Repository navigation
fix(terminal): restore PROMPT_COMMAND when a system profile appends to it - #37699
bolichen97 wants to merge 1 commit into
Conversation
|
@iamwhatever could you review this one? Our push means our own approval does not count here. It fixes the last ubuntu-26.04 fork-runner red from #37647 (Backend Tests, bash readiness hook). The codex sandbox part already landed in #37677 and the Playwright part in #37653. Root cause and the 26.04 container repro are in the description. AI-assisted, sent by Bolin Review bot |
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks. Rewriting only element zero keeps every element a profile appends, so the old [DESIGN-REVIEWED] aea85eb Description read[DESCRIPTION-READ] 8e76c3c5408daf79cf2638bc108c098e7d807756eab6a74a0a221b33a4d4b0f6 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 to check. The fix targets the cause: the withdrawal test assumed no profile adds a later What this change shipsInventory (5 items) — 5 justifiedIntent: A terminal on a distro whose system profile appends to
[FIRST-PRINCIPLES-REVIEWED] aea85eb Description read[DESCRIPTION-READ] 240343be96ab7b064d3157d83313ae2640d660dc384ce3d630151151eb901bd0 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: |
…o it On the ubuntu-26.04 fork runner two Backend Tests failed. The bash readiness hook withdrew itself only while PROMPT_COMMAND had no element one. systemd's /etc/profile.d OSC 3008 snippet, which every login Bash on 26.04 runs, appends one, so the hook stayed in element zero and an inherited PROMPT_COMMAND was never restored. The withdrawal now rewrites element zero alone when later elements exist. The profile-append PTY test probes the last element, since the system profile can add its own first.
e99100c to
aea85eb
Compare
Code change approver recommendation: ApproveWhy: the decider estimates a 7% chance that this change introduces a defect, within the 12% limit for approving on its own, and every check passes. Small, correct fix to the Bash readiness hook. When element zero of PROMPT_COMMAND still equals the exported hook, the hook now restores the inherited command into element zero even if a profile (or systemd's OSC 3008 snippet) added later elements, and sets element zero to empty when there is no inherited command. When the hook is the only element, it still unsets the variable as before. A plain assignment to an array name writes only element zero, so appended elements are kept, and the Bash 3.2-safe syntax is preserved. Tests: the inherited-command PTY test gains an array-append case that fails on main, the append test now reads the last element, and the unit test checking the hook's text is updated. The spec and docstring match the code. CI is 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 #37697 makes the same fix, and a maintainer has to keep one of the two. What the review checked on aea85eb:
Done well: the fix removes one guard and adds one Decision needed: #37697 changes the same Optional:
|
|
Closing in favour of #37697, which makes the same fix in the same four files, was opened first, and has merged. The ubuntu-26.04 AI-assisted, sent by Bolin Review bot |
Pull request was closed
Problem / Motivation
Goal: Fork PRs on the ubuntu-26.04 runner pass Backend Tests again, and a Kiro Crew terminal on a systemd-snippet distro gets its inherited
PROMPT_COMMANDback.On the
kirocrew-linux-4-corefork runner (now ubuntu-26.04, bash 5.3.9), Backend Tests (3.12, 7) fails on every fork PR (example: run 43724230771, job 132874134510, on #37626):test_ws_bash_keeps_a_profile_appended_prompt_command:the profile's own PROMPT_COMMAND element did not survive the readiness hook's self-withdrawaltest_ws_bash_restores_an_inherited_prompt_command:the gateway's exported PROMPT_COMMAND was not restored after the readiness hook withdrewWhy it matters
Every fork PR is red on a lane it did not touch. It is also a real product bug on any distribution that ships systemd's OSC 3008 profile snippet (Ubuntu 26.04 among them): the readiness hook never withdraws from
PROMPT_COMMAND, and an operator's exportedPROMPT_COMMAND(for examplehistory -a) is never restored as element zero.Not a goal
What changed (motivation → approach → change)
Symptom → cause: on 26.04,
/etc/profile.d/80-systemd-osc-context.shruns in every login Bash and appends__systemd_osc_context_precmdlinetoPROMPT_COMMAND. The readiness hook insrc/kiro_crew/dashboard/handlers/terminal.pyonly withdrew when there was no element one. So it stayed in element zero, and the inherited command was never put back.Change: when later elements exist, the hook now rewrites element zero alone, to the inherited command or to an empty element (the same placeholder systemd uses). With no later element it unsets the variable, as before. Every element a profile added is kept. The profile-append PTY test now reads the last element, because the system profile may add its own element first. The spec paragraph on terminal input readiness in
docs/system-specs/modules/learn-cron-dashboard.mdis updated to match.Backwards compatibility
Compatible: the hook only changes what it does with its own element zero. Every other element is kept, and the hook-alone case still unsets the variable.
Removes nothing: no key, path or check is removed; the hook text it leaves behind was inert.
Tests
test_ws_bash_restores_an_inherited_prompt_commandis parametrized with a profile that appends an array element. That case is red on main on any Bash host, and green here.test_ws_bash_keeps_a_profile_appended_prompt_commandchecks the last element instead of index one.Proof: PROVEN test/test_terminal_handler_pty_integration.py::TestTerminalWsIntegration::test_ws_bash_restores_an_inherited_prompt_command[PROMPT_COMMAND+=(true)\n], test/test_terminal_handler_session_state.py::TestBashShellReadiness::test_ready_hook_is_a_single_shot_self_removing_prompt_command (head aea85eb)
Determinism: the changed test files passed 5 times in a row with
-n 4, and once serially in a shuffled order.Manual verification
In an
ubuntu:26.04container (bash 5.3.9) with systemd's80-systemd-osc-context.shlinked into/etc/profile.d, the terminal PTY tests on origin/main fail the same two ways CI does (2 failed, 2 passed). On this branch all 5 pass. Non-fork PRs run on codebuild, so this PR's own CI does not run on the 26.04 runner; the next fork PR after merge does.Related Issues
Fixes #37647
Sibling sweep
Swept: git grep -n "PROMPT_COMMAND" -- src/
Sibling: src/kiro_crew/acp/client_turn.py -- not affected -- ACP prompt-command allowlist, not the shell variable
Pattern harvest
Not generalizable: the hook assumed no system profile adds a
PROMPT_COMMANDelement; that is specific to this one shell hook.Checklist