Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/browser/components/ChatInput/useCreationWorkspace.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import type { DraftWorkspaceSettings } from "@/browser/hooks/useDraftWorkspaceSettings";
import { getModeKey, getProjectScopeId, getThinkingLevelKey } from "@/common/constants/storage";
import {
getInputKey,
getModeKey,
getPendingScopeId,
getProjectScopeId,
getThinkingLevelKey,
} from "@/common/constants/storage";
import type { SendMessageError } from "@/common/types/errors";
import type { BranchListResult, IPCApi, SendMessageOptions } from "@/common/types/ipc";
import type { RuntimeMode } from "@/common/types/runtime";
Expand Down Expand Up @@ -219,8 +225,10 @@ describe("useCreationWorkspace", () => {

const modeKey = getModeKey(TEST_WORKSPACE_ID);
const thinkingKey = getThinkingLevelKey(TEST_WORKSPACE_ID);
const pendingInputKey = getInputKey(getPendingScopeId(TEST_PROJECT_PATH));
expect(updatePersistedStateCalls).toContainEqual([modeKey, "plan"]);
expect(updatePersistedStateCalls).toContainEqual([thinkingKey, "high"]);
expect(updatePersistedStateCalls).toContainEqual([pendingInputKey, ""]);
});

test("handleSend surfaces backend errors and resets state", async () => {
Expand Down
12 changes: 11 additions & 1 deletion src/browser/components/ChatInput/useCreationWorkspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ import { parseRuntimeString } from "@/browser/utils/chatCommands";
import { useDraftWorkspaceSettings } from "@/browser/hooks/useDraftWorkspaceSettings";
import { readPersistedState, updatePersistedState } from "@/browser/hooks/usePersistedState";
import { useSendMessageOptions } from "@/browser/hooks/useSendMessageOptions";
import { getModeKey, getProjectScopeId, getThinkingLevelKey } from "@/common/constants/storage";
import {
getInputKey,
getModeKey,
getPendingScopeId,
getProjectScopeId,
getThinkingLevelKey,
} from "@/common/constants/storage";
import type { Toast } from "@/browser/components/ChatInputToast";
import { createErrorToast } from "@/browser/components/ChatInputToasts";

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