修复首次会话等待与上游饱和重试
This commit is contained in:
@@ -1355,7 +1355,12 @@ export function OpencodeChatPanel({ variant = 'main', navigationDraft, onOpenDev
|
||||
}, [authenticationFailureKey, logout]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!selectedSessionId || sessionMessages.length > 0 || selectedSessionRunning) return;
|
||||
if (
|
||||
!selectedSessionId
|
||||
|| sessionMessages.length > 0
|
||||
|| Object.prototype.hasOwnProperty.call(sessionMessagesBySessionId, selectedSessionId)
|
||||
|| selectedSessionRunning
|
||||
) return;
|
||||
if (!activeProject || status.state !== 'running') return;
|
||||
void loadSessionMessages(selectedSessionId).catch(() => undefined);
|
||||
}, [
|
||||
@@ -1364,6 +1369,7 @@ export function OpencodeChatPanel({ variant = 'main', navigationDraft, onOpenDev
|
||||
selectedSessionId,
|
||||
selectedSessionRunning,
|
||||
sessionMessages.length,
|
||||
sessionMessagesBySessionId,
|
||||
status.state,
|
||||
]);
|
||||
|
||||
@@ -1718,7 +1724,7 @@ export function OpencodeChatPanel({ variant = 'main', navigationDraft, onOpenDev
|
||||
const createdSessionId = getSessionId(session);
|
||||
if (!createdSessionId) throw new Error('运行时未返回会话 ID');
|
||||
await linkProjectSession(activeProject.id, createdSessionId, submissionAgent.id);
|
||||
await selectSession(createdSessionId);
|
||||
await selectSession(createdSessionId, { loadMessages: false });
|
||||
submissionSession = {
|
||||
id: createdSessionId,
|
||||
generation: submissionSession.generation + 1,
|
||||
|
||||
@@ -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);
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user