Repository navigation
fix(ls): check executor state for non-tmux (SDK/omni) agents #1167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2134,14 +2134,32 @@ type WorkerStatus = { | |||||||||||||||
| autoResume?: boolean; | ||||||||||||||||
| }; | ||||||||||||||||
|
|
||||||||||||||||
| /** | ||||||||||||||||
| * Resolve liveness + display state for a worker. | ||||||||||||||||
| * | ||||||||||||||||
| * - Tmux transport: `isPaneAlive(%N)` is authoritative and `agents.state` is | ||||||||||||||||
| * kept in sync, so we preserve the legacy behavior exactly. | ||||||||||||||||
| * - Non-tmux transports (SDK, omni, inline): pane IDs are synthetic ('sdk', '', | ||||||||||||||||
| * 'inline') and fail tmux's regex, so we query `executors.state` directly. | ||||||||||||||||
| * The cached `agents.state` is stale for these transports — we use the live | ||||||||||||||||
| * executor state for display as well. | ||||||||||||||||
| */ | ||||||||||||||||
| async function resolveWorkerLiveness(w: registry.Agent): Promise<{ alive: boolean; state: string }> { | ||||||||||||||||
| if (/^%\d+$/.test(w.paneId)) { | ||||||||||||||||
| return { alive: await isPaneAlive(w.paneId), state: w.state }; | ||||||||||||||||
| } | ||||||||||||||||
| const execState = await executorRegistry.getLiveExecutorState(w.id); | ||||||||||||||||
| return { alive: execState !== null, state: execState ?? w.state }; | ||||||||||||||||
|
Comment on lines
+2148
to
+2152
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Useful? React with 👍 / 👎. |
||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| /** Build a name → status map from registry workers, including resume info for dead agents. */ | ||||||||||||||||
| async function buildWorkerStatusMap(workers: registry.Agent[]): Promise<Map<string, WorkerStatus>> { | ||||||||||||||||
| const statusMap = new Map<string, WorkerStatus>(); | ||||||||||||||||
| for (const w of workers) { | ||||||||||||||||
| const name = w.role || w.id; | ||||||||||||||||
| const alive = await isPaneAlive(w.paneId); | ||||||||||||||||
| const { alive, state } = await resolveWorkerLiveness(w); | ||||||||||||||||
|
Comment on lines
2158
to
+2160
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The loop performs sequential asynchronous calls to
Suggested change
|
||||||||||||||||
| if (alive) { | ||||||||||||||||
| statusMap.set(name, { state: w.state, team: w.team || '-' }); | ||||||||||||||||
| statusMap.set(name, { state, team: w.team || '-' }); | ||||||||||||||||
| } else if (w.state === 'suspended' || w.state === 'error') { | ||||||||||||||||
| const attempts = w.resumeAttempts ?? 0; | ||||||||||||||||
| const max = w.maxResumeAttempts ?? 3; | ||||||||||||||||
|
|
||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
getLiveExecutorStatefunction returnsnullfor terminal states (done,error,terminated). However, as noted in the function's documentation, theagents.statecolumn is stale for non-tmux transports. By returningnullfor dead executors, you force the caller to fall back to this stale data, which can result ingenie lsshowing an incorrect status (e.g.,offlineinstead oferror) for crashed agents. Consider returning the authoritative executor state regardless of liveness and letting the caller determine how to handle terminal states.