Skip to content

Commit 5f2e84a

Browse files
fix: update validation branch for v0.4.0 type changes
- Replace removed `@/control` import with `@/account` in conversation-logger - Cast `sessionID: string` to branded `SessionID` in session routes and conversation-logger
1 parent b294811 commit 5f2e84a

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

packages/opencode/src/server/routes/session.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@ const log = Log.create({ service: "server" })
2525
function resolvePrompt(sessionID: string, body: Omit<SessionPrompt.PromptInput, "sessionID">) {
2626
const textPart = body.parts?.find((p: { type: string }) => p.type === "text")
2727
const text = (textPart && "text" in textPart ? (textPart.text as string) : "").trimStart()
28+
const typedSessionID = sessionID as SessionID
2829

2930
if (text.startsWith("/validate")) {
3031
return SessionPrompt.command({
31-
sessionID,
32+
sessionID: typedSessionID,
3233
command: "validate",
3334
arguments: text.slice("/validate".length).trim(),
3435
model: body.model ? `${body.model.providerID}/${body.model.modelID}` : undefined,
@@ -38,7 +39,7 @@ function resolvePrompt(sessionID: string, body: Omit<SessionPrompt.PromptInput,
3839
})
3940
}
4041

41-
return SessionPrompt.prompt({ ...body, sessionID })
42+
return SessionPrompt.prompt({ ...body, sessionID: typedSessionID })
4243
}
4344

4445
export const SessionRoutes = lazy(() =>

packages/opencode/src/session/conversation-logger.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { Bus } from "@/bus"
22
import { Config } from "@/config/config"
3-
import { Control } from "@/control"
3+
import { Account } from "@/account"
44
import { Log } from "@/util/log"
55
import { Session } from "."
6+
import type { SessionID } from "./schema"
67
import { SessionStatus } from "./status"
78
import type { MessageV2 } from "./message-v2"
89

@@ -80,12 +81,12 @@ function normalizePart(part: MessageV2.Part): NormalizedPart | null {
8081

8182
async function logConversation(sessionID: string): Promise<void> {
8283
const cfg = await Config.get()
83-
const userID = Control.account()?.email ?? cfg.username ?? "unknown"
84+
const userID = Account.active()?.email ?? cfg.username ?? "unknown"
8485

8586
// Fetch recent messages and find the last user+assistant pair.
8687
// Multi-step sessions (e.g. internet questions with multiple tool-call rounds) create
8788
// one assistant message per loop step, so limit:2 would return only assistant messages.
88-
const msgs = await Session.messages({ sessionID, limit: 500 })
89+
const msgs = await Session.messages({ sessionID: sessionID as SessionID, limit: 500 })
8990

9091
const userMsg = msgs.findLast((m) => m.info.role === "user")
9192
if (!userMsg) return

0 commit comments

Comments
 (0)