Compare commits

...
Author SHA1 Message Date
Cursor Agent 3065fcb5cf Fix thread creation without API, threadsUpdate fallthrough, and duplicate updateBranch calls
- Sidebar: Create thread locally in addProjectFromPath when API is unavailable,
  instead of calling handleNewThread which requires API
- wsServer: Break fallthrough from threadsUpdate to threadsUpdateTerminalState,
  throw explicit error for unimplemented generic threads.update method
- BranchToolbar: Remove explicit api.threads.updateBranch call since the
  useEffect in ChatView.tsx already syncs branch changes to the server
2026-02-20 06:14:16 +00:00
3 changed files with 51 additions and 17 deletions

No files matched your search

+18 -15
View File
@@ -339,21 +339,20 @@ export function createServer(options: ServerOptions) {
case WS_METHODS.providersGetCheckpointDiff:
return providerManager.getCheckpointDiff(request.params as never);
case WS_METHODS.providersRevertToCheckpoint:
{
const params = request.params as {
sessionId: string;
turnCount: number;
};
const result = await providerManager.revertToCheckpoint(params as never);
persistenceService.applyCheckpointRevert({
sessionId: params.sessionId,
runtimeThreadId: result.threadId,
turnCount: result.turnCount,
messageCount: result.messageCount,
});
return result;
}
case WS_METHODS.providersRevertToCheckpoint: {
const params = request.params as {
sessionId: string;
turnCount: number;
};
const result = await providerManager.revertToCheckpoint(params as never);
persistenceService.applyCheckpointRevert({
sessionId: params.sessionId,
runtimeThreadId: result.threadId,
turnCount: result.turnCount,
messageCount: result.messageCount,
});
return result;
}
case WS_METHODS.stateBootstrap:
return persistenceService.loadSnapshot();
@@ -377,6 +376,10 @@ export function createServer(options: ServerOptions) {
return persistenceService.createThread(request.params as never);
case WS_METHODS.threadsUpdate:
throw new Error(
`Method ${WS_METHODS.threadsUpdate} is not implemented. Use a specific update method instead.`,
);
case WS_METHODS.threadsUpdateTerminalState:
return persistenceService.updateThreadTerminalState(request.params as never);
@@ -120,7 +120,6 @@ export default function BranchToolbar({
if (sessionId && worktreePath !== activeWorktreePath) {
void api?.providers.stopSession({ sessionId }).catch(() => undefined);
}
void api?.threads.updateBranch({ threadId: activeThreadId, branch, worktreePath }).catch(() => undefined);
dispatch({ type: "SET_THREAD_BRANCH", threadId: activeThreadId, branch, worktreePath });
};
+33 -1
View File
@@ -241,7 +241,38 @@ export default function Sidebar() {
scripts: [],
};
dispatch({ type: "ADD_PROJECT", project });
handleNewThread(project.id);
const threadId = crypto.randomUUID();
const now = new Date().toISOString();
dispatch({
type: "ADD_THREAD",
thread: {
id: threadId,
codexThreadId: null,
projectId: project.id,
title: "New thread",
model: DEFAULT_MODEL,
terminalOpen: false,
terminalHeight: 300,
terminalIds: [],
runningTerminalIds: [],
activeTerminalId: "",
terminalGroups: [],
activeTerminalGroupId: "",
session: null,
messages: [],
events: [],
error: null,
createdAt: now,
branch: null,
worktreePath: null,
turnDiffSummaries: [],
},
});
void navigate({
to: "/$threadId",
params: { threadId },
});
return;
}
@@ -278,6 +309,7 @@ export default function Sidebar() {
focusMostRecentThreadForProject,
handleNewThread,
isAddingProject,
navigate,
state.projects,
],
);