fix(ralph-loop): generate transcript path from sessionID instead of relying on event properties (#355)
OpenCode doesn't pass transcriptPath in the session.idle event properties, which caused detectCompletionPromise to always return false (the first check returns early if transcriptPath is undefined). This fix: - Imports getTranscriptPath from claude-code-hooks/transcript - Generates the transcript path from sessionID instead of reading from event - Adds optional getTranscriptPath callback to RalphLoopOptions for testability Fixes #354 Co-authored-by: sisyphus-dev-ai <sisyphus-dev-ai@users.noreply.github.com>
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
DEFAULT_COMPLETION_PROMISE,
|
||||
} from "./constants"
|
||||
import type { RalphLoopState, RalphLoopOptions } from "./types"
|
||||
import { getTranscriptPath as getDefaultTranscriptPath } from "../claude-code-hooks/transcript"
|
||||
|
||||
export * from "./types"
|
||||
export * from "./constants"
|
||||
@@ -48,6 +49,7 @@ export function createRalphLoopHook(
|
||||
const sessions = new Map<string, SessionState>()
|
||||
const config = options?.config
|
||||
const stateDir = config?.state_dir
|
||||
const getTranscriptPath = options?.getTranscriptPath ?? getDefaultTranscriptPath
|
||||
|
||||
function getSessionState(sessionID: string): SessionState {
|
||||
let state = sessions.get(sessionID)
|
||||
@@ -149,7 +151,8 @@ export function createRalphLoopHook(
|
||||
return
|
||||
}
|
||||
|
||||
const transcriptPath = props?.transcriptPath as string | undefined
|
||||
// Generate transcript path from sessionID - OpenCode doesn't pass it in event properties
|
||||
const transcriptPath = getTranscriptPath(sessionID)
|
||||
|
||||
if (detectCompletionPromise(transcriptPath, state.completion_promise)) {
|
||||
log(`[${HOOK_NAME}] Completion detected!`, {
|
||||
|
||||
Reference in New Issue
Block a user