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
This commit is contained in:
1 parent
27bd9192ad
commit
3065fcb5cf
3 files changed
+51
-17
No files matched your search
+18
-15
@@ -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 });
|
||||
};
|
||||
|
||||
|
||||
@@ -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,
|
||||
],
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user