Skip to content

Commit 2ff3bed

Browse files
dzianisvengineer
andcommitted
fix(session): recover orphaned assistant messages on startup (#59)
When the server crashes or restarts while a session is actively executing tool calls, in-memory session state is lost but the database retains stale incomplete messages. This leaves sessions permanently stuck in a 'Thinking' state with no way to recover. Add Session.recover() that runs during InstanceBootstrap to: - find assistant messages with no time.completed - force running/pending tool parts to error status - mark orphaned messages as completed - emit bus events so connected frontends update Closes anomalyco#19023 Co-authored-by: engineer <[email protected]>
1 parent 950a9fe commit 2ff3bed

2 files changed

Lines changed: 580 additions & 521 deletions

File tree

‎packages/opencode/src/project/bootstrap.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ import { Command } from "../command"
1111
import { Instance } from "./instance"
1212
import { Log } from "@/util/log"
1313
import { ShareNext } from "@/share/share-next"
14+
import { Session } from "@/session"
1415

1516
export async function InstanceBootstrap() {
1617
Log.Default.info("bootstrapping", { directory: Instance.directory })
18+
await Session.recover()
1719
await Plugin.init()
1820
ShareNext.init()
1921
Format.init()

0 commit comments

Comments
 (0)