Skip to content

Commit 0b0a959

Browse files
codydeclaude
andauthored
feat(ca): thread-first sidebar with work status (#1352)
Reorganizes the `railway ca` sidebar around threads and where each one's work stands, instead of around machines. - Threads are grouped by attention: needs you, working, done, then the rest. Machines, projects and automations fold below. - Each thread and agent shows its work status (idle, working, done, blocked, error) from the API, with markers for connected, awake, sleeping, waking and down. - Enter on a sleeping thread wakes its machine and reopens that thread, with an opening card that shows the steps as they happen. - Agents can be archived and unarchived, and finished work is marked seen when opened. - `railway ca list` gains a STATE column. - Shared searchable list card for the target, settings and wizard pickers. Adds the `workStatus`, `archivedAt`, mark-seen and archive operations to the schema file. Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
1 parent 862cd9b commit 0b0a959

30 files changed

Lines changed: 9609 additions & 4711 deletions

‎src/commands/cloud_agent/bootstrap.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,8 @@ mod tests {
250250
project_id: "project".into(),
251251
environment_id: "env".into(),
252252
created_at: chrono::Utc::now(),
253+
work_status: None,
254+
archived: false,
253255
}
254256
}
255257

‎src/commands/cloud_agent/herdr/agents.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,8 @@ mod tests {
525525
project_id: "project-1".into(),
526526
environment_id: "environment-1".into(),
527527
created_at: chrono::Utc::now(),
528+
work_status: None,
529+
archived: false,
528530
};
529531
api.stub(
530532
"CloudAgentWake",

‎src/commands/cloud_agent/herdr/sync.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,8 @@ mod tests {
545545
project_id: "project".into(),
546546
environment_id: "env".into(),
547547
created_at: Utc::now(),
548+
work_status: None,
549+
archived: false,
548550
}
549551
}
550552

