Skip to content

agora phase 2 — tui: the seat fleet as a navigable organisation chart, Enter opens the conversation - #93

Merged
SSFSKIM merged 9 commits into
mainfrom
worktree-agora-tui
Sep 2, 2026
Merged

SSFSKIM merged 9 commits into
mainfrom
worktree-agora-tui

Conversation

@SSFSKIM

@SSFSKIM SSFSKIM commented Sep 2, 2026 •

Copy link
Copy Markdown
Owner

Summary

agora phase 2 — the fleet as a navigable organisation chart. agora tui draws a group (or the whole fleet) as boxes: roots on the left, children to the right, siblings stacked, each seat showing its alias, role, a live-state glyph and the one-line status the agent set. Arrow keys move a heavy-bordered focus; Enter opens that seat's conversation with claude attach in a new tmux window, so the chart stays up and returning to the map is an ordinary tmux window switch. s types a message and delivers it over the seat's inbox socket, b shows the group's board with a post overlay, a unfolds retired seats, ? lists the keys.

The same layout engine renders without curses: agora chart [group] prints the chart as text, for agents and for anyone outside tmux.

What lands:

  • skills/agora/scripts/agora_chart.py — snapshot() reads seats plus live state into a node forest and folds dead seats (retired, failed, errored, or gone from the harness) into a +N retired note on their parent; layout() places boxes left-to-right with per-depth column widths and bus connectors; paint_chart() draws onto a Screen. Display width is counted in cells, so a Korean status line keeps a box's borders aligned.
  • skills/agora/scripts/agora_tui.py — one state dict, handle_key() as the whole keymap, paint() onto any Screen. Effects sit behind an actions object: RealActions opens or switches tmux windows and runs agora send off the drawing thread; HeadlessActions records decisions, so agora tui --headless --keys "right,down,enter" drives the identical code from the bash suite. A refresher thread re-reads the harness every few seconds (the read takes over a second, so it never runs on the drawing thread). Started outside tmux, agora tui re-executes itself inside tmux new-session -A -s agora.
  • A liveness fix in agora core (see below), plus refresh_caches() for a long-lived reader.
  • skills/agora/SKILL.md documents both verbs; skills/execplan/SKILL.md drops the one-milestone-per-fork execution shape.

The defect the live proof found

peer_live() decided whether a seat's session was still the process its record described by comparing the harness's recorded procStart with what ps -o lstart= prints — as text. The harness writes that field in UTC; ps prints local time. On any machine not on UTC the comparison never matched, so every live seat read as stopped: agora send refused with "not live", wake resumed a session instead of using its open socket, and sync mirrored idle sessions as stopped.

Observed here (KST): for live pid 28115 the record said Wed Sep 2 22:38:53 2026 and ps said Thu Sep 3 07:38:53 2026 — the same instant, 32400 seconds apart — and every peer record on this machine from harness 2.1.251 through 2.1.259 carried the same offset. same_process() now compares instants and accepts the recorded string read as either UTC or local.

Two reasons the v3 suite could not catch it: its fabricated peer records carry no procStart at all (the check is skipped when either side is unparseable), and the first regression test written for it also passed without the fix, because a Korean-locale ps prints 수 9/ 2 23:08:14 2026, which the helper could not parse. Reading ps under LC_ALL=C, as agora.proc_start already does, made the assertion fail without the fix and pass with it.

Review

A codex native review of the branch (gpt-5.6-sol) returned four findings; all were confirmed and fixed in eaf9c287:

  • Bind a composed message to its seat. A refresh landing while the operator types rebuilds the layout and can move the focus, so Enter sent the text to whatever was focused by then — and in fleet view could hand a group node to the send path, crashing on node["seat"]. The target is captured when the editor opens; if it has left the chart, the message is dropped with a reason.
  • Relaunch into a surviving tmux session. The agora session outlives the chart, because the conversation windows Enter opens keep it alive. new-session -A then merely attaches and drops the command, landing the operator in an old conversation with no chart. An existing session now gets a fresh chart window. Verified live: with a leftover window holding the session open, agora tui opened window chart and attached to it.
  • Qualify attach windows. Open windows were keyed by bare alias, so the same alias in two groups switched to the wrong seat's conversation. Keyed by qualified seat id now.
  • Count folded subtrees. Folding a dead child added one for its entire dead subtree, so a box could say +1 retired while the summary counted several.

Testing the first one needed a way to move the focus mid-run, which the keymap cannot do (input mode swallows every keystroke). --keys now accepts two driver-level tokens, !focus:<id> and !drop:<id>, that do what only the refresh thread does in a live screen.

