Repository navigation
feat(terminal): prompt and command marks from shell integration (#614) - #618
Merged
Merged
Conversation
Shell integration reported only the working directory, so a terminal knew a prompt had been drawn but not where a command's output started or how it exited. The bash, zsh and PowerShell hooks now also send OSC 133 A (prompt start), C (command start) and D (exit status), for local shells and for SSH, WSL and container sessions. Each terminal records them as command regions: prompt line, output start, end line, exit code and timing, read through getCommandRegions(sessionId). Regions follow scrollback trimming and are not opened on the alternate screen. Nothing consumes them yet. The hooks never edit the prompt, so B (input start) is not sent; it is recorded when the user's own prompt sends it. bash below 4.4 has no PS0 and sends no C. The POSIX sh fallback and cmd send no marks. fish relies on its own. tmux control mode passes the marks through. After a reattach the list restarts empty, and the first command typed at the restored prompt is not tracked. The hook text lived in five copies in shell_integration.rs and is now built from shared fragments. Comments that travelled inside the SSH bootstrap moved to Rust doc comments, which keeps the payload clear of the 8192-byte cap. Closes #614
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #614
Problem
Shell integration reports only the working directory (OSC 7). A terminal knows a prompt was drawn, but not where a command's output starts or how the command exited. Jumping between prompts, copying the last output, exit-status marks and output-only decoration (#317) all need that.
Change
Shell hooks (
src-tauri/src/shell_integration.rs)A(prompt start),C(command start) andD;<exit>(finished), for local shells and for SSH, WSL and container sessions.DandAride on the existing OSC 7printf, so a prompt is still one write.Ccomes fromPS0in bash,preexec_functionsin zsh, and a wrapper aroundPSConsoleHostReadLinein PowerShell.macro_rules!fragments (pwd_fn!,bash_hooks!,zsh_hooks!,zsh_env!,bash_login_chain!,sh_hooks!).Frontend
src/components/terminal/commandMarks.ts: a tracker that turns the marks into command regions (prompt line, output start, end line, exit code, start and end time). Positions are xterm markers, so they follow scrollback trimming.useTerminal.tsregisters the OSC 133 handler next to the OSC 7 one and exposesgetCommandRegions(sessionId).Deviations from the issue
B(input start). It is the only mark that needs the user's prompt edited, and no planned feature needs it. The tracker recordsBwhen the user's own prompt sends it.PS0, so it sends noC: prompts are tracked, output regions are not.Open questions from the issue
Awas never replayed.CorDfor the same command is ignored.ssh,sudo su): the outer command stays open until the outer shell reports again, which is what is happening.Testing
cargo fmt --checkandcargo clippy --workspace --all-targets -- -D warningsclean.cargo test --lib shell_integration: 33 pass. New tests run real bash and zsh (zsh is skipped when not installed) and compare the mark sequence.tsc --noEmitclean. 9 new tracker tests;src/hookssuites pass (284 tests).Set-StrictMode -Version Latest.Not covered
Cpath; not run.