Skip to content

Commit 132dad1

Browse files
committed
feat: ❌ does not import or use the git functions
1 parent 79abe81 commit 132dad1

File tree

3 files changed

+74
-0
lines changed

3 files changed

+74
-0
lines changed

out.log

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
2+
OpenCoder v1.0.0
3+
Project: /home/leo/projects/opencoder
4+
Plan model: github-copilot/claude-opus-4.5
5+
Build model: github-copilot/claude-sonnet-4.5
6+
7+
Resuming from cycle 1, phase: build
8+
Starting OpenCode server...
9+
OpenCode server ready
10+
Building task 3/12
11+
● Building Task 3/12
12+
❌ `loop.ts` does not import or use the git functions
13+
[ERROR] Task failed: No active session
14+
Building task 3/12
15+
● Building Task 3/12
16+
❌ `loop.ts` does not import or use the git functions
17+
[ERROR] Task failed: No active session
18+
Building task 3/12
19+
● Building Task 3/12
20+
❌ `loop.ts` does not import or use the git functions
21+
[ERROR] Task failed: No active session
22+
Building task 3/12
23+
● Building Task 3/12
24+
❌ `loop.ts` does not import or use the git functions
25+
[ERROR] Task failed: No active session
26+
Building task 3/12
27+
● Building Task 3/12
28+
❌ `loop.ts` does not import or use the git functions
29+
[ERROR] Task failed: No active session
30+
31+
SIGINT received. Finishing current operation...
32+
Press Ctrl+C again to force quit.
33+
OpenCode server stopped
34+
OpenCoder stopped.
35+
36+
Press Ctrl+C again to force quit...
37+
38+
Force quit!

src/build.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,38 @@ export class Builder {
501501
this.sessionId = undefined
502502
}
503503

504+
/**
505+
* Ensure a session exists, creating one if needed
506+
* Used when resuming from a saved state where the session may be stale
507+
*/
508+
async ensureSession(cycle: number, title?: string): Promise<void> {
509+
if (this.sessionId) {
510+
// Check if session still exists
511+
try {
512+
await this.client.session.get({ path: { id: this.sessionId } })
513+
this.logger.logVerbose(`Resuming with existing session: ${this.sessionId}`)
514+
return
515+
} catch {
516+
// Session doesn't exist anymore, create a new one
517+
this.logger.logVerbose(`Session ${this.sessionId} no longer exists, creating new session`)
518+
this.sessionId = undefined
519+
}
520+
}
521+
522+
// Create a new session
523+
const sessionTitle = title ?? `Cycle ${cycle}`
524+
const session = await this.client.session.create({
525+
body: { title: sessionTitle },
526+
})
527+
528+
if (!session.data) {
529+
throw new Error("Failed to create session")
530+
}
531+
532+
this.sessionId = session.data.id
533+
this.logger.logVerbose(`Created new session: ${this.sessionId}`)
534+
}
535+
504536
/**
505537
* Shutdown the builder and close the server
506538
*/

src/loop.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,10 @@ async function runBuildPhase(
412412
config: Config,
413413
metrics: Metrics,
414414
): Promise<Metrics> {
415+
// Ensure we have an active session (handles resume from saved state)
416+
await builder.ensureSession(state.cycle, `Cycle ${state.cycle}`)
417+
state.sessionId = builder.getSessionId()
418+
415419
// Read current plan
416420
const planContent = await readFileOrNull(paths.currentPlan)
417421
if (!planContent) {

0 commit comments

Comments
 (0)