Skip to content

feat(terminal): add prompt-based command block splitting - #223

Merged
shihuili1218 merged 5 commits into
mainfrom
feat/command-block-prompt-splitting
Aug 7, 2026
Merged

shihuili1218 merged 5 commits into
mainfrom
feat/command-block-prompt-splitting

Conversation

@shihuili1218

@shihuili1218 shihuili1218 commented Aug 6, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • add a persisted command-block boundary preference with deterministic Enter mode as the default and Prompt mode as an opt-in heuristic
  • constrain Prompt detection to startup or post-Enter cursor lines, reject the submitted line and prompt-looking output with trailing text, and preserve marker behavior across wrapping, reset, and alternate buffers
  • expose two accessible button choices in command-block settings and document the behavior and limitations

Compatibility

  • Desktop GUI: supported
  • Mobile GUI: supported; choices collapse to one column at 480px and below
  • Headless / JetBrains: supported through the existing get_setting and set_setting adapters
  • CLI: N/A; command blocks are a GUI presentation feature

No schema, new command, or IPC change is required. Existing users keep Enter mode, and unknown persisted values fall back to Enter.

Testing

  • npm test — 50 files, 637 tests passed
  • npm run build
  • cargo fmt --manifest-path src-tauri/Cargo.toml --check
  • cargo test --manifest-path src-tauri/Cargo.toml — 702 tests passed
  • cargo check --manifest-path src-tauri/Cargo.toml --features server --bin rssh-server
  • Headless browser verification: two pressed-state buttons, zero split-mode input elements, reload persistence, and 460px single-column layout

Summary by CodeRabbit

  • New Features

    • Added configurable command-block splitting with deterministic Enter-based or local shell Prompt-based modes.
    • Added settings under Advanced → Command Blocks, with saved preferences, guidance, accessibility support, responsive layout, and error handling.
    • Prompt-based detection supports submitted commands, wrapped prompts, terminal resets, and alternate-buffer transitions.
  • Documentation

    • Updated English and Chinese help content to explain both modes, limitations, and session behavior.
  • Bug Fixes

    • Improved prompt recognition to avoid duplicate or output-like matches.

Copilot AI lite review requested due to automatic review settings August 6, 2026 14:59
@coderabbitai

coderabbitai Bot commented Aug 6, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR adds Enter and Prompt command-block split modes. It persists the selected mode, loads it before tracker creation, updates terminal tracking, adds tests, and documents the behavior and settings. It also adds two roadmap items.

Changes

Command-block split modes

Layer / File(s) Summary
Prompt-aware tracker behavior
src/lib/terminal/command-blocks.ts, src/lib/terminal/prompt.ts, src/lib/terminal/command-blocks.test.ts
The tracker supports Enter and Prompt modes. Prompt mode detects standalone prompts after command submission and handles resets, soft wraps, alternate buffers, and disposal.
Persisted split-mode state
src/lib/stores/app.svelte.ts, src/lib/stores/app.svelte.test.ts, src/lib/components/TerminalPane.svelte
The store validates, caches, loads, and persists the split mode. TerminalPane passes the loaded mode to the tracker.
Split-mode configuration UI
src/lib/components/CommandBlockSettings.svelte, src/lib/i18n/locales/en.ts, src/lib/i18n/locales/zh.ts
The settings card provides Enter and Prompt options, optimistic saving, rollback, errors, accessibility states, responsive styling, and localized text.
Command-block mode documentation
docs/article_blocks_zh.md, docs/article_structured_zh.md, docs/article_workbench_zh.md, docs/index.html
Documentation describes Enter as the default mode, optional local Prompt detection, detection limits, and the updated settings path.

Roadmap updates