‎src/commands/cloud_agent/lifecycle.rs‎

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ pub struct ListArgs {
6666
#[clap(long)]
6767
all: bool,
6868

69+
/// List archived agents instead of the rest
70+
#[clap(long)]
71+
archived: bool,
72+
6973
/// Output as JSON
7074
#[clap(long)]
7175
json: bool,
@@ -258,14 +262,17 @@ pub async fn list(args: ListArgs) -> Result<()> {
258262
let backboard = configs.get_backboard();
259263
let mut agents = match &scoped {
260264
Some(environment_id) => {
261-
ca::list_in_environment(client, &backboard, environment_id, !args.all).await?
265+
ca::list_in_environment_with_work(client, &backboard, environment_id, !args.all).await?
262266
}
263-
None => ca::list_mine(client, &backboard).await?,
267+
None => ca::list_mine_with_work(client, &backboard).await?,
264268
};
269+
agents.retain(|agent| agent.archived == args.archived);
265270

266271
if agents.is_empty() {
267272
if args.json {
268273
println!("[]");
274+
} else if args.archived {
275+
println!("No archived cloud agents.");
269276
} else if scoped.is_some() {
270277
println!("No cloud agents in this environment.");
271278
} else {
@@ -296,6 +303,14 @@ pub async fn list(args: ListArgs) -> Result<()> {
296303
"environmentId": a.environment_id,
297304
"environment": names.get(&a.environment_id),
298305
"createdAt": a.created_at.to_rfc3339(),
306+
"archived": a.archived,
307+
"workStatus": a.work_status.as_ref().map(|w| serde_json::json!({
308+
"state": format!("{:?}", w.state).to_uppercase(),
309+
"kind": w.kind,
310+
"message": w.message,
311+
"unseen": w.unseen,
312+
"at": w.at,
313+
})),
299314
})
300315
})
301316
.collect();
@@ -304,9 +319,10 @@ pub async fn list(args: ListArgs) -> Result<()> {
304319
}
305320

306321
println!(
307-
" {:<24} {:<9} {:<22} {:<14} {}",
322+
" {:<24} {:<9} {:<8} {:<22} {:<14} {}",
308323
"NAME".dimmed(),
309324
"STATUS".dimmed(),
325+
"STATE".dimmed(),
310326
"PROJECT".dimmed(),
311327
"ENVIRONMENT".dimmed(),
312328
"AGE".dimmed()
@@ -317,10 +333,11 @@ pub async fn list(args: ListArgs) -> Result<()> {
317333
marked |= current;
318334
let place = |id: &String| names.get(id).cloned().unwrap_or_else(|| truncate(id, 22));
319335
println!(
320-
"{} {:<24} {:<9} {:<22} {:<14} {}",
336+
"{} {:<24} {:<9} {:<8} {:<22} {:<14} {}",
321337
if current { "*" } else { " " },
322338
truncate(&agent.name, 24),
323339
colorize_status(&agent.status),
340+
colorize_work(agent.work_status.as_ref()),
324341
truncate(&place(&agent.project_id), 22),
325342
truncate(&place(&agent.environment_id), 14),
326343
ca::humanize_age(agent.created_at)
@@ -329,9 +346,43 @@ pub async fn list(args: ListArgs) -> Result<()> {
329346
if marked {
330347
println!("\n{}", "* this directory's agent".dimmed());
331348
}
349+
if agents
350+
.iter()
351+
.any(|a| a.work_status.as_ref().is_some_and(|w| w.unseen))
352+
{
353+
println!("{}", "+ finished or failed since you last looked".dimmed());
354+
}
332355
Ok(())
333356
}
334357

358+
/// Where an agent's work stands, as the platform reports it: `+` marks an
359+
/// outcome nobody has looked at yet.
360+
fn colorize_work(work: Option<&super::tui::work_status::WorkStatus>) -> colored::ColoredString {
361+
use super::tui::work_status::WorkState;
362+
let Some(work) = work else {
363+
return "-".dimmed();
364+
};
365+
let label = match work.state {
366+
WorkState::Idle => "idle",
367+
WorkState::Working => "working",
368+
WorkState::Done => "done",
369+
WorkState::Blocked => "blocked",
370+
WorkState::Error => "error",
371+
};
372+
let label = if work.unseen {
373+
format!("{label}+")
374+
} else {
375+
label.to_string()
376+
};
377+
match work.state {
378+
WorkState::Blocked => label.yellow(),
379+
WorkState::Error => label.red(),
380+
WorkState::Working => label.green(),
381+
WorkState::Done if work.unseen => label.green(),
382+
_ => label.dimmed(),
383+
}
384+
}
385+
335386
pub async fn create(args: CreateArgs) -> Result<()> {
336387
let mut configs = Configs::new()?;
337388
let client = GQLClient::new_authorized(&configs)?;

‎src/commands/cloud_agent/mod.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,7 @@ async fn browse_with_inner(opts: BrowseOpts) -> Result<()> {
483483
app.skills_enabled = saved.skills.enabled;
484484
app.hide_tabs = saved.hide_tabs;
485485
app.sidebar_width = saved.sidebar_width;
486+
app.automations_expanded = !saved.automations_collapsed;
486487
// What the key check learned. Connects gate on this in-frame: an
487488
// unregistered key raises a register question instead of a hung prompt.
488489
app.ssh_key = ssh_key;

‎src/commands/cloud_agent/prefs.rs‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ pub struct AgentPrefs {
5858
/// Sidebar width in terminal columns, including its border.
5959
#[serde(default, skip_serializing_if = "Option::is_none")]
6060
pub sidebar_width: Option<u16>,
61+
/// The sidebar's automations list was folded, and stays folded.
62+
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
63+
pub automations_collapsed: bool,
6164
}
6265

6366
impl Default for AgentPrefs {
@@ -71,6 +74,7 @@ impl Default for AgentPrefs {
7174
theme: None,
7275
hide_tabs: false,
7376
sidebar_width: None,
77+
automations_collapsed: false,
7478
}
7579
}
7680
}
@@ -164,6 +168,12 @@ impl AgentPrefs {
164168
prefs.save_in(home)
165169
}
166170

171+
pub fn save_automations_collapsed_in(home: &Path, collapsed: bool) -> Result<()> {
172+
let mut prefs = Self::load_in(home).unwrap_or_default();
173+
prefs.automations_collapsed = collapsed;
174+
prefs.save_in(home)
175+
}
176+
167177
pub fn save_in(&self, home: &Path) -> Result<()> {
168178
let path = Self::path_in(home);
169179
let contents = serde_json::to_string_pretty(self)?;
@@ -211,6 +221,7 @@ mod tests {
211221
theme: Some("ember".into()),
212222
hide_tabs: true,
213223
sidebar_width: Some(46),
224+
automations_collapsed: true,
214225
};
215226
prefs.save_in(home.path()).unwrap();
216227
assert_eq!(AgentPrefs::load_in(home.path()).unwrap(), prefs);

‎src/commands/cloud_agent/setup.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ async fn prompt(home: &Path, existing: Option<AgentPrefs>) -> Result<AgentPrefs>
252252
theme: Some(theme),
253253
hide_tabs: previous.hide_tabs,
254254
sidebar_width: previous.sidebar_width,
255+
automations_collapsed: previous.automations_collapsed,
255256
})
256257
}
257258

‎src/commands/cloud_agent/tui/activity.rs‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,21 @@ pub(super) async fn fetch(
9292
}
9393

9494
pub(super) fn apply(app: &mut App, agent: &str, reports: &[Report]) {
95+
app.reports_seen(
96+
agent,
97+
&reports
98+
.iter()
99+
.map(|r| {
100+
(
101+
r.session_id.clone(),
102+
r.title.clone(),
103+
r.prompt.clone(),
104+
r.latest_prompt.clone(),
105+
r.updated_at.clone(),
106+
)
107+
})
108+
.collect::<Vec<_>>(),
109+
);
95110
let mut updates = Vec::new();
96111
for pane in &mut app.sessions {
97112
if pane.agent_id != agent

0 commit comments

Comments
 (0)