Skip to content

Commit 5a98c6b

Browse files
王璨claude
andcommitted
fix: clear visible history on reset
Make /reset clear the current TUI conversation view along with agent history, and bump the package version for the 0.0.7 release. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 9cb9640 commit 5a98c6b

5 files changed

Lines changed: 40 additions & 5 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@wangcan26/dscode",
3-
"version": "0.0.6",
3+
"version": "0.0.7",
44
"type": "module",
55
"description": "DeepSeek-native terminal AI agent for digital work — DeepSeek model harness analogous to Claude Code for Claude models.",
66
"bin": {

src/ui/commands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const COMMANDS: SlashCommandDef[] = [
5555
description: "Clear conversation history",
5656
execute: async (_args, ctx) => {
5757
ctx.agent.reset();
58-
ctx.tui.addInfo("(conversation reset)");
58+
ctx.tui.clearConversationView();
5959
},
6060
},
6161
{

src/ui/tui-app.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,23 @@ export class TuiApp {
752752
this.tui.setFocus(this.editor);
753753
}
754754

755+
clearConversationView(): void {
756+
this.conversation.clear();
757+
this.permissionExplainMode = false;
758+
this.pendingPermissionContext = null;
759+
this.menuNavDebounceUntil = 0;
760+
this.pendingImages = [];
761+
if (this.mcpPanelVisible) {
762+
this.closeMcpBrowser();
763+
} else {
764+
this.updateImageStatus();
765+
}
766+
this.editor.setText("");
767+
this.editor.disableSubmit = this.processing && !this.permissionExplainMode;
768+
this.focusEditor();
769+
this.tui.requestRender(true);
770+
}
771+
755772
addPendingImage(image: ImageContent): void {
756773
this.pendingImages.push(image);
757774
this.updateImageStatus();

tests/ui/commands.test.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function makeContext(overrides: Record<string, unknown> = {}) {
1919
} as any;
2020
}
2121

22-
describe("/mcp command", () => {
22+
describe("slash commands", () => {
2323
it("opens the MCP browser when MCP servers are available", async () => {
2424
const openMcpBrowser = vi.fn();
2525
const addInfo = vi.fn();
@@ -63,4 +63,22 @@ describe("/mcp command", () => {
6363
expect(addInfo).toHaveBeenCalledWith("No MCP servers configured.");
6464
expect(addError).not.toHaveBeenCalled();
6565
});
66+
67+
it("clears the visible conversation on /reset", async () => {
68+
const reset = vi.fn();
69+
const clearConversationView = vi.fn();
70+
const addInfo = vi.fn();
71+
72+
executeSlashCommand(
73+
"/reset",
74+
makeContext({ agent: { reset, state: { messages: [] } } }),
75+
{ clearConversationView, addInfo } as any,
76+
);
77+
78+
await Promise.resolve();
79+
80+
expect(reset).toHaveBeenCalledOnce();
81+
expect(clearConversationView).toHaveBeenCalledOnce();
82+
expect(addInfo).not.toHaveBeenCalledWith("(conversation reset)");
83+
});
6684
});

0 commit comments

Comments
 (0)