Layer / File(s) Summary
New roadmap items
roadmap.md
The roadmap adds custom profile and forward icons and an iOS shortcut keyboard synchronized with the soft keyboard.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant CommandBlockSettings
  participant AppStore
  participant TerminalPane
  participant CommandBlockTracker
  User->>CommandBlockSettings: select Enter or Prompt mode
  CommandBlockSettings->>AppStore: setCommandBlockSplitMode(mode)
  AppStore-->>CommandBlockSettings: persist setting
  TerminalPane->>AppStore: loadCommandBlockSplitMode()
  AppStore-->>TerminalPane: validated mode
  TerminalPane->>CommandBlockTracker: create tracker with mode
  CommandBlockTracker-->>TerminalPane: split command blocks by selected strategy
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding prompt-based command block splitting.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/command-block-prompt-splitting

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/article_blocks_zh.md`:
- Around line 133-136: Add the text language identifier to the fenced Markdown
block containing the settings layout, changing the opening fence to use text
while preserving its contents and closing fence.

In `@docs/index.html`:
- Line 2473: Update the documentation sentence around the command-block behavior
to use conditional wording rather than claiming every command becomes a block.
State that commands are separated into blocks when the configured boundary
mechanism recognizes the returned prompt, while preserving the existing
explanation of colored edges and Enter-based or local prompt recognition.

In `@src/lib/components/CommandBlockSettings.svelte`:
- Around line 70-73: Update the catch block in the split-mode save flow to call
the shared toast error path with errMsg(error), while preserving the existing
splitMode rollback and inline splitModeNote message.
- Around line 26-33: Add an initial split-mode readiness state in the component,
keep both mode buttons disabled until loadCommandBlockSplitMode() completes, and
set that state after the Promise.all initialization finishes. Guard
selectSplitMode with the same readiness check so user changes cannot occur
during loading or be overwritten by loadedSplitMode.

In `@src/lib/stores/app.svelte.ts`:
- Around line 740-742: Update the catch path for command-block split mode
loading to call toast.error(errMsg(error)) in addition to the existing warning,
ensuring get_setting failures are shown to the user while preserving the
fallback behavior.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e1030f4f-dfde-49dd-a052-2fec06efe2dc

📥 Commits

Reviewing files that changed from the base of the PR and between b048e14 and e33ee20.

📒 Files selected for processing (13)
  • docs/article_blocks_zh.md
  • docs/article_structured_zh.md
  • docs/article_workbench_zh.md
  • docs/index.html
  • src/lib/components/CommandBlockSettings.svelte
  • src/lib/components/TerminalPane.svelte
  • src/lib/i18n/locales/en.ts
  • src/lib/i18n/locales/zh.ts
  • src/lib/stores/app.svelte.test.ts
  • src/lib/stores/app.svelte.ts
  • src/lib/terminal/command-blocks.test.ts
  • src/lib/terminal/command-blocks.ts
  • src/lib/terminal/prompt.ts

Comment thread docs/article_blocks_zh.md Outdated
Comment thread docs/index.html Outdated
Comment thread src/lib/components/CommandBlockSettings.svelte
Comment thread src/lib/components/CommandBlockSettings.svelte
Comment thread src/lib/stores/app.svelte.ts

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.

Pull request overview

Adds an opt-in, prompt-recognition–based strategy for splitting terminal command blocks, backed by a persisted per-user setting and UI controls, while keeping the existing Enter-based splitting as the deterministic default.

Changes:

  • Implement prompt split mode in the command-block tracker using constrained, cursor-line-only prompt detection.
  • Persist and expose command_block_split_mode via the app store + terminal pane initialization.
  • Add settings UI + i18n strings and update user-facing docs to describe the new behavior/limitations.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/lib/terminal/prompt.ts Tightens documentation around safe prompt-detection usage constraints.
src/lib/terminal/command-blocks.ts Adds split modes (enter vs prompt) and prompt-based boundary detection using onWriteParsed.
src/lib/terminal/command-blocks.test.ts Adds prompt-mode tests (startup prompt, post-Enter prompt return, wrapped prompt, reset, alt-buffer).
src/lib/stores/app.svelte.ts Introduces persisted command_block_split_mode setting load/set APIs (with fallback).
src/lib/stores/app.svelte.test.ts Updates invoke mocking and adds tests for split-mode load sharing, fallback, and persistence.
src/lib/i18n/locales/zh.ts Adds zh strings for the new split-mode setting and updates prompt-redaction description text.
src/lib/i18n/locales/en.ts Adds en strings for the new split-mode setting and updates prompt-redaction description text.
src/lib/components/TerminalPane.svelte Initializes the command-block tracker with the persisted split mode per terminal pane.
src/lib/components/CommandBlockSettings.svelte Adds accessible two-button split-mode selector + responsive layout styling.
docs/index.html Updates marketing copy to reflect default Enter mode + opt-in prompt detection.
docs/article_workbench_zh.md Updates explanation to include optional prompt-based splitting.
docs/article_structured_zh.md Updates structured-terminal article to describe default + optional prompt mode.
docs/article_blocks_zh.md Documents prompt mode behavior/limitations and updates settings section.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/lib/components/CommandBlockSettings.svelte

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/lib/stores/app.svelte.test.ts`:
- Line 514: Update the toast-dismissal loop to iterate over a snapshot of the
array returned by toasts() before calling dismiss(item.id), ensuring removals do
not alter the collection being traversed and all toasts are dismissed.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6548800b-4ea7-45d3-a6b4-7c43d8d77bde

📥 Commits

Reviewing files that changed from the base of the PR and between a77a464 and 1934f99.

📒 Files selected for processing (5)
  • docs/article_blocks_zh.md
  • docs/index.html
  • src/lib/components/CommandBlockSettings.svelte
  • src/lib/stores/app.svelte.test.ts
  • src/lib/stores/app.svelte.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • docs/index.html
  • docs/article_blocks_zh.md
  • src/lib/stores/app.svelte.ts
  • src/lib/components/CommandBlockSettings.svelte

Comment thread src/lib/stores/app.svelte.test.ts Outdated

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.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated no new comments.

Suppressed comments (1)

src/lib/components/CommandBlockSettings.svelte:656

  • The PR description states the split-mode choices “collapse to one column below 600px”, but the implemented breakpoint here is 480px. This is a concrete discrepancy that will affect mobile layout behavior versus what’s documented/expected.
  @media (max-width: 480px) {
    .split-mode-options { grid-template-columns: 1fr; }
  }

@shihuili1218
shihuili1218 merged commit 8da3c3d into main Aug 7, 2026
@shihuili1218
shihuili1218 deleted the feat/command-block-prompt-splitting branch August 7, 2026 03:45
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.

2 participants