Repository navigation
Description
Problem
afx workspace list (Spec 1940, PR #1957) shows stopped workspaces as running. On a Tower with 53 registered workspaces, 12 of which have a live terminal, the listing marks only 7 as not running. The other 34 stopped workspaces are printed as running, with their registered architects and builders as addresses marked no live terminal.
Found in the project's verify step on the installed Tower, by the builder and confirmed by the architect.
Cause
tower-address-book.ts sets running: listed.entry !== undefined, where the entry is the workspace's slot in Tower's in-memory terminal map. getWorkspaceTerminalsEntry() (tower-terminals.ts) is get-or-create and is called from about a dozen routes, so any route that is merely asked about a workspace (dashboard or extension polling, for example) leaves an empty entry behind. An empty entry is not a running workspace. Which route created these entries is inferred, not proved.
The tests did not see it because their fixtures put a workspace in the map only when it has terminals.
Consequences
- The listing calls stopped workspaces running and prints addresses for them. Mail to one is held
no-live-ptyand waits, where a workspace with no entry is refused as not running. - The naming rules use the same set for "running", so a stopped workspace with an empty entry can make a shared directory name ambiguous. (The pre-1940 resolver iterated the same map, so this half is not new.)
afx whoamicounts running fromterminal_sessionsrows, so whoami and Tower can disagree.
No mail goes to a wrong recipient, and the headline path (a named architect in a running workspace) is unaffected.
Ask
- One definition of "running", in one function, used by the address book, the naming and ambiguity rules, the resolvers' "not running" refusal, and
afx whoami: the workspace has at least one live terminal (decide and state whether a workspace that is activated but has no terminal yet counts, and test it). - Decide what a send to a registered architect in a stopped workspace should do, and make the listing and the send agree: either refused as not running (what the spec's listing implies) or held, but the same answer whichever route created or did not create an entry.
- Consider making the read routes use a lookup that does not create an entry. If that is a larger change than this fix, say so and leave it; the definition in (1) must not depend on it.
- Tests: a workspace with an empty entry is listed
not runningwith no agents; it does not take part in ambiguity; a send to it gets the answer chosen in (2); whoami agrees with the listing. - Verify on a real Tower with many registered workspaces: the count of running workspaces in
afx workspace listequals the count with a live terminal.
Activity
waleedkadous commentedon Nov 24, 2026
On it! Working on a fix now.
[Bugfix #1978] Fix: a workspace runs while it has an open terminal, n…
[Bugfix #1978] Test: an empty terminal-map slot is not a running work…
[Bugfix #1978] Thread: investigation, decisions and fix notes
[Bugfix #1978] Fix: review follow-ups — structural running flag, name…
waleedkadous commentedon Nov 25, 2026
Verified on a real Tower after PR #1980 merged (
5d5f88f4b), installed frommainat6cb29ec8e.afx workspace list --json: 52 workspaces, 12 running, 12 with a live agent; no workspace is running without a live agent, and no stopped workspace lists agents. Before the fix the same Tower showed 45 of 52 as running with 12 live.Workspace '<name>' (<path>) is not running. (NOT_FOUND), exit 1, and no mailbox row was written for it.afx whoamiagrees with the listing for the sender's workspace.Not verified live: the reconnect window right after a Tower restart (covered by the tests in the PR), and the name-clash case (no two workspaces share a name on this machine).