Skip to content
Open
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 .opencode/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
plans/
bun.lock
node_modules
package.json
bun.lock
.gitignore
14 changes: 7 additions & 7 deletions packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion packages/util/src/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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("/") + "/"
}

Expand Down