feat(cli): enhance /clear with --history and --all flags#2915
feat(cli): enhance /clear with --history and --all flags#2915
Conversation
📋 Review SummaryThis PR enhances the 🔍 General Feedback
🎯 Specific Feedback🔴 Critical
🟡 High
🟢 Medium
🔵 Low
✅ Highlights
|
Add explicit return type annotation to clearCommand action to fix "Not all code paths return a value" TypeScript error. Revert the regenerated unused-keys-only-in-locales.json to avoid unrelated diff noise. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR enhances the CLI /clear slash command by adding new reset modes with confirmation prompts and tab-completion support, plus locale updates for the new user-facing strings.
Changes:
- Added
/clear --history(clear conversation history) and/clear --all(full reset incl. IDE context store) with interactive confirmations. - Added argument completion entries for
--historyand--all. - Updated
clearCommandtests and added new i18n strings inenandzhlocales.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| packages/cli/src/ui/commands/clearCommand.ts | Implements new /clear modes, confirmations, and flag completions; clears IDE context store for --all. |
| packages/cli/src/ui/commands/clearCommand.test.ts | Expands test coverage for new modes, confirmation returns, and IDE context clearing behavior. |
| packages/cli/src/i18n/locales/en.js | Adds English strings for new confirmation prompts and completion descriptions. |
| packages/cli/src/i18n/locales/zh.js | Adds Chinese translations for new confirmation prompts and completion descriptions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Update command description to reflect new behavior (screen-only by default) - Explicitly handle both --history and --all flags (--all takes precedence) - Add comment explaining IDE context preservation in --history mode - Add test case for simultaneous --history and --all flags - Add i18n keys for updated description (en, zh) 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. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Tokenize args with split/filter for exact flag matching, preventing substring false positives (e.g. --allow matching --all) - Filter completion suggestions by partialArg, consistent with modelCommand - Fix comment to not conflate IDE context with system prompt/memory Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
packages/cli/src/ui/commands/clearCommand.test.ts:304
- There’s no test covering the config-less case for
--all. Given--allis supposed to clear the IDE context store, it would be good to add a test similar to the null-config one here that runs/clear --alland assertsideContextStore.clear()is called (and that the action still completes). This will also catch regressions around the config-less fallback behavior.
it('should not attempt to reset chat if config service is not available', async () => {
if (!clearCommand.action) {
throw new Error('clearCommand must have an action.');
}
const nullConfigContext = createMockCommandContext({
services: {
config: null,
},
session: {
startNewSession: vi.fn(),
},
overwriteConfirmed: true,
});
await clearCommand.action(nullConfigContext, '--history');
expect(nullConfigContext.ui.setDebugMessage).toHaveBeenCalledWith(
'Starting a new session and clearing.',
);
expect(mockResetChat).not.toHaveBeenCalled();
expect(nullConfigContext.ui.clear).toHaveBeenCalledTimes(1);
});
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Enhances the
/clearcommand with multiple clear modes, providing finer-grained control over session resets.Comparison with Claude Code
/clear(no args)/clear --history/clear --all--historyand--all--historyand--allflags with descriptionsKey improvements over Claude Code:
/clearalone only clears the screen, preventing accidental data loss--history) and full reset (--all)Before / After (within Qwen Code)
/clear/clear --history/clear --allChanges
/clear(no args): Only clears the terminal screen — safe, no session reset/clear --history: Clears conversation history while keeping system prompt, memory, and IDE context/clear --all: Completely resets the session, clearing history and IDE context store--historyand--allmodes--historyand--allflags, filtered by partial inputenandzhlocales--historyand--allare provided,--alltakes precedenceTest plan
/clearonly clears the screen, does not reset session/clear --historyprompts for confirmation, then clears history/clear --allprompts for confirmation, then fully resets session + IDE context--allresetChatfor immediate responsiveness🤖 Generated with Claude Code