fix: address all Cubic P2 review issues
- session-utils: log SDK errors instead of silent swallow - opencode-message-dir: fix indentation, improve error log format - storage: use session.list for sessionExists (handles empty sessions) - storage.test: use resetStorageClient for proper SDK client cleanup - todo-sync: add content-based fallback for id-less todo removal
This commit is contained in:
@@ -1,22 +1,22 @@
|
||||
import { findNearestMessageWithFields, findNearestMessageWithFieldsFromSDK } from "../features/hook-message-injector"
|
||||
import { getMessageDir } from "./opencode-message-dir"
|
||||
import { isSqliteBackend } from "./opencode-storage-detection"
|
||||
import { log } from "./logger"
|
||||
import type { PluginInput } from "@opencode-ai/plugin"
|
||||
|
||||
export async function isCallerOrchestrator(sessionID?: string, client?: PluginInput["client"]): Promise<boolean> {
|
||||
if (!sessionID) return false
|
||||
|
||||
// Beta mode: use SDK if client provided
|
||||
if (isSqliteBackend() && client) {
|
||||
try {
|
||||
const nearest = await findNearestMessageWithFieldsFromSDK(client, sessionID)
|
||||
return nearest?.agent?.toLowerCase() === "atlas"
|
||||
} catch {
|
||||
} catch (error) {
|
||||
log("[session-utils] SDK orchestrator check failed", { sessionID, error: String(error) })
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// Stable mode: use JSON files
|
||||
const messageDir = getMessageDir(sessionID)
|
||||
if (!messageDir) return false
|
||||
const nearest = findNearestMessageWithFields(messageDir)
|
||||
|
||||
Reference in New Issue
Block a user