Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ DEBUG=false
# AUTH_SECRET=

# Trusted origins for authentication (comma-separated)
# Add your server's external URL when accessing remotely
# AUTH_TRUSTED_ORIGINS=http://localhost:5173,http://localhost:5003
# Add your server's external URL when accessing remotely. localhost and
# 127.0.0.1 are distinct browser origins, so both are listed.
# AUTH_TRUSTED_ORIGINS=http://localhost:5173,http://localhost:5003,http://127.0.0.1:5173,http://127.0.0.1:5003

# Admin Account (optional - for pre-configured single-user mode)
# When set, admin user is created on first startup and self-registration is disabled
Expand Down
49 changes: 49 additions & 0 deletions backend/src/db/change-walkthroughs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import type { Database } from 'bun:sqlite'
import { ChangeWalkthroughSchema, type ChangeWalkthrough } from '@opencode-manager/shared/schemas'

interface ChangeWalkthroughRow {
session_id: string
diff_hash: string
payload: string
created_at: number
}

export function ensureChangeWalkthroughTable(db: Database): void {
db.run(`
CREATE TABLE IF NOT EXISTS change_walkthroughs (
session_id TEXT PRIMARY KEY,
diff_hash TEXT NOT NULL,
payload TEXT NOT NULL,
created_at INTEGER NOT NULL
)
`)
}

export function getChangeWalkthrough(db: Database, sessionId: string): ChangeWalkthrough | null {
const row = db
.prepare('SELECT session_id, diff_hash, payload, created_at FROM change_walkthroughs WHERE session_id = ?')
.get(sessionId) as ChangeWalkthroughRow | undefined
if (!row) {
return null
}
try {
return ChangeWalkthroughSchema.parse(JSON.parse(row.payload))
} catch {
return null
}
}

export function deleteChangeWalkthrough(db: Database, sessionId: string): void {
db.prepare('DELETE FROM change_walkthroughs WHERE session_id = ?').run(sessionId)
}

export function saveChangeWalkthrough(db: Database, walkthrough: ChangeWalkthrough): void {
db.prepare(`
INSERT INTO change_walkthroughs(session_id, diff_hash, payload, created_at)
VALUES(?,?,?,?)
ON CONFLICT(session_id) DO UPDATE SET
diff_hash = excluded.diff_hash,
payload = excluded.payload,
created_at = excluded.created_at
`).run(walkthrough.sessionId, walkthrough.diffHash, JSON.stringify(walkthrough), walkthrough.createdAt)
}
14 changes: 14 additions & 0 deletions backend/src/db/migrations/202610061700-multi-run-fusions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { Migration } from '../migration-runner'
import { ensureMultiRunFusionTable } from '../multi-runs'

const migration: Migration = {
id: '202610061700-multi-run-fusions',
up(db) {
ensureMultiRunFusionTable(db)
},
down(db) {
db.run('DROP TABLE IF EXISTS multi_run_fusions')
},
}

export default migration
14 changes: 14 additions & 0 deletions backend/src/db/migrations/202610061701-change-walkthroughs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { Migration } from '../migration-runner'
import { ensureChangeWalkthroughTable } from '../change-walkthroughs'

const migration: Migration = {
id: '202610061701-change-walkthroughs',
up(db) {
ensureChangeWalkthroughTable(db)
},
down(db) {
db.run('DROP TABLE IF EXISTS change_walkthroughs')
},
}

export default migration
4 changes: 4 additions & 0 deletions backend/src/db/migrations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import migration025 from './025-session-permission-modes'
import migration026 from './026-session-goals'
import migration027 from './027-multi-runs'
import migration202610061345 from './202610061345-schedule-workspace-mode'
import migration202610061700 from './202610061700-multi-run-fusions'
import migration202610061701 from './202610061701-change-walkthroughs'

export const allMigrations: Migration[] = [
migration001,
Expand Down Expand Up @@ -57,4 +59,6 @@ export const allMigrations: Migration[] = [
migration026,
migration027,
migration202610061345,
migration202610061700,
migration202610061701,
]
Loading
Loading