修复首次会话等待与上游饱和重试

This commit is contained in:
2026-08-12 23:26:19 +08:00
parent b02c3f22e1
commit 08da976634
10 changed files with 506 additions and 14 deletions

View File

@@ -210,7 +210,7 @@ interface OpencodeState {
deleteSession: (sessionId: string) => Promise<void>;
abortSession: (sessionId: string) => Promise<void>;
clearSessionSelection: () => void;
selectSession: (sessionId: string) => Promise<RawMessage[]>;
selectSession: (sessionId: string, options?: { loadMessages?: boolean }) => Promise<RawMessage[]>;
loadSessionStatuses: () => Promise<OpencodeSessionStatusMap>;
loadSessionMessages: (sessionId: string) => Promise<RawMessage[]>;
sendSessionMessage: (sessionId: string, text: string, options?: SendSessionMessageOptions) => Promise<RawMessage[]>;
@@ -3353,7 +3353,7 @@ export const useOpencodeStore = create<OpencodeState>((set, get) => ({
});
},
async selectSession(sessionId) {
async selectSession(sessionId, options) {
const state = get();
sessionDiffLoadSequence += 1;
const projectId = getProjectId(state.activeProject);
@@ -3373,6 +3373,12 @@ export const useOpencodeStore = create<OpencodeState>((set, get) => ({
sessionDiffError: null,
...errorState(null),
});
if (
options?.loadMessages === false
&& Object.prototype.hasOwnProperty.call(state.sessionMessagesBySessionId, sessionId)
) {
return state.sessionMessagesBySessionId[sessionId] ?? [];
}
return await get().loadSessionMessages(sessionId);
},