Skip to content

refactor(ai): run approved commands in existing terminal sessions - #345

Open
shihuili1218 wants to merge 1 commit into
mainfrom
refactor/core-terminal-commands
Open

shihuili1218 wants to merge 1 commit into
mainfrom
refactor/core-terminal-commands

Conversation

@shihuili1218

Copy link
Copy Markdown
Collaborator

Closes #334

Core now runs approved commands in the current SSH shell, local or connector PTY, native SSM, serial, or Telnet session. The terminal still shows the command echo and streams output as it arrives. A command inherits the working directory, environment, and nested shell the user is already in.

run_command, match_file, patch steps, and file capability probes share one executor. It observes the existing transport reader, collects bounded output, and passes the result through the existing redaction and audit path. Approval retries return the original result. Stopping a command targets the original connection instance. A timeout ends collection and lets the remote command continue. Serial and Telnet retain manual completion and cancellation without sending Ctrl+C.

Entry points

  • Desktop GUI keeps the approval card, xterm output flush, alternate-screen check, and bracketed-paste handling. Verified with the macOS Tauri app.
  • Mobile GUI uses the same controls for transports offered by the host. Verified tap-to-approve and live output in Chrome with a narrow viewport and touch emulation.
  • Headless / JetBrains uses the same core executor through the WebSocket dispatcher. Verified the embedded frontend with Chrome and rssh-server.
  • CLI keeps its existing external SSH launch behavior. No new CLI commands.

Verification

  • Real local PTY and loopback OpenSSH sessions retained a shell variable set before approval. The terminal showed the first output while the command was still waiting for input, and the card received the complete result and exit code afterward.
  • Regression coverage includes split UTF-8 and completion markers, 80-column shell redraws, output limits, approval retries, stop and timeout, reconnects, and owner isolation.
  • npm test passed 1,435 tests. npm run build, cargo fmt --all --check, and the Tauri, server, and CLI feature checks passed. cargo test --workspace --all-features passed 1,101 tests with one ignored doctest.
  • tsc --noEmit reports the same 18 diagnostics on this branch and its base.

Copilot AI balanced review requested due to automatic review settings November 18, 2026 06:43

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T06:49:01.440156Z 41602c8 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 41602c8635

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

// Reclaim the whole output budget, even if the echoed input
// itself was larger than the head window. With echo disabled
// this branch never runs and the first output line is retained.
*output = BoundedOutput::default();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve earlier output when stripping a multiline command's echo

When bracketed paste is disabled in an interactive Bash terminal, a multiline command executes line by line, so real output can arrive before the final line containing the echoed sentinel template. Resetting the entire output buffer here discards those earlier results. For example, approving echo FIRST\necho SECOND produces FIRST, then the second command's echo, then SECOND; the new collector returns only SECOND. This silently removes diagnostic data from the result supplied to the AI and audit log. Strip the echoed input without clearing output already produced by earlier lines.

Useful? React with 👍 / 👎.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

将终端命令执行与结果采集下沉到 core,复用现有会话

2 participants