Verification

  • tests/agora/run-agora-tests.sh: 504 assertions pass (406 before this branch) — 27 for the chart, 60 for the screen driven headlessly, 4 for the process-identity fix, 7 for the review wave.
  • The regression is proved to bite: with the old string comparison restored, 1 of 497 assertions FAILED — a procStart written in UTC identifies the same process; with the fix, all 497 pass.
  • Live proof on the real harness, inside tmux, against the real registry: a seat spawned into group demo replied PONG-TUI; agora tui demo rendered it; Enter opened claude attach in window 1 while the chart kept running in window 0; Enter again switched to that window rather than opening a second; q quit the chart and left the conversation window open. After the liveness fix, s delivered to a live seat and it replied "Reachable. What's needed?". Transcripts are in the plan's Artifacts section.
  • tests/claude-code/run-skill-tests.sh: 17 passed, 8 skipped (gated tiers), 1 failed — test-subagent-driven-execution.sh, which greps a model's free-form prose for executor.*fix. It passed on a rerun, and this branch does not touch that skill.

Plan

docs/doperpowers/execplans/2026-09-02-agora-tui.md — the living ExecPlan: Decision Log (grill choices and the calls made while building), Surprises (the liveness defect and its evidence, the harness's own agent view, what claude attach does to a stopped session, background pids that outlive their session record), Artifacts (chart output and live-proof transcripts).

New skills/agora/scripts/agora_chart.py: snapshot() reads seats + live state
into a node forest and folds dead seats (retired/failed/error, or gone from the
harness) into a +N retired note; layout() places boxes roots-left, children
right, siblings stacked, parents centred on their children, with bus
connectors; paint_chart() draws onto a Screen (GridScreen renders text).
agora.py gains the chart verb (group optional → fleet with rounded group boxes,
--all, --width), refresh_caches() for a long-lived reader, and chart_module()
so the chart binds to the running module's caches. 27 assertions on an org
fixture (busy/idle/blocked/vacant/retired, Korean now line keeps borders
aligned).
…rows move, enter attaches in a tmux window, s sends, detail/board panels, headless driver

New skills/agora/scripts/agora_tui.py: one state dict, handle_key() as the
whole keymap, paint() onto any Screen; RealActions opens claude attach in a
new tmux window (or switches to the seat's open one) and runs agora send in a
thread; HeadlessActions records decisions so agora tui --headless --keys …
drives the same code from the bash suite. A Refresher thread re-reads the
harness every AGORA_TUI_REFRESH seconds off the drawing thread. agora tui
re-execs itself inside tmux new-session -A -s agora when started outside tmux.
agora.py gains the tui verb and sibling_module(); agora_chart.fit() learns
collapse=False for columnar text. 60 headless assertions.
… string

peer_live compared the harness's procStart (written in UTC) with ps -o lstart=
(printed in local time) as text, so on any machine not on UTC every live seat
read as stopped: agora send refused everything, wake resumed instead of using
the socket, and sync mirrored idle sessions as stopped. Observed on this
machine (KST): the record said 'Wed Sep 2 22:38:53 2026' and ps said
'Thu Sep 3 07:38:53 2026' for the same live pid, an exact 9-hour offset, on
every record from harness 2.1.251 through 2.1.259.

same_process() now compares instants and accepts the recorded string read as
either UTC or local. Three assertions pin it, using the suite's own live
socket-server pid: local-form and UTC-form procStart both identify the process
(the UTC one fails without this fix), an unrelated time still reads as a
recycled pid. The helper reads ps under LC_ALL=C, as agora does — a localized
ps prints an unparseable date and silently skips the check.
…evidence, live-proof transcripts; SKILL.md documents chart and tui
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-02T23:49:12.742282Z 65b1116 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 65b11166fc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread skills/execplan/SKILL.md

Run it milestone by milestone through `fork` subagents, one milestone per fork. You stay the orchestrator: the fork inherits your full context — the grill, the reasoning behind the plan, the state of the branch — so it starts oriented instead of re-deriving, and the implementation churn stays out of your context, which is what makes a long plan survivable in a single session. Dispatch in plan order and wait for each fork before the next; milestones build on each other and the next one needs the previous result in the tree. Brief each fork with its milestone's scope and acceptance, and let it own that milestone's bookkeeping and commits. When it reports back, verify the acceptance yourself — holding the whole arc is the orchestrator's job. A milestone too small to be worth a dispatch is fine to do inline; this is the default shape, not a gate.

This profile fits durable background sessions — seats spawned through doperpowers:agora: the ExecPlan is exactly what a spawn prompt can carry, and it survives the seat's context death — the document is the memory.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Restore this protocol until its behavior is evaluated

This deletes the ExecPlan track's only default execution shape, allowing future long plans to run inline or with unconstrained delegation, but this commit provides no before/after skill-behavior evaluation or pressure-test results for that change—the reported 497 assertions exercise the Agora CLI/TUI. Restore the protocol or provide the required behavioral evidence before changing it. CLAUDE.mdL32-L39

Useful? React with 👍 / 👎.

Comment thread skills/agora/scripts/agora_tui.py Outdated
Comment on lines +227 to +230
text, state["input"] = state["input"].strip(), None
node = focused_node(state)
if text and node is not None:
actions.send(node, text)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Bind message input to the originally selected seat

If the selected seat disappears or becomes hidden while the operator is typing, the three-second refresher calls rebuild(), which moves focus to the first visible root; Enter then resolves focused_node(state) again here and sends the text to that different seat. Preserve the target seat ID when input mode starts and either send to that same seat or refuse if it is no longer available.

Useful? React with 👍 / 👎.

Comment thread skills/agora/scripts/agora_chart.py Outdated
if prune(c):
kept.append(c)
else:
node["hidden"] += 1 + count_nodes(c["children"])

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Include all descendants in folded-seat counts

When an entirely dead subtree is pruned, recursive calls have already removed its descendants from c["children"] and accumulated them in c["hidden"]. Counting only the remaining children therefore reports +1 retired for a dead node with any number of dead descendants, even though the summary correctly counts the whole subtree; include the child's accumulated hidden count.

Useful? React with 👍 / 👎.

return [(node["label"], ""), (counts, ""), (("+%d retired" % node["hidden"]) if node["hidden"] else "", "")]
live = node["live"] or "unknown"
state = "%s %s" % (GLYPH.get(live, "?"), live)
tail = node["now"] or (("+%d retired" % node["hidden"]) if node["hidden"] else "")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve the retired note when a parent has status text

For a live parent that has both a now value and folded dead children, this expression always selects now and suppresses the +N retired note. Since active seats commonly set their status line, the chart then loses the promised indication of which parent owns the hidden seats; render both pieces, or otherwise reserve a visible place for the folded count.

Useful? React with 👍 / 👎.

Comment thread skills/agora/scripts/agora_tui.py Outdated
alias = node["label"]
try:
wins = self._tmux("list-windows", "-F", "#{window_id}").stdout.split()
wid = st["attached"].get(alias)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Key attached windows by full seat identity

Fleet mode permits the same alias in different groups, but this lookup keys the window cache only by alias. After opening group-a/scout, pressing Enter on group-b/scout will select the first seat's existing window instead of opening the second conversation; use the node's full group/alias ID as the cache key.

Useful? React with 👍 / 👎.



def main_loop(stdscr, state, curses):
curses.curs_set(0)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Tolerate terminals that cannot hide the cursor

On a real TTY whose terminfo lacks the cursor-visibility capability—reproducible with TERM=dumb, particularly when using the documented --no-tmux mode—curses.curs_set(0) raises curses.error, and the wrapper exits before rendering anything. Treat cursor hiding as optional by catching that exception, as the color initialization already does.

Useful? React with 👍 / 👎.

…ch into a surviving tmux session, qualify attach windows, count folded subtrees

Four findings from the codex review of this branch, all confirmed:

- A refresh landing while the operator types rebuilds the layout and can move
  the focus, so enter sent the text to whatever was focused then — and to a
  GROUP node in fleet view, which crashed on node["seat"]. The target is now
  captured when the editor opens; if it has left the chart the message is
  dropped with a reason.
- The agora tmux session outlives the chart (enter's conversation windows keep
  it alive), so new-session -A on the next run merely attached and dropped the
  command, landing the operator in an old conversation with no chart. An
  existing session now gets a fresh chart window.
- Open conversation windows were keyed by bare alias, so the same alias in two
  groups switched to the wrong seat's window. Keyed by qualified seat id now.
- Folding a dead child added one for its whole dead subtree, so a box said
  '+1 retired' while the summary counted several.

7 new assertions, including two driver-level tokens (!focus, !drop) that let
the suite reproduce what only the refresh thread does in a live screen. The
tmux relaunch is verified live: with a leftover window holding the session
open, agora tui opens window 'chart' and attaches to it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant