feat(cli): add /btw slash command for ephemeral side questions#2371
feat(cli): add /btw slash command for ephemeral side questions#2371yiliang114 merged 18 commits intomainfrom
Conversation
Allow users to ask quick "by the way" questions that use the current conversation context but don't pollute the main conversation history. Closes #2370 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add pendingItem conflict guard to prevent overwriting other operations - Use finally block to ensure setPendingItem(null) is always called - Wrap "Thinking..." with t() for i18n support - Remove unnecessary type assertion, use typed variable instead Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
📋 Review SummaryThis PR introduces a 🔍 General Feedback
🎯 Specific Feedback🟡 High
🟢 Medium
🔵 Low
✅ Highlights
|
- Add ACP mode support with stream_messages async generator - Add non-interactive mode support with simple message return - Add wrap="wrap" to Text components for long text handling - Extract askBtw helper to reduce duplication across execution modes Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove redundant null check by passing the already-validated client and model to the helper function instead of re-extracting them. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Code Coverage Summary
CLI Package - Full Text ReportCore Package - Full Text ReportFor detailed HTML reports, please see the 'coverage-reports-22.x-ubuntu-latest' artifact from the main CI run. |
…ommand
Extract repeated error formatting into formatBtwError helper, remove
no-op marginTop={0}, and add comprehensive test coverage for all three
execution modes.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Explicitly pass tools:[] to generateContent to prevent tool invocation in side questions. Add model undefined guard for defensive safety. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…eSyntax incompatibility The @anthropic-ai/sdk package's type exports are not compatible with TypeScript's verbatimModuleSyntax option when using NodeNext module resolution. Define the stream event types locally to avoid the import error. Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Revert tools:[] to empty config {} to avoid provider compatibility
issues. Empty tools array is truthy and gets passed through to API
requests, which can cause errors on some providers. Omitting the
tools field entirely achieves the same effect (no tool access).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
7611683 to
b1b5f72
Compare
Run the /btw API call as fire-and-forget in interactive mode so the main conversation is not blocked while waiting for the answer. The action now returns immediately after setting the pending item, and the background promise updates the UI when the answer arrives. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
ef4b083 to
1b651d5
Compare
Replace broad \s+} and \s+] regexes with a narrower pattern that only
strips whitespace before closing braces/brackets when preceded by a
JSON value terminator (", digit, ] or }). Prevents mangling string
values like "hello }" which contain whitespace before braces.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Use promptIdContext for stateless requests - Add promptIdOverride parameter to generateContent method - Prefer explicit override over context, context over lastPromptId Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
- Delete anthropicSseParser.ts as it's no longer needed Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
- Add btwItem state management independent from pendingItem - Add cancelBtw functionality to abort in-flight BTW API calls - Allow /btw commands to execute concurrently with main responses - Add isBtwCommand utility function - Update BtwMessage UI with cleaner styling (remove spinner) - Add tests for concurrent /btw execution scenarios - Update layouts to render BTW messages in fixed bottom area Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
# Conflicts: # packages/cli/src/ui/AppContainer.tsx # packages/cli/src/ui/hooks/useGeminiStream.ts # packages/cli/src/ui/layouts/DefaultAppLayout.tsx # packages/cli/src/ui/types.ts # packages/core/src/core/client.test.ts
There was a problem hiding this comment.
Thank you for this well-structured PR! The /btw command is a useful feature for asking quick side questions. Here's my detailed review:
Suggestions
Suggest wrapping BtwMessage with React.memo to prevent unnecessary re-renders and avoid layout jitter.
import { memo } from 'react';
const BtwMessageInner: React.FC<BtwDisplayProps> = ({ btw }) => ( .... )
export const BtwMessage = memo(BtwMessageInner);
…y cleanup - Make /btw overlay mutually exclusive with Composer (replaces input area) - Add dismiss hints: "Press Escape to cancel" (pending) / "Press Space, Enter, or Escape to dismiss" (completed) - Skip adding /btw to conversation history to avoid duplicate display - Prioritize dialog shortcuts over btw dismiss via dialogsVisibleRef - Add `sleep` property to terminal-capture FlowStep for async wait scenarios Made-with: Cursor
- Add null/undefined guard in formatBtwError to avoid "null"/"undefined" strings - Add type guard for btw property in HistoryItemDisplay to prevent crash - Extract isBtwCommand regex to module-level constant and simplify with [/?] Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
/btwslash command that lets users ask quick side questions using the current conversation context, without affecting the main conversation historyBtwMessageUI componentCloses #2370
Test plan
/btw <question>and verify the answer appears withbtw>prefix styling/btwwithout arguments and verify error message is shown/btwrequest and verify it cancels cleanly/btwappears in/helpcommand listnpx tsc --noEmit --project packages/cli/tsconfig.jsonTLDR
Dive Deeper
Reviewer Test Plan
Testing Matrix
Linked issues / bugs