From ccb6e96e4bd9303f3ed90a336fbc70a45e5bdd76 Mon Sep 17 00:00:00 2001 From: Adam <2363879+adamdotdevin@users.noreply.github.com> Date: Thu, 22 Jan 2026 12:40:57 -0600 Subject: [PATCH 1/2] fix(app): windows path handling issues --- .opencode/.gitignore | 5 +++-- packages/util/src/path.ts | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.opencode/.gitignore b/.opencode/.gitignore index 00bfdfda298..25cb250b7cc 100644 --- a/.opencode/.gitignore +++ b/.opencode/.gitignore @@ -1,3 +1,4 @@ -plans/ -bun.lock +node_modules package.json +bun.lock +.gitignore \ No newline at end of file diff --git a/packages/util/src/path.ts b/packages/util/src/path.ts index 2da8028b46a..1ac106f2186 100644 --- a/packages/util/src/path.ts +++ b/packages/util/src/path.ts @@ -7,7 +7,8 @@ export function getFilename(path: string | undefined) { export function getDirectory(path: string | undefined) { if (!path) return "" - const parts = path.split("/") + const trimmed = path.replace(/[\/\\]+$/, "") + const parts = trimmed.split(/[\/\\]/) return parts.slice(0, parts.length - 1).join("/") + "/" } From ca62be8f2cce344220c47a74ae60531d11207673 Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Thu, 22 Jan 2026 14:05:50 -0500 Subject: [PATCH 2/2] fix(tui): preserve agent state after compaction Track lastUserMessage().id changes instead of session ID changes when syncing agent state. Previously, compaction would create a new user message with the current agent mode (e.g., "plan"), but since the session ID stayed the same, the agent state was never synced from it. Fixes #8349 --- .../src/cli/cmd/tui/component/prompt/index.tsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx b/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx index e19c8b70982..fdcae41049d 100644 --- a/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx +++ b/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx @@ -130,16 +130,16 @@ export function Prompt(props: PromptProps) { interrupt: 0, }) - // Initialize agent/model/variant from last user message when session changes - let syncedSessionID: string | undefined + // Initialize agent/model/variant from last user message when it changes. + // This handles both initial session load AND compaction (where a new user + // message is created with the current agent state). + let syncedMessageID: string | undefined createEffect(() => { - const sessionID = props.sessionID const msg = lastUserMessage() + if (!msg) return - if (sessionID !== syncedSessionID) { - if (!sessionID || !msg) return - - syncedSessionID = sessionID + if (msg.id !== syncedMessageID) { + syncedMessageID = msg.id // Only set agent if it's a primary agent (not a subagent) const isPrimaryAgent = local.agent.list().some((x) => x.name === msg.agent)