can you review the PR comments for this branch?
- User
can you review the PR comments for this branch?
Assistant
Here's a summary of the PR comments for PR #466 (
soph/opencode-refactor-bugfix):Status
- Approved by @squishykid
- Reviewed by GitHub Copilot and Cursor Bugbot
Inline Review Comments (5 total)
1. Redundant agent lookup in
manual_commit_hooks.go:1148(Copilot)File:
cmd/entire/cli/strategy/manual_commit_hooks.goprepareTranscriptIfNeededcallsagent.GetByAgentTypeinternally, but the function already fetched the agent earlier. Suggests using the already-resolvedagwith a type assertion instead:goif preparer, ok := ag.(agent.TranscriptPreparer); ok { preparer.PrepareTranscript(state.TranscriptPath) }2. Same redundant lookup in second location (Copilot)
File:
cmd/entire/cli/strategy/manual_commit_hooks.go:1188Same issue - duplicate
GetByAgentTypecall.3. Missing error handling for
os.Statfailures (Copilot)File:
cmd/entire/cli/agent/opencode/lifecycle.go:119-121PrepareTranscripttreats anyos.Staterror as "file missing". Should explicitly handle non-os.IsNotExisterrors:goif _, err := os.Stat(sessionRef); err == nil { return nil } else if !os.IsNotExist(err) { return fmt.Errorf("failed to stat OpenCode transcript path %s: %w", sessionRef, err) }4. Test doesn't exercise the actual fix (Copilot)
File:
cmd/entire/cli/integration_test/opencode_hooks_test.go:311-315The test pre-creates the transcript via
CopyTranscriptToEntireTmp, makingPrepareTranscripta no-op. The test doesn't actually exercise the on-demand export behavior.5. Stale transcript prevents checkpoints in resumed sessions (Cursor Bugbot - Medium Severity)
File:
cmd/entire/cli/agent/opencode/lifecycle.go:117-122The most significant issue: short-circuits when the file exists, but for resumed sessions (turn 2+), the file contains stale data from the previous turn. Since both and are derived from the same stale file, the "no new content" check passes and no checkpoint is created. Mid-turn commits in turn 2+ still won't produce checkpoints.
- User
let's fix all of them
Assistant
I'll read the relevant files to understand the current implementation, then fix all the issues.
Assistant
Let me also check the integration test hooks helper and the agent interface for
TranscriptPreparer.Assistant
Let me also look at the
lifecycle_test.gofile to understand the existing tests forPrepareTranscript.Assistant
Now I have a complete picture. Let me fix all the issues:
lifecycle.go: Fixos.Staterror handling AND the stale transcript issue (always refresh)manual_commit_hooks.go: Use the already-resolvedagvariable instead of callingprepareTranscriptIfNeeded- Test: Restructure to actually exercise the
PrepareTranscriptflow
Assistant
Now let me fix the two locations in
manual_commit_hooks.go:Assistant
Let me check if
prepareTranscriptIfNeededis still used elsewhere:Assistant
The function is still used in
manual_commit_condensation.go. Let me fix those locations too:Assistant
The
prepareTranscriptIfNeededcalls inmanual_commit_condensation.goare fine - those locations don't have an already-resolved agent variable, so the function is appropriate there.Now I need to update the tests. First, let me update
lifecycle_test.gosince the behavior has changed (no longer a no-op when file exists):Assistant
Now let me add a test for the improved error handling:
Assistant
Let me re-read the mock export logic to understand the test setup better:
Assistant
The test is actually fine now because with the fix,
PrepareTranscriptalways callsfetchAndCacheExport. In mock mode,fetchAndCacheExportchecks if the file exists at.entire/tmp/and returns it. Let me update the test comment to reflect the new behavior:Assistant
Now let me run the tests to verify the fixes work:
Assistant
Let me fix the lint issue:
Assistant
Now let me run the integration tests for OpenCode:
Assistant
All tests pass. Let me run the full test suite to make sure there are no regressions:
Assistant
All tests pass. Here's a summary of the fixes I made:
Summary of Changes
1.
cmd/entire/cli/agent/opencode/lifecycle.go- Fixed two issues:a) Proper error handling for
os.Statfailures:- Now explicitly checks for non-
os.IsNotExisterrors (permission denied, broken symlinks) - Returns a wrapped error explaining the issue instead of proceeding to export
b) Fixed stale transcript issue (Cursor Bugbot's Medium severity bug):
PrepareTranscriptnow ALWAYS callsfetchAndCacheExportto refresh the transcript- This ensures resumed sessions (turn 2+) get fresh data, not stale cached data from previous turns
- Critical for mid-turn commits to capture the latest agent activity
2.
cmd/entire/cli/strategy/manual_commit_hooks.go- Fixed redundant agent lookup:- Now explicitly checks for non-
- User
/exit exit