fix: close PI-140 cutover gaps

Back up unknown legacy Agents, reconnect settled Conversation observation, remove remaining active repository residue, and restore the bundled Python verifier import.
This commit is contained in:
2026-08-24 12:47:16 +08:00
parent 5a275b93a7
commit 7a15b1b49c
12 changed files with 286 additions and 247 deletions

View File

@@ -6,6 +6,7 @@ import {
useUserProfileStore,
} from '@/stores/user-profile';
import type { RawMessage } from '@/types/chat';
import type { ConversationSnapshot } from '@/types/coding-conversation';
import type {
AgentSessionData,
AgentSessionMessage,
@@ -338,14 +339,7 @@ async function flushUpload(key: string): Promise<void> {
}
}
/** Queue a completed local session snapshot without blocking the chat turn. */
export function queueAgentSessionSync(
projectId: string,
sessionId: string,
messages: readonly RawMessage[],
): void {
const data = buildAgentSessionData(projectId, sessionId, messages);
if (!data) return;
function queueAgentSessionData(data: AgentSessionData): void {
const userId = getCurrentAccountKey();
if (!userId) return;
@@ -356,6 +350,44 @@ export function queueAgentSessionSync(
scheduleUpload(key, SESSION_UPLOAD_DEBOUNCE_MS);
}
/** Queue a completed local session snapshot without blocking the chat turn. */
export function queueAgentSessionSync(
projectId: string,
sessionId: string,
messages: readonly RawMessage[],
): void {
const data = buildAgentSessionData(projectId, sessionId, messages);
if (!data) return;
queueAgentSessionData(data);
}
/** Queue the final product Conversation snapshot after a completed prompt turn. */
export function queueCodingConversationSessionSync(snapshot: ConversationSnapshot): void {
const messages: RawMessage[] = snapshot.nodes.flatMap((node) => {
if (node.kind !== 'message') return [];
return [{
id: node.id,
role: node.role,
content: node.blocks.flatMap((block) => (
block.kind === 'text' ? [{ type: 'text', text: block.text }] : []
)),
isError: node.status === 'error' || node.status === 'aborted',
} satisfies RawMessage];
});
const settledAt = snapshot.run.settledAt;
const updatedAt = typeof settledAt === 'number' && Number.isFinite(settledAt)
? new Date(settledAt).toISOString()
: new Date().toISOString();
const data = buildAgentSessionData(
snapshot.conversation.projectId,
snapshot.conversation.id,
messages,
updatedAt,
);
if (!data?.messages.some((message) => message.role === 'assistant')) return;
queueAgentSessionData(data);
}
/** Flush persisted session snapshots after login or profile bootstrap. */
export async function flushPendingAgentSessionSync(): Promise<void> {
hydratePendingUploads();