Commit d1f62b0
fix: don't pin dashboard to a non-orchestrator session (#12)
* fix: don't pin dashboard to a non-orchestrator session
The dashboard discovers delegates by scanning the *parent* (orchestrator)
session's messages for "Task <id> started in background" and never re-resolves
that parent once pinned. Two paths could pin the wrong session, leaving the UI
stuck on "Spawning delegates..." with 0 delegates forever — even while delegate
messages stream onto the wall (the wall is keyed off GOOSE_GTWALL_FILE, so it
keeps working independently):
1. dashboard `resolve_session()` trusted `AGENT_SESSION_ID` unconditionally and
passed it as `--session`, bypassing goosetown-ui's own discovery. goose
exports a *terminal* session id into shell subprocesses, so launching the
dashboard from a goose shell pinned that terminal session — which has no
delegates.
2. `sessions_tree_watcher()` reads `parent_id` once and never re-resolves, so any
wrong/early pin is permanent.
Fix:
- resolve_session(): only trust AGENT_SESSION_ID when it actually has delegate
activity; otherwise prefer SQL discovery of a delegate-bearing session, and
fall back to AGENT_SESSION_ID / most-recent user session only as a last resort.
Adds a `session_has_delegates()` helper.
- sessions_tree_watcher(): when the pinned parent yields 0 children, re-resolve
via find_parent_session() and adopt a candidate only if it actually has
children — self-healing without thrashing between empty sessions.
Verified against a real sessions.db that exhibited the bug: with
AGENT_SESSION_ID set to a terminal session, resolve_session now returns the
orchestrator session, and the watcher re-resolves a wrongly-pinned parent to the
orchestrator (6 delegates) while leaving a correct parent untouched.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix: scope dashboard session resolution to the instance's wall
All goosetowns on a machine share one sessions.db, and sessions carry no
instance/wall identifier. The previous resolution ("most recent delegate-bearing
user session") and the self-heal added in the prior commit would, with multiple
concurrent instances, resolve or re-pin to *another* instance's orchestrator —
e.g. instance A's dashboard adopting instance B's delegates whenever A's
orchestrator momentarily had 0 children.
Use the wall as the per-instance anchor. An instance's wall lists its delegates'
gtwall IDs (senders), and the orchestrator's delegate-spawn messages declare those
same IDs (already parsed by build_sender_session_map). Matching the two uniquely
identifies the orchestrator for this instance:
- goosetown-ui: add scoped_parent_session(cur, senders) — pick the candidate whose
spawned delegates overlap most with this wall's senders (ties → most recent),
else None. find_parent_session() now prefers it; main() lets a positive
wall-scoped match override an explicit --session (the launcher may pass a
terminal/other-instance id); the self-heal re-resolves on 0 children OR when the
current parent's delegates don't match the wall's senders (wrong instance), using
only the scoped lookup — so it can adopt this instance's orchestrator and never
another's.
- dashboard: resolve_session() prefers a delegate-bearing user session that
references this wall (WALL_ID, already sanitized to [A-Za-z0-9_-]) before the
generic most-recent query. Best-effort hint; goosetown-ui is authoritative.
Verified with a synthetic two-instance sessions.db: wall-A senders resolve to
orchestrator A and wall-B senders to orchestrator B even though B is more recently
updated; a wall with no delegate senders resolves to None (never a cross-instance
guess); and bash resolve_session honors WALL_ID over a conflicting AGENT_SESSION_ID.
Single-instance behavior and tests/test_dashboard.sh (4/4) unchanged.
Known limitation: if two concurrent instances spawn delegates with identical gtwall
IDs, the most-overlap-then-most-recent tiebreak may still pick the wrong one.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent b5ddb5f commit d1f62b0
2 files changed
Lines changed: 159 additions & 27 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
34 | 52 | | |
35 | 53 | | |
36 | 54 | | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
50 | 105 | | |
51 | 106 | | |
52 | 107 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
97 | | - | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
98 | 115 | | |
99 | 116 | | |
100 | 117 | | |
101 | 118 | | |
102 | 119 | | |
103 | 120 | | |
104 | 121 | | |
105 | | - | |
| 122 | + | |
106 | 123 | | |
107 | | - | |
108 | | - | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
109 | 155 | | |
110 | 156 | | |
111 | 157 | | |
| |||
362 | 408 | | |
363 | 409 | | |
364 | 410 | | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
365 | 436 | | |
366 | 437 | | |
367 | 438 | | |
| |||
577 | 648 | | |
578 | 649 | | |
579 | 650 | | |
580 | | - | |
581 | | - | |
582 | | - | |
583 | | - | |
584 | | - | |
585 | | - | |
586 | | - | |
587 | | - | |
588 | | - | |
589 | | - | |
590 | 651 | | |
591 | 652 | | |
592 | 653 | | |
| |||
595 | 656 | | |
596 | 657 | | |
597 | 658 | | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
598 | 675 | | |
599 | 676 | | |
600 | 677 | | |
| |||
0 commit comments