Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ and listed with their assets on the
prompt, a hook's text, a tool's arguments or its answer, on this machine,
for a week (ADR-0098). The agent's own tools (its shell, its edits) do
not pass devstack and are not shown.
- **A lane shows its agents' sessions in time.** The lane's Activity has a
second view, Timeline: per session, the prompts (when, never what), the
model's turns, every tool call by where it went (devstack, an upstream,
another MCP server, the agent's own tools, sub-agents) with how long it
took, what changed the lane and the hooks given; below, how full the
context was and the tokens summed up (cache read, written, input, output).
Pauses longer than two minutes are pushed together; hovering a call says
the tokens used until then. The turns, tokens and the agent's own tools
come from the agent's transcript, which the hub reads only once
**Read transcripts** is switched on (off by default), for Claude Code and
Codex, taking only times, counts and names (ADR-0099). The activity list
of the Skills page moved here.

## [0.42.0] - 2026-11-06

Expand Down
14 changes: 14 additions & 0 deletions crates/devstack-hub/src/activity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ pub enum Record {
/// `session-end`: the end was kept for the next start.
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
recorded: bool,
/// Where the agent keeps the session's transcript, as its hook's
/// input names it: the path only, never what is in it. The
/// timeline reads it when switched on (`transcript`).
#[serde(default, skip_serializing_if = "Option::is_none")]
transcript: Option<String>,
},
/// A tool call through `devstack mcp`.
Tool {
Expand Down Expand Up @@ -251,6 +256,10 @@ pub fn view(
let mut out = Vec::new();
for r in records {
let mut v = serde_json::to_value(r).expect("serialises");
// The transcript's path is the timeline's, not the page's.
if let Some(o) = v.as_object_mut() {
o.remove("transcript");
}
// A record without a session of its own (a tool call, a lane's
// stop): the latest session that started in its tree before it.
let own = matches!(
Expand Down Expand Up @@ -299,6 +308,9 @@ pub fn view(
if out.len() > MAX {
out.drain(..out.len() - MAX);
}
if let Some(t) = tree {
sessions.retain(|s| s.tree == t);
}
sessions.sort_by_key(|s| std::cmp::Reverse(s.last));
View {
sessions,
Expand Down Expand Up @@ -361,6 +373,7 @@ mod tests {
tree: tree.into(),
hooks: Vec::new(),
recorded: event == "session-end",
transcript: None,
}
}

Expand Down Expand Up @@ -441,6 +454,7 @@ mod tests {
tree: "/a".into(),
hooks: Vec::new(),
recorded: false,
transcript: None,
},
];
let v = view(&records, None, None, None, &prefixes, &index);
Expand Down
4 changes: 3 additions & 1 deletion crates/devstack-hub/src/agenthooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,8 @@ struct Input {
/// Why a session starts: `startup`, `resume`, `clear`, `compact`.
#[serde(default)]
source: Option<String>,
/// The session's transcript (`session-end`): named at the next start.
/// The session's transcript: named at the next start (`session-end`),
/// and recorded for the timeline (its path only).
#[serde(default, alias = "transcriptPath")]
transcript_path: Option<String>,
}
Expand Down Expand Up @@ -483,6 +484,7 @@ fn record(
tree: cwd.map(tree_of).unwrap_or_default(),
hooks,
recorded,
transcript: input.transcript_path.clone().filter(|s| !s.is_empty()),
};
if let Err(e) = crate::activity::write(at.state, &r) {
(at.warn)(e);
Expand Down
69 changes: 68 additions & 1 deletion crates/devstack-hub/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ mod share;
mod shared;
mod stdio;
mod summary;
mod transcript;
pub mod tray;
pub mod upstreams;
mod watchdog;
Expand Down Expand Up @@ -664,6 +665,11 @@ fn router(state: AppState) -> axum::Router {
.route("/hub/pool/skills/{name}", delete(pool::skill_remove))
.route("/hub/skills", get(poolskills::get))
.route("/hub/activity", get(activity_get))
.route("/hub/activity/timeline", get(timeline_get))
.route(
"/hub/activity/transcripts",
get(transcripts_get).put(transcripts_put),
)
.route("/hub/skills/sync", post(poolskills::sync))
.route("/hub/skills/agents/{id}", put(poolskills::agent))
.route("/hub/skills/sets/{pool}/{set}", put(poolskills::auto))
Expand Down Expand Up @@ -2914,9 +2920,14 @@ async fn activity_get(State(s): State<AppState>, Query(q): Query<ActivityQuery>)
.filter_map(|v| v.pool.map(|p| (p.pool, p.name, v.prefix)))
.collect();
let index = agenthooks::read_index(&state);
// A tree as the records write it, whatever separators or case the page used.
let tree = q
.tree
.as_deref()
.map(|t| activity::tree_of(std::path::Path::new(t)));
activity::view(
&records,
q.tree.as_deref(),
tree.as_deref(),
q.session.as_deref(),
q.since,
&prefixes,
Expand All @@ -2930,6 +2941,62 @@ async fn activity_get(State(s): State<AppState>, Query(q): Query<ActivityQuery>)
}
}

#[derive(Deserialize)]
struct TimelineQuery {
session: String,
#[serde(default)]
agent: Option<String>,
}

/// `GET /hub/activity/timeline?session=&agent=`: a session in time, from
/// devstack's records and, when switched on, the agent's transcript.
async fn timeline_get(State(s): State<AppState>, Query(q): Query<TimelineQuery>) -> Response {
let ups = s.upstreams.clone();
let got = tokio::task::spawn_blocking(move || {
let state = activity::state();
let records = activity::read(&state);
let prefixes: activity::Prefixes = ups
.views()
.unwrap_or_default()
.into_iter()
.filter_map(|v| v.pool.map(|p| (p.pool, p.name, v.prefix)))
.collect();
let index = agenthooks::read_index(&state);
let enabled = transcript::Setting::load(&state).enabled;
transcript::timeline(
&records,
&q.session,
q.agent.as_deref(),
&prefixes,
&index,
enabled,
)
})
.await;
match got {
Ok(Some(v)) => Json(v).into_response(),
Ok(None) => err(StatusCode::NOT_FOUND, "no such session"),
Err(e) => err(StatusCode::INTERNAL_SERVER_ERROR, e.to_string()),
}
}

/// `GET /hub/activity/transcripts`: whether the hub reads the agents'
/// transcripts for the timeline (off until switched on).
async fn transcripts_get() -> Response {
Json(transcript::Setting::load(&activity::state())).into_response()
}

/// `PUT /hub/activity/transcripts {enabled}`: switch it on or off.
async fn transcripts_put(Json(b): Json<transcript::Setting>) -> Response {
match transcript::Setting::save(b, &activity::state()) {
Ok(()) => {
devstack_daemon::diag::info("transcripts", serde_json::json!({ "enabled": b.enabled }));
Json(b).into_response()
}
Err(e) => err(StatusCode::INTERNAL_SERVER_ERROR, e),
}
}

/// `DELETE /hub/upstreams/{name}`: it and its credential go.
async fn upstream_remove(State(s): State<AppState>, Path(name): Path<String>) -> Response {
on_upstreams(&s, move |ups| {
Expand Down
Loading