Skip to content

Commit ffb75ab

Browse files
authored
🤖 fix: clear pending workspace creation prompt (#721)
## Summary - clear the project-scoped pending chat input once workspace creation succeeds so the next creation flow starts blank - wire the creation hook to reset the pending input key alongside mode & thinking preference sync - extend the corresponding hook test to assert the pending input key is reset to an empty string
1 parent d89d54a commit ffb75ab

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 type { Toast } from "@/browser/components/ChatInputToast";
1218
import { createErrorToast } from "@/browser/components/ChatInputToasts";
1319

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

0 commit comments

Comments
 (0)