Skip to content

Commit 0b72e72

Browse files
committed
fix: clear pending creation prompt
1 parent 5f31123 commit 0b72e72

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/browser/components/ChatInput/useCreationWorkspace.test.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import type { DraftWorkspaceSettings } from "@/browser/hooks/useDraftWorkspaceSettings";
2-
import { getModeKey, getProjectScopeId, getThinkingLevelKey } from "@/common/constants/storage";
2+
import {
3+
getInputKey,
4+
getModeKey,
5+
getPendingScopeId,
6+
getProjectScopeId,
7+
getThinkingLevelKey,
8+
} from "@/common/constants/storage";
39
import type { SendMessageError } from "@/common/types/errors";
410
import type { BranchListResult, IPCApi, SendMessageOptions } from "@/common/types/ipc";
511
import type { RuntimeMode } from "@/common/types/runtime";
@@ -219,8 +225,10 @@ describe("useCreationWorkspace", () => {
219225

220226
const modeKey = getModeKey(TEST_WORKSPACE_ID);
221227
const thinkingKey = getThinkingLevelKey(TEST_WORKSPACE_ID);
228+
const pendingInputKey = getInputKey(getPendingScopeId(TEST_PROJECT_PATH));
222229
expect(updatePersistedStateCalls).toContainEqual([modeKey, "plan"]);
223230
expect(updatePersistedStateCalls).toContainEqual([thinkingKey, "high"]);
231+
expect(updatePersistedStateCalls).toContainEqual([pendingInputKey, ""]);
224232
});
225233

226234
test("handleSend surfaces backend errors and resets state", async () => {

src/browser/components/ChatInput/useCreationWorkspace.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ import { parseRuntimeString } from "@/browser/utils/chatCommands";
77
import { useDraftWorkspaceSettings } from "@/browser/hooks/useDraftWorkspaceSettings";
88
import { readPersistedState, updatePersistedState } from "@/browser/hooks/usePersistedState";
99
import { useSendMessageOptions } from "@/browser/hooks/useSendMessageOptions";
10-
import { getModeKey, getProjectScopeId, getThinkingLevelKey } from "@/common/constants/storage";
10+
import {
11+
getInputKey,
12+
getModeKey,
13+
getPendingScopeId,
14+
getProjectScopeId,
15+
getThinkingLevelKey,
16+
} from "@/common/constants/storage";
1117
import { extractErrorMessage } from "./utils";
1218

1319
interface UseCreationWorkspaceOptions {
@@ -118,6 +124,10 @@ export function useCreationWorkspace({
118124
// Check if this is a workspace creation result (has metadata field)
119125
if ("metadata" in result && result.metadata) {
120126
syncCreationPreferences(projectPath, result.metadata.id);
127+
if (projectPath) {
128+
const pendingInputKey = getInputKey(getPendingScopeId(projectPath));
129+
updatePersistedState(pendingInputKey, "");
130+
}
121131
// Settings are already persisted via useDraftWorkspaceSettings
122132
// Notify parent to switch workspace (clears input via parent unmount)
123133
onWorkspaceCreated(result.metadata);

0 commit comments

Comments
 (0)