Repository navigation
fix(cli): preserve shell profiles when completion install fails - #117987
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 2, 2026, 9:34 AM ET / 13:34 UTC. ClawSweeper reviewWhat this changesThe branch makes shell-completion installation publish profile updates atomically, preserving existing profile bytes, permissions, and symlink targets if a write fails. Merge readinessThis PR is still necessary: current Priority: P1 Review scores
Verification
How this fits togetherThe completion CLI reads a cached completion script and adds a managed source block to a shell startup profile. The new shared output publisher stages the updated profile beside its destination, then atomically replaces the resolved file so failures do not damage unrelated user shell configuration. flowchart LR
A[Completion command] --> B[Shell startup profile]
B --> C[Completion block update]
C --> D[Resolve profile target]
D --> E[Sibling temporary file]
E --> F[Atomic durable replacement]
F --> G[Shell profile or symlink target]
H[CLI media outputs] --> E
Before merge
Agent review detailsSecurityNone. PR surfaceSource +51, Tests +105, Docs +2. Total +158 across 8 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the shared atomic publisher after the current-base merge result retains the built-CLI cases for normal profiles, failed writes, valid symlinks, and dangling relative symlinks; keep shell-profile semantics centralized in the shared publisher rather than adding another completion-specific write path. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: current main writes the final completion profile directly, while the supplied deterministic built-CLI case shows a write failure can leave the prior profile truncated. I did not execute the reproduction because this review is read-only. Is this the best way to solve the issue? Yes. Reusing the existing sibling-temp publisher is the narrowest maintainable repair because it fixes the destructive write at its owner boundary while preserving established mode and cleanup behavior for other CLI outputs. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 3748fcfd2c99. LabelsLabel changes:
Label justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
|
Land-ready proof for exact head Root cause: completion installation read the complete shell profile, built its replacement text, then called Provenance (clear): current blame traces the direct final-profile write to Canonical repair: completion profiles now publish through a lightweight shared CLI output owner with durable sibling-temp/parent sync and existing-mode preservation. Completion-specific resolution keeps shell symlink-before- Proof:
Scope: 8 files; production |
|
Merged via squash.
|
* origin/main: fix(ui): label Gateway connection settings for accessibility (#118000) ci(qa): extend profile evidence timeout (#117999) fix(googlechat): report a blocked account instead of a webhook path that was never bound (#117986) fix(line): preserve semantic indentation in fenced code (#117996) fix(plugins): contain rejected synchronous hook results (#117988) fix(cli): preserve shell profiles when completion install fails (#117987) fix(tui): preserve legitimate consecutive backspaces (#117989) fix: preserve queued messages during /compact (#117840) fix(talk): enforce relay lifecycle bounds fix(talk): enforce relay terminal precedence test(talk): cover relay tool-call retention overflow fix(talk): bound relay tool-call lifecycle state
…claw#117987) * fix(cli): publish completion profiles atomically Closes openclaw#117980 * fix(ci): restore environment variable budget * fix(cli): preserve dangling completion profile symlinks * fix(cli): narrow completion readlink failures
* origin/main: fix(ui): label Gateway connection settings for accessibility (openclaw#118000) ci(qa): extend profile evidence timeout (openclaw#117999) fix(googlechat): report a blocked account instead of a webhook path that was never bound (openclaw#117986) fix(line): preserve semantic indentation in fenced code (openclaw#117996) fix(plugins): contain rejected synchronous hook results (openclaw#117988) fix(cli): preserve shell profiles when completion install fails (openclaw#117987) fix(tui): preserve legitimate consecutive backspaces (openclaw#117989) fix: preserve queued messages during /compact (openclaw#117840) fix(talk): enforce relay lifecycle bounds fix(talk): enforce relay terminal precedence test(talk): cover relay tool-call retention overflow fix(talk): bound relay tool-call lifecycle state
Closes #117980
What Problem This Solves
Fixes an issue where users installing cached shell completions could lose unrelated zsh, Bash, Fish, or PowerShell profile contents when the final profile write failed. The command exited nonzero after the profile had already been truncated or partially replaced.
Why This Change Was Made
Completion profiles now publish through the same lightweight sibling-temp owner used by CLI media, with durable temp/parent sync, existing-mode preservation, and a profile-specific temp prefix. Existing profile symlinks are resolved to their referent, while missing profiles preserve shell symlink-before-
..traversal by creating and canonicalizing the lexical parent before publication.The atomic publisher moved into
output-file.runtime.tsso completion startup does not import the media store and media callers do not retain a parallel mode/cleanup policy.This PR also repairs an inherited red-main env-var ratchet failure from #117205: a CUA driver constant contained the reserved
OPENCLAW_substring even though it was not an environment variable. The behavior-neutral rename restores the existing 515-name budget; the budget file is unchanged.User Impact
Failed completion installation leaves an existing shell profile unchanged. Successful installation preserves unrelated profile lines, the prior file mode, and dotfile-manager symlinks. Missing profiles still use the shell-owned startup location and are created without an empty intermediate file.
Evidence
openclaw completion --shell zsh --install --yesexited 1 and truncated mode-0644export IMPORTANT=keepto zero bytes.tbx_01kz17806fyvy5ra9125fcjmpf, run https://github.com/openclaw/openclaw/actions/runs/30747948101:check:changedpassed across core and extension production/test typechecks, targeted lint, dependency/plugin boundaries, database/media guards, env ratchet515/515, and zero runtime import cycles.0640; forced failure exited 1 with prior contents/mode and no temp; symlinked.zshrcremained a symlink while its target received the completion block.5436a1eee9927ddf7a5a55100d0a31bd2bd75c4don Blacksmith Testboxtbx_01kz19f6t06t982hwzs9vh10zz, run https://github.com/openclaw/openclaw/actions/runs/30749316372: remoteHEADand clean tree verified before the full build passed, including all 149 public Plugin SDK subpaths and the production Control UI build.managed/zshrcwhile its target was created and populated.0851909e5995a705b0b20bdcbd57da69cb941792adds only the hosted-lintunknowncatch narrowing; targeted type-aware lint passed and its autoreview was clean at 0.99.GREENfrom the repository watcher, with no failed or pending PR check.git diff --checkpassed.Production delta: +95/-44 (net +51). Tests: +114/-9. Docs: +2/-0. The production growth is the lightweight shared publisher plus durable profile publication that preserves shell-specific parent traversal, valid symlinks, and dangling relative symlinks; the prior media-local publisher was removed rather than duplicated. No config, protocol, storage, migration, dependency, provider, Gateway, or completion-script format change.
AI-assisted: yes. No agent transcript attached by user preference.