Repository navigation
fix(panel-terminal): keep a re-keyed spawn's in-flight flag in step with its owner (#1384) - #1388
Merged
Merged
Conversation
…ith its owner (#1384) A shell closed while its spawn was pending and then re-keyed left the new owner id in panelSpawnsInFlight for good: the re-key moved the flag but could not reach the unregistered state, so the settle cleared the old id. The in-flight table now maps each owner to its spawn's state, and the re-key moves that owner along with the flag.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1384. The Shell button could stop opening a panel shell for a session until the window reloaded. This happened when the shell was closed during start-up and the owner session was re-keyed (for example a fork re-key through
rekeySessionTab) beforeopenTerminalsettled.Root cause
rekeyPanelTerminalStatemoved the owner id inpanelSpawnsInFlightto the new id unconditionally. It updatedstate.ownerSessionIdonly while the state was still inpanelTerminals, and the close had already removed it. ThefinallyinopenPanelTerminalthen deletedstate.ownerSessionId, which was still the old id, so the new id stayed in flight forever. After that,openPanelTerminalreturned early and each Shell click only flippedpanelReopenAfterSpawn.Fix
panelSpawnsInFlightis now aMapfrom owner id to the state of its pending spawn. When a re-key moves the in-flight entry, it also sets that state'sownerSessionIdto the new id, whether or not the state is still registered. Thefinallytherefore clears the id the flag now sits under. These spawn-race branches are unchanged and keep using the current owner id:ok;ok:false;Tests
New in
test/panel-terminal.test.js(one test for each settle outcome): open, then close while the spawn is pending, then re-keyownertonew, then resolve or rejectopenTerminal. The test checks thatpanelSpawnsInFlightis empty and that a Shell click fornewspawns a shell.RED at 62134ed (base, before the fix),
node --test --test-concurrency=1 --test-name-pattern=1384 test/panel-terminal.test.jsunder Node 22:Mutation check: with the fix applied but the
spawning.ownerSessionId = newIdline removed, both tests fail on the same assertion. With the line back, both pass.test/bg-rekey-renderer-639.test.jsseeds the in-flight table directly. It now uses.set('old', shell639)instead of.add('old'), because the table is a Map.GREEN under Node 22, one file at a time:
test/panel-terminal.test.js: 51/51test/build-projects-panel-shell.test.js: 7/7test/panel-terminal-target.test.js: 6/6test/bg-rekey-renderer-639.test.js: 11/11test/session-rekey-renderer.test.js: 27/27test/send-to-background-renderer.test.js: 39/39Other checks:
scripts/check-docs.js --validateandscripts/check-doc-refs.js: exit 0, 0 failures.git diff --check: clean.Docs
.ai/contexts/panel-terminal.md"Spawn races": the known-limitation paragraph replaced by the fixed behaviour. No user docs: the panel shell has no user doc covering this race.CHANGELOG.md: one entry under Unreleased / Fixed.Not verified
task checkand the whole test suite were not run, only the files listed above.docsjob will need thepanel-terminal.mdbody change from the merge of main before it can pass.