fix: address Cubic round-4 P2 issues
- isTodo: allow optional id to match Todo interface, preventing todos without ids from being silently dropped - messageHasContentFromSDK: treat unknown part types as empty (continue) instead of content (return true) for parity with existing storage logic - readMessagesFromSDK in recover-empty-content-message-sdk: wrap SDK call in try/catch to prevent recovery from throwing
This commit is contained in:
parent
557340af68
commit
8d82025b70
@ -4,7 +4,7 @@ function isTodo(value: unknown): value is Todo {
|
|||||||
if (typeof value !== "object" || value === null) return false
|
if (typeof value !== "object" || value === null) return false
|
||||||
const todo = value as Record<string, unknown>
|
const todo = value as Record<string, unknown>
|
||||||
return (
|
return (
|
||||||
typeof todo["id"] === "string" &&
|
(typeof todo["id"] === "string" || todo["id"] === undefined) &&
|
||||||
typeof todo["content"] === "string" &&
|
typeof todo["content"] === "string" &&
|
||||||
typeof todo["status"] === "string" &&
|
typeof todo["status"] === "string" &&
|
||||||
typeof todo["priority"] === "string"
|
typeof todo["priority"] === "string"
|
||||||
|
|||||||
@ -32,7 +32,7 @@ function messageHasContentFromSDK(message: SDKMessage): boolean {
|
|||||||
|
|
||||||
if (TOOL_TYPES.has(type)) return true
|
if (TOOL_TYPES.has(type)) return true
|
||||||
|
|
||||||
return true
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
|
|||||||
@ -133,8 +133,12 @@ function sdkMessageHasContent(message: MessageData): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function readMessagesFromSDK(client: Client, sessionID: string): Promise<MessageData[]> {
|
async function readMessagesFromSDK(client: Client, sessionID: string): Promise<MessageData[]> {
|
||||||
const response = await client.session.messages({ path: { id: sessionID } })
|
try {
|
||||||
return (response.data ?? []) as MessageData[]
|
const response = await client.session.messages({ path: { id: sessionID } })
|
||||||
|
return (response.data ?? []) as MessageData[]
|
||||||
|
} catch {
|
||||||
|
return []
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function findMessagesWithThinkingOnlyFromSDK(messages: MessageData[]): string[] {
|
function findMessagesWithThinkingOnlyFromSDK(messages: MessageData[]): string[] {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user