Repository navigation
fix(terminal): withdraw the readiness hook from a PROMPT_COMMAND array - #37697
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the fix removes only the hook's own element zero, keeps every element a profile added, and still parses on Bash 3.2. [DESIGN-REVIEWED] d3d8a29 Description read[DESCRIPTION-READ] 7b679fd32ac01c85a196915ab3170ad5cb877202e4fe693aad8623371c8d711e That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. This is a fix with a linked issue (#37693) and two CI tests that fail on the ubuntu-26.04 runner. It targets the mechanism that caused them: the withdrawal check that refused to act on any array. What this change shipsInventory (4 items) — 4 justifiedIntent: on systemd hosts, the terminal readiness hook should remove itself after the first prompt and give back the operator's inherited
The old pin's stated reason was "unsetting there would take the user's own element with it". The change keeps that reason intact, so this is not a reversed decision. A grep for [FIRST-PRINCIPLES-REVIEWED] d3d8a29 Description read[DESCRIPTION-READ] c7e7f92b05353785f28fe6129df8681b3e8106c06d78dc27da917dc8660d3807 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 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: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 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: |
systemd's /etc/profile.d OSC-context script appends to PROMPT_COMMAND as an array on every login Bash. The readiness hook then saw a second element and skipped its withdrawal, so its text stayed in element zero for the whole session and an inherited PROMPT_COMMAND was never restored. The hook now drops only element zero: replaced by the inherited command when there is one, else removed with the rest shifted down. Closes #37693
1a0706b to
d3d8a29
Compare
|
#37699 fixes the same red (the ubuntu-26.04 runner's systemd |
Code change approver recommendation: ApproveWhy: the decider estimates an 8% chance that this change introduces a defect, within the 12% limit for approving on its own, and every check passes. The PR changes the one-shot Bash readiness hook so it also withdraws itself when a profile has turned PROMPT_COMMAND into an array, which systemd's profile.d script does on every login shell. While element zero is still the exported hook: with an inherited command, only element zero is overwritten with it; with none and a single element, the variable is unset as before; otherwise element zero is dropped and the rest move down. Bash runs prompt-command elements from a copy taken before running any of them, so every element still runs on the first prompt. systemd's empty first element is kept, which gives exactly the layout it would build with no hook. The syntax parses on Bash 3.2, and the macOS suites passed. The scalar-append and assignment cases behave as on main. The integration test now builds a two-element array and asserts the hook text is gone; that check fails on main on any runner. A unit test pins the new branch. The spec and docstring were updated to match. All CI checks are green. An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit |
|
The review found no code defect on this head. It cannot be approved yet because #37699 makes the same fix, and a maintainer has to keep one of the two. Decision needed: duplicate of #37699 ( Optional:
|
bolichen97
left a comment
There was a problem hiding this comment.
Approving this head and keeping this one over #37699, which makes the same fix (this one was opened first). I'm closing #37699 with a pointer here.
- The hook now withdraws element zero only: it is replaced by the inherited command when there is one, otherwise dropped with the rest of the array shifted down. Profile-appended elements (systemd's
__systemd_osc_context_precmdlineon ubuntu-26.04) survive in every shape. ${PROMPT_COMMAND[1]+x}and${PROMPT_COMMAND[@]:1}both parse on macOS's Bash 3.2.- Ran the readiness and
prompt_commandtests intest_terminal_handler_session_state.pyandtest_terminal_handler_pty_integration.pylocally: 11 passed. CI on this head: 87 passed, 0 failed, none pending.
Once this merges I'll close #37647 by hand: its three parts are #37653 (Playwright), #37677 (Codex sandbox probe) and this PR.
AI-assisted, sent by Bolin Review bot
Problem / Motivation
Goal: On systemd hosts, the dashboard terminal's one-shot readiness hook removes itself from
PROMPT_COMMANDafter the first prompt, as it already does elsewhere.systemd's
/etc/profile.d/80-systemd-osc-context.shappends__systemd_osc_context_precmdlinetoPROMPT_COMMANDas an array on every login Bash (Ubuntu 26.04 ships it). The hook then sees a second element and skips its withdrawal. Its text stays inPROMPT_COMMAND[0]for the whole session, and an inheritedPROMPT_COMMANDis never restored as its own value. Theubuntu-26.04CI runner shows it:Backend Tests (3.12, 7)failstest_ws_bash_keeps_a_profile_appended_prompt_commandandtest_ws_bash_restores_an_inherited_prompt_command, which blocks PRs that land on that runner (#37626, #37627).Why it matters
Every Bash tab on a systemd host carries Kiro Crew's hook and its
KIROCREW_TERMINAL_READY_*names forever, and the operator's own exportedPROMPT_COMMANDstays glued behind it. CI on the ubuntu-26.04 image is red for every PR until this lands.Not a goal
PROMPT_COMMAND.PROMPT_COMMAND="$PROMPT_COMMAND; ..."), where the hook still stays by design./etc/profile.d: these tests run the real login chain on purpose.What changed (motivation → approach → change)
Symptom: hook text left in
PROMPT_COMMAND[0]on systemd hosts. Cause: withdrawal requiredPROMPT_COMMAND[1]to be unset, so any array (systemd's, or a profile's+=(...)) kept the hook. Change: while element zero is still the exported hook, it drops only element zero. With an inherited command it puts that command back in element zero; with none and more elements it shifts the rest down, which is the array the profile chain builds with no hook; a lone scalar is still unset. The docstring and the terminal readiness spec paragraph say the same.Backwards compatibility
Compatible: only the hook's own element changes; every profile-added element keeps running in order.
Removes nothing: the only thing taken out of
PROMPT_COMMANDis Kiro Crew's own one-shot hook, which the spec already says must withdraw.Tests
test_ws_bash_keeps_a_profile_appended_prompt_command: profile now appends two elements (:thentrue), the shape systemd makes, so every runner exercises it. Probe reads the LAST element (systemd adds one in front) and also prints the whole array, asserting the hook text is gone.test_ready_hook_is_a_single_shot_self_removing_prompt_command: pins the new array branch.test_ws_bash_restores_an_inherited_prompt_command: unchanged; it is the second red on the ubuntu-26.04 runner and passes with the fix.Proof: PROVEN test/test_terminal_handler_pty_integration.py::TestTerminalWsIntegration::test_ws_bash_keeps_a_profile_appended_prompt_command, test/test_terminal_handler_session_state.py::TestBashShellReadiness::test_ready_hook_is_a_single_shot_self_removing_prompt_command (head d3d8a29)
Determinism: the changed tests passed 3 of 3 repeats; all 513 tests in
test/test_terminal_handler*.pypass.Manual verification
Drove a real Bash 5.2 with the exported hook env for 8 shapes (systemd+user array, user array, none, scalar append; each with and without an inherited
PROMPT_COMMAND) and readdeclare -p PROMPT_COMMANDafter the first prompt. On main the hook stayed in element zero for all 4 array shapes. With this change those 4 end as[0]="sysd" [1]="true",[0]="true",[0]="builtin printf PREV" [1]="sysd" [2]="true"and[0]="builtin printf PREV" [1]="true"; the scalar shapes are unchanged.Related Issues
Closes #37693
Sibling sweep
Swept: git grep -n "PROMPT_COMMAND" -- src
Siblings: none -- the readiness hook in src/kiro_crew/dashboard/handlers/terminal.py is the only code that edits a shell PROMPT_COMMAND; the other hits are the unrelated ACP prompt-command allowlist.
Pattern harvest
Not generalizable: a one-off assumption that an exported scalar stays a scalar through the login profile chain.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)