Repository navigation
fix(terminal): split the input tiers so completion still types (#7657) - #12655
Conversation
UX Review (Fable 5) — ✅ PASSUX-level review of UX-Verdict: PASS Manually accept a completion in a live Bash session whose profile assigns [UX-REVIEWED] 89b6d5a |
Design Review (Fable 5) — ✅ PASSDesign-level review of Design-Verdict: PASS Verify once in a live Bash session whose profile assigns [DESIGN-REVIEWED] 89b6d5a |
GPT 5.6 Review — ✅ no blocking findingsGPT 5.6 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Opus 4.8 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
First Principles Review (Fable 5) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS
Not justified as shipped
What this change shipsInventory (3 items) — 2 justifiedIntent: FIX — make accepting an inline path completion type into a terminal whose login profile replaced
[FIRST-PRINCIPLES-REVIEWED] 89b6d5a |
479415f to
f01e568
Compare
The `ready` frame gated two capabilities whose safety needs differ. It rides an inherited PROMPT_COMMAND hook, so a login profile that ASSIGNS that variable replaces the hook and the frame never arrives -- which took inline path completion down for the life of the session, while the same characters typed by hand still reached the shell through `term.onData`. Typing now resolves through a TYPING tier (`getTerminalInputWs`): the session's open socket, the one hand-typed keystrokes already use. Newline-terminated dispatch keeps using the ready-gated EXECUTION tier, because a line released into a profile still blocked in `read` is consumed by that `read` -- executed never, reported sent. The raw sender additionally refuses any carriage return or newline, so the tier that may run before `ready` cannot submit a line at all. Interactive input only. Automated dispatch still fails in a clobbered session, so the issue remains the record of that remaining half. Refs #7657
GPT 5.6 Review —
|
f01e568 to
89b6d5a
Compare
GPT 5.6 Review —
|
The count is right. It is not applied in this revision because the only way to apply it is a new head, and a new head re-rolls the five non-deterministic whole-design lanes over a board that is currently 82 green. This pull request has already paid that cost once: the previous head lost seven unrelated lanes to No follow-up issue is filed for it, per the repository owner's standing instruction on this pull request. Clears when a later revision of this pull request drops the |
bolichen97
left a comment
There was a problem hiding this comment.
Reviewed the full diff. Pure fix: sendRawToTerminalSession moves to the new input tier (terminalRegistry.ts:247-252) and refuses /[\r\n]/, while the execution tier is untouched, so completion can type before shell_ready without gaining the ability to submit a line. No widening beyond what term.onData already allowed pre-ready. Both new tests go red on revert. All 90 check-runs green.
…otdev#7657) (kirodotdev#12655) The `ready` frame gated two capabilities whose safety needs differ. It rides an inherited PROMPT_COMMAND hook, so a login profile that ASSIGNS that variable replaces the hook and the frame never arrives -- which took inline path completion down for the life of the session, while the same characters typed by hand still reached the shell through `term.onData`. Typing now resolves through a TYPING tier (`getTerminalInputWs`): the session's open socket, the one hand-typed keystrokes already use. Newline-terminated dispatch keeps using the ready-gated EXECUTION tier, because a line released into a profile still blocked in `read` is consumed by that `read` -- executed never, reported sent. The raw sender additionally refuses any carriage return or newline, so the tier that may run before `ready` cannot submit a line at all. Interactive input only. Automated dispatch still fails in a clobbered session, so the issue remains the record of that remaining half. Refs kirodotdev#7657
…otdev#7657) (kirodotdev#12655) The `ready` frame gated two capabilities whose safety needs differ. It rides an inherited PROMPT_COMMAND hook, so a login profile that ASSIGNS that variable replaces the hook and the frame never arrives -- which took inline path completion down for the life of the session, while the same characters typed by hand still reached the shell through `term.onData`. Typing now resolves through a TYPING tier (`getTerminalInputWs`): the session's open socket, the one hand-typed keystrokes already use. Newline-terminated dispatch keeps using the ready-gated EXECUTION tier, because a line released into a profile still blocked in `read` is consumed by that `read` -- executed never, reported sent. The raw sender additionally refuses any carriage return or newline, so the tier that may run before `ready` cannot submit a line at all. Interactive input only. Automated dispatch still fails in a clobbered session, so the issue remains the record of that remaining half. Refs kirodotdev#7657
What is the problem?
A Bash terminal whose login profile assigns
PROMPT_COMMANDnever receives thegateway's
readyframe, and inline path completion is dead for the life of thatsession: the menu opens, lists real directory entries, and then types nothing at
all when a row is accepted.
The readiness marker rides an inherited
PROMPT_COMMAND, because Bash reads an--init-fileonly for a NON-login shell (#5885 is what happens when the terminalis not a login shell, and #7641 restored
-l). The injected hook survives aprofile that APPENDS to the variable, including the Bash 5.1 array form, but a
profile that assigns it outright
PROMPT_COMMAND='history -a'replaces the hook. The marker never fires,
shell_readystays false, and thefrontend's
registerTerminalWsnever runs.The frontend turns that one frame into that one registration, and
getTerminalWsthen served both ofterminalRegistry's senders:sendToTerminalSession\n, released on the user's behalfsendRawToTerminalSessionOnly the first needs it. The second is the same class of input as a keystroke,
and a keystroke never consulted the registry at all:
term.onDatawritesstraight to the connection's socket. So in an affected session a user could type
/locby hand and could not accept/local/from the menu one keypress later.Why this issue matters to the user
The failure is silent, permanent per session, and self-contradicting. The
completion menu still opens and still lists the right names, because nothing
about reading the filesystem depends on readiness -- only the insertion does. A
menu that answers correctly and then does nothing reads as a broken feature
rather than as a blocked one, and there is no message and no workaround short of
editing the profile.
This is not an exotic configuration. The common
~/.bash_profilethat sources~/.bashrcpulls in whatever prompt tooling lives there, and several of thoseassign
PROMPT_COMMANDrather than appending to it.How our fix solves it
Symptom -- accepting a completion types nothing, for the whole session.
Mechanism -- the insertion goes through
sendRawToTerminalSession, whichcalled
getTerminalWs, which reads the registry, which is populated only by thereadyframe.Root cause -- one frame gated two capabilities whose safety requirements are
not the same. The barrier exists for exactly one reason, recorded on
_bash_ready_envand re-derived on #7641: releasing a queued command into aprofile still blocked in
readhands the command to thatread, so it isexecuted never and reported sent. That argument is about submitting a line. It
has nothing to say about typing characters, which the client already does without
a barrier on every keypress.
So the fix splits the tiers rather than weakening the barrier:
getTerminalWs, unchanged.sendToTerminalSessionandonTerminalReadykeep waiting forready, and a clobbered session keepsfailing closed.
getTerminalInputWs: the session's open socket, the oneterm.onDataalready uses.sendRawToTerminalSessionuses this, so completiontypes in a clobbered session exactly as hand-typing does.
sendRawToTerminalSessionadditionally refuses any payload containing a carriagereturn or newline. That makes the tier which may run before
readystructurallyincapable of submitting a line, so opening it cannot reach the loss the barrier
protects against. Callers already refuse a filesystem name holding either
character (
isSafeNameinterminalCompletion, plus the server withholding suchentries), so this adds no filtering to a real path -- it is the tier's own
invariant, and a future caller that loses its own check fails closed here.
No inference and no new signal is involved. Nothing reads the terminal's line
discipline, nothing releases on a timeout, and no PTY output other than the
randomized marker is ever treated as readiness -- the three approaches #7641
measured and reviewed out. The user's command text is neither executed nor
rewritten anywhere in this change.
This is direction 1 of the issue's own "promising directions", suggested by
Design Review on #7641 and named as compatible by the invariant #8226 pinned:
"directions 1 and 3 both keep queued injection fail-closed and change only
interactive typing, so both survive this invariant." That test is untouched and
still passes.
Verified across the whole matrix, so the change is behaviour-preserving
wherever the bug is not present:
readyarisesshell_readyThe same holds across the
PROMPT_COMMANDforms already covered by tests(exported hook, appended scalar, appended Bash 5.1 array, inherited and restored,
preserved, blank-inherited) and across login mode, since POSIX spawn is
-linevery case after #7641. Profile stdout reaching the PTY is still not readiness:
the marker matcher compares against the session's randomized marker only.
Scope, and why the issue stays open. This PR restores interactive
input only. Automated "Run in terminal" dispatch still fails in a clobbered
session, so step 3 of the issue's own repro still reproduces: the gateway sends
no
readyframe and the button still reports failure after its timeout. #7657therefore stays open as the authoritative record of that remaining half, and no
follow-up issue is filed for it.
Bash offers no inherited hook that runs after the profile chain and is out of a
profile's reach --
BASH_ENVis non-interactive only,ENVis POSIX-mode only,INPUTRCcannot run commands, andPS1is assigned by prompt tooling as often asPROMPT_COMMANDis -- and every alternative signal measured on #7641 has a falsepositive that corrupts or swallows the queued command. #10859 already made that
failure non-destructive by rolling back the dock tab it minted. So this PR
recovers the half that needs no barrier and leaves the half that does exactly as
reviewed.
What tests we did
Four tests added to
website/src/test/TerminalRegistryCoverage.test.tsx, thefile that owns
terminalRegistry. They drive the real module through itsWebSocket double; the unready state is produced by
ensureTerminalConnectionplus an opened socket and no
readyframe.getTerminalWsis null first, so the session is genuinely in the clobberedstate and not merely ready.
invariant:
sendToTerminalSessionfalse, no ready waiter fired, nothingwritten.
return, and a bare newline, on a ready session, with nothing written.
Evidence, running only that file:
Each mutation reddens only the test that owns it, and the head file was restored
byte-for-byte after each probe. Type check (
tsc -p tsconfig.app.json) andlint on both changed files are clean.
terminalRegistryis not in the per-filecoverage baseline, and every branch of the new function is exercised: the
connection socket, the registry fallback (through the existing direct-registration
test), and both null returns.
Any other suggestions on the work
readyframe carries two more things that have no safety role:shellandfence_shells, both known at spawn time. A clobbered session loses those too.It costs nothing today because the only reader sits inside the
onTerminalReadycallback, but if the execution tier ever gains a fallback, those two facts
should ride their own frame rather than the barrier.
TerminalCompletion's accept path ignores the boolean fromsendRawToTerminalSession. Unreachable from that caller now, since the refusalis a superset of
isSafeName, but a visible notice there would turn any futuresilent insertion failure into a reported one.
the hook) stays open and is not superseded by this change. It would need to run
something in the shell to observe the mirror, which is the barrier it is trying
to cross; it is left recorded on the issue rather than attempted here.
Pattern harvest
Rule candidate: review-prompt
Pattern: one readiness flag or registry gating two callers whose safety
requirements differ.
getTerminalWswas introduced for a reason that appliesonly to submitting a whole line; a second caller that merely types characters was
attached to the same accessor later, so the barrier began removing a capability it
was never protecting. The question that catches the class on review: for every
reader of a gate, does the gate's stated justification apply to THAT reader?
No syntactic rule fits it, because the defect is a mismatch between a gate's prose
justification and its set of readers, and both sides are ordinary correct code.
The mechanical half is the narrower invariant this PR adds and tests: the
non-submitting sender refuses the bytes that would submit.
Refs #7657 -- deliberately not
Closes: the automated-dispatch half of thatissue is untouched and still reproduces, so the issue remains the record of it.