Repository navigation
task-work / task-reviewer / task-recreate-worker sometimes leave focus on the new tab: the snap-back to the caller's tab races zellij's new-tab: re-check focus and retry go-to-tab (#311) - #312
Conversation
…s on the new tab: the snap-back to the caller's tab races zellij's new-tab: re-check focus and retry go-to-tab (#311) zellij handles `new-tab` asynchronously and always focuses the new tab, so the snap-back `go-to-tab` in `aw_launch_tab` could land before the tab had finished opening. The new `aw_snap_back_to_tab` checks the active tab after the `go-to-tab` and re-issues it every 0.25s, up to 7 checks (~1.5s). A retry or a final failure writes one `tab-focus:` line to radio's log. The `--focus` path is unchanged and a launch never fails over focus. The zellij stub gains `STUB_ZELLIJ_TABS_JSON_QUEUE` so tests can move focus between `list-tabs` calls. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Spec complianceChecked against #311; all deliverables are present.
Code-review findingsNo blockers. I traced the loop: gotos tops out at Nit (non-blocking, worth a sentence rather than code): the loop returns as soon as the first check sees the caller active. If the very first Verdictclean-with-nits. The change is small and matches the spec. PM can merge, and the nit above doesn't need to block. |
PM: one round of small items before mergeCI is green and the reviewer is clean-with-nits. Three things, all in this PR:
Please mutation-check 2 and 3 yourself: revert each mutation above and watch the test go red. Then send |
…s on the new tab: the snap-back to the caller's tab races zellij's new-tab: test the warning and the quiet stop, note the first-check limit (#311) Review round on PR #312: - `aw_snap_back_to_tab`'s comment states the known limit: a first `list-tabs` answered before zellij processed `new-tab` reports the caller active, so a later focus steal goes unseen; the fix would be two consecutive observations. - The never-comes-back test asserts the stderr warning; the recovered and clean tests assert it is absent. - New test: `list-tabs` turning unusable mid-loop stops with no log line and no warning. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary
Launching a worker sometimes left you on the new worker's tab, because zellij opens tabs asynchronously and the snap-back
go-to-tabcould land before the new tab finished opening. The launcher now re-checks which tab is active for up to about 1.5s and sendsgo-to-tabagain until yours is, and logs atab-focus:line to radio's log whenever it had to retry or gave up.Closes #311
Changes
lib/zellij-tab.sh: newaw_snap_back_to_tab, called fromaw_launch_tabonly on the stay-on-caller path. After thego-to-tabit readslist-tabs --json.active; while that is not the caller's position it sleeps 0.25s and issuesgo-to-tabagain, up to 7 checks. The common case is onelist-tabswith no sleep. An unusablelist-tabsanswer ends the loop quietly. It never fails the launch. On a retry it logstab-focus: snap-back needed N go-to-tab(s) slug=… caller_position=…; on giving up it logstab-focus: snap-back failed after N go-to-tab(s) … active_position=…plus one stderr line.AW_TAB_FOCUS_CHECKS/AW_TAB_FOCUS_INTERVALare internal knobs for tests, not flags.tests/helpers/stubs/zellij:STUB_ZELLIJ_TABS_JSON_QUEUE, a file oflist-tabsanswers consumed one per call, so a test can move focus between calls.tests/zellij_tab_stay_focused.bats: five new tests for the race (2 go-to-tabs + 1 log line), caller active at once (1 go-to-tab, 2 list-tabs, no log),--focus(no go-to-tab), a caller that never comes back (bounded, logged, launch succeeds), and the default bound in wall time. The file now uses a private radio home so the log assertions don't see other tests' lines..claude/gh-workflow.mdand the seven steering templates. CHANGELOG entry; notask-initre-run needed.Verification
./run_tests.sh: 1597 ok, 0 failures. Shellcheck clean,tools/check-drift.shclean. After the full run I changed the default from 6 to 7 checks (6 gave only 1.25s of sleep) and fixed a flattened line continuation, then re-ran the focus suite: 20/20.🤖 Generated with Claude Code