Skip to content

afx workspace list shows stopped workspaces as running: an empty terminal-map entry counts as running #1978

Done

Description

@waleedkadous

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

  1. The listing calls stopped workspaces running and prints addresses for them. Mail to one is held no-live-pty and waits, where a workspace with no entry is refused as not running.
  2. 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.)
  3. afx whoami counts running from terminal_sessions rows, 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

  1. 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).
  2. 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.
  3. 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.
  4. Tests: a workspace with an empty entry is listed not running with no agents; it does not take part in ambiguity; a send to it gets the answer chosen in (2); whoami agrees with the listing.
  5. Verify on a real Tower with many registered workspaces: the count of running workspaces in afx workspace list equals the count with a live terminal.

Activity

  1. added
    area/tower
    on Nov 24, 2026
  2. waleedkadous commented on Nov 24, 2026

    @waleedkadous
    ContributorAuthor

    On it! Working on a fix now.

  3. added 4 commits that reference this issue on Nov 24, 2026
  4. waleedkadous commented on Nov 25, 2026

    @waleedkadous
    ContributorAuthor

    Verified on a real Tower after PR #1980 merged (5d5f88f4b), installed from main at 6cb29ec8e.

    • 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.
    • A send that names a stopped workspace is refused: Workspace '<name>' (<path>) is not running. (NOT_FOUND), exit 1, and no mailbox row was written for it.
    • afx whoami agrees 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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/tower

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions