Skip to content

fix(cosh-ng): [shell] own prompt boundary#1310

Open
samchu-zsl wants to merge 2 commits into
alibaba:mainfrom
samchu-zsl:fix/cosh-ng/shell-prompt-boundary
Open

fix(cosh-ng): [shell] own prompt boundary#1310
samchu-zsl wants to merge 2 commits into
alibaba:mainfrom
samchu-zsl:fix/cosh-ng/shell-prompt-boundary

Conversation

@samchu-zsl

@samchu-zsl samchu-zsl commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Description

Fixes a cosh-shell prompt boundary issue where user or system PROMPT_COMMAND hooks could run before cosh recorded its prompt boundary, causing ghost foreground commands and leaving interactive cards stuck behind shell_busy. The shell marker now records cosh prompt state before running user prompt hooks, and interactive card consumers run before the busy early return. Raw CLI tests were hardened to assert semantic behavior across rich/plain rendering and dev shell environment differences.

Related Issue

closes: #1249

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional change)
  • Performance improvement
  • CI/CD or build changes

Scope

  • cosh (copilot-shell)
  • cosh-ng (cosh-ng)
  • sec-core (agent-sec-core)
  • skill (os-skills)
  • sight (agentsight)
  • tokenless (tokenless)
  • ckpt (ws-ckpt)
  • memory (agent-memory)
  • anolisa (anolisa-cli)
  • skillfs (SkillFS)
  • Multiple / Project-wide

Checklist

  • I have read the Contributing Guide
  • My code follows the project's code style
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the documentation accordingly
  • For cosh: Lint passes, type check passes, and tests pass
  • For cosh-ng: cargo clippy --all-targets -- -D warnings and cargo fmt --check pass
  • For sec-core (Rust): cargo clippy -- -D warnings and cargo fmt --check pass
  • For sec-core (Python): Ruff format and pytest pass
  • For skill: Skill directory structure is valid and shell scripts pass syntax check
  • For sight: cargo clippy -- -D warnings and cargo fmt --check pass
  • For tokenless: cargo clippy -- -D warnings and cargo fmt --check pass
  • For memory (Linux only): cargo clippy --all-targets -- -D warnings, cargo fmt --check, and cargo test pass
  • For anolisa: cargo clippy --all-targets --locked -- -D warnings, cargo fmt --all --check, and cargo test --locked pass
  • For skillfs: cargo fmt --all --check, cargo clippy --workspace --all-targets -- -D warnings, and cargo test --workspace pass
  • Lock files are up to date (package-lock.json / Cargo.lock)

Testing

  • cargo fmt --package cosh-shell -- --check
  • git diff --check -- crates/cosh-shell
  • cargo clippy --package cosh-shell --all-targets -- -D warnings
  • dev: cargo test --package cosh-shell --test raw_cli -- --test-threads=4
    • 301 passed, 0 failed, 1 ignored
  • dev: cargo test --package cosh-shell --test raw_cli host_executed::raw_cli_host_executed_provider_disconnect_marks_recovery_reason -- --exact
    • 1 passed

Note: local cargo test --package cosh-shell --lib is blocked by macOS sandbox restrictions for readonly pipeline tests using ps; dev lib tests passed earlier.

Additional Notes

The fix is scoped to src/cosh-ng/crates/cosh-shell.

@samchu-zsl

Copy link
Copy Markdown
Collaborator Author

Caution

This PR was generated and submitted by AI.
Please review all changes carefully before merging. Pay special attention to logic correctness, edge cases, and potential side effects.

Affected crate: crates/cosh-shell

Cosh-shell now records its prompt boundary before running user PROMPT_COMMAND hooks, and card consumers run before the shell_busy early return. This fixes auth-style card input when prompt hooks leave the runtime thinking the foreground shell is busy.

Known limitation: the dispatcher still has separate busy/non-busy paths for slash handling; this commit keeps the change scoped to interactive card consumers.

Signed-off-by: Shenglong Zhu <samchu.zsl@alibaba-inc.com>
Affected crate: crates/cosh-shell

Raw CLI assertions now focus on semantic behavior instead of exact renderer wording or environment-specific shell output. The tests cover card focus, provider handoff, host-executed shell results, startup prompt ghosts, and dev prompt hook noise.

Known limitation: these are test-only hardening changes; they do not add a dedicated /auth raw_cli scenario.

Signed-off-by: Shenglong Zhu <samchu.zsl@alibaba-inc.com>
@samchu-zsl samchu-zsl force-pushed the fix/cosh-ng/shell-prompt-boundary branch from 88a7cb5 to 59d9274 Compare July 3, 2026 09:50
@samchu-zsl samchu-zsl requested a review from SunnyQjm July 3, 2026 10:20
@samchu-zsl samchu-zsl marked this pull request as ready for review July 3, 2026 10:20
@samchu-zsl samchu-zsl closed this Jul 3, 2026
@samchu-zsl samchu-zsl deleted the fix/cosh-ng/shell-prompt-boundary branch July 3, 2026 12:49
@samchu-zsl samchu-zsl restored the fix/cosh-ng/shell-prompt-boundary branch July 4, 2026 03:15
@samchu-zsl samchu-zsl reopened this Jul 4, 2026
@samchu-zsl samchu-zsl requested a review from kongche-jbw July 4, 2026 04:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[cosh-ng] bug: cosh-shell raw mode busy-loop causes shell freeze when PROMPT_COMMAND is set

1 participant