refactor: create normalizeSDKResponse helper and replace scattered patterns across 37 files

This commit is contained in:
YeonGyu-Kim
2026-02-16 18:20:19 +09:00
parent 6d732fd1f6
commit 1a6810535c
41 changed files with 250 additions and 77 deletions
+2 -1
View File
@@ -1,4 +1,5 @@
import type { PluginInput } from "@opencode-ai/plugin"
import { normalizeSDKResponse } from "../shared"
interface Todo {
content: string
@@ -10,7 +11,7 @@ interface Todo {
export async function hasIncompleteTodos(ctx: PluginInput, sessionID: string): Promise<boolean> {
try {
const response = await ctx.client.session.todo({ path: { id: sessionID } })
const todos = (response.data ?? response) as Todo[]
const todos = normalizeSDKResponse(response, [] as Todo[], { preferResponseOnMissingData: true })
if (!todos || todos.length === 0) return false
return todos.some((todo) => todo.status !== "completed" && todo.status !== "cancelled")
} catch {