Repository navigation
feat(terminal): add prompt-based command block splitting - #223
Conversation
📝 WalkthroughWalkthroughThe 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. ChangesCommand-block split modes
Roadmap updates
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
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (13)
docs/article_blocks_zh.mddocs/article_structured_zh.mddocs/article_workbench_zh.mddocs/index.htmlsrc/lib/components/CommandBlockSettings.sveltesrc/lib/components/TerminalPane.sveltesrc/lib/i18n/locales/en.tssrc/lib/i18n/locales/zh.tssrc/lib/stores/app.svelte.test.tssrc/lib/stores/app.svelte.tssrc/lib/terminal/command-blocks.test.tssrc/lib/terminal/command-blocks.tssrc/lib/terminal/prompt.ts
There was a problem hiding this comment.
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
promptsplit mode in the command-block tracker using constrained, cursor-line-only prompt detection. - Persist and expose
command_block_split_modevia 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.
There was a problem hiding this comment.
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
📒 Files selected for processing (5)
docs/article_blocks_zh.mddocs/index.htmlsrc/lib/components/CommandBlockSettings.sveltesrc/lib/stores/app.svelte.test.tssrc/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
There was a problem hiding this comment.
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; }
}
Summary
Compatibility
No schema, new command, or IPC change is required. Existing users keep Enter mode, and unknown persisted values fall back to Enter.
Testing
Summary by CodeRabbit
New Features
Documentation
Bug Fixes