Skip to content

Commit 5567549

Browse files
committed
refactor(session-recovery): remove unused ThinkingPart interface and fallbackRevertStrategy function
🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
1 parent ae2d347 commit 5567549

File tree

1 file changed

+4
-61
lines changed

1 file changed

+4
-61
lines changed

src/hooks/session-recovery/index.ts

Lines changed: 4 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@ interface ToolUsePart {
3434
input: Record<string, unknown>
3535
}
3636

37-
interface ThinkingPart {
38-
type: "thinking"
39-
thinking: string
40-
}
41-
4237
interface MessagePart {
4338
type: string
4439
id?: string
@@ -186,62 +181,10 @@ async function recoverEmptyContentMessage(
186181
return anySuccess
187182
}
188183

189-
async function fallbackRevertStrategy(
190-
client: Client,
191-
sessionID: string,
192-
failedAssistantMsg: MessageData,
193-
directory: string
194-
): Promise<boolean> {
195-
const parentMsgID = failedAssistantMsg.info?.parentID
196-
197-
const messagesResp = await client.session.messages({
198-
path: { id: sessionID },
199-
query: { directory },
200-
})
201-
const msgs = (messagesResp as { data?: MessageData[] }).data
202-
if (!msgs || msgs.length === 0) {
203-
return false
204-
}
205-
206-
let targetUserMsg: MessageData | null = null
207-
if (parentMsgID) {
208-
targetUserMsg = msgs.find((m) => m.info?.id === parentMsgID) ?? null
209-
}
210-
if (!targetUserMsg) {
211-
for (let i = msgs.length - 1; i >= 0; i--) {
212-
if (msgs[i].info?.role === "user") {
213-
targetUserMsg = msgs[i]
214-
break
215-
}
216-
}
217-
}
218-
219-
if (!targetUserMsg?.parts?.length) {
220-
return false
221-
}
222-
223-
await client.session.revert({
224-
path: { id: sessionID },
225-
body: { messageID: targetUserMsg.info?.id ?? "" },
226-
query: { directory },
227-
})
228-
229-
const textParts = targetUserMsg.parts
230-
.filter((p) => p.type === "text" && p.text)
231-
.map((p) => ({ type: "text" as const, text: p.text ?? "" }))
232-
233-
if (textParts.length === 0) {
234-
return false
235-
}
236-
237-
await client.session.prompt({
238-
path: { id: sessionID },
239-
body: { parts: textParts },
240-
query: { directory },
241-
})
242-
243-
return true
244-
}
184+
// NOTE: fallbackRevertStrategy was removed (2025-12-08)
185+
// Reason: Function was defined but never called - no error recovery paths used it.
186+
// All error types have dedicated recovery functions (recoverToolResultMissing,
187+
// recoverThinkingBlockOrder, recoverThinkingDisabledViolation, recoverEmptyContentMessage).
245188

246189
export function createSessionRecoveryHook(ctx: PluginInput) {
247190
const processingErrors = new Set<string>()

0 commit comments

Comments
 (0)