Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
bd51c51
fix(app): keep session timeline stable across worktree exit
Astro-Han May 4, 2026
af87f30
fix(app): address timeline stability review
Astro-Han May 4, 2026
0d35251
test(app): cover timeline stability review cases
Astro-Han May 4, 2026
a26ab8e
fix(app): refresh session actions after directory changes
Astro-Han May 4, 2026
9139287
test(app): tighten timeline cache diagnostics
Astro-Han May 4, 2026
280aa03
fix(app): document followup queue migration boundary
Astro-Han May 4, 2026
1dd3fa5
fix(app): keep timeline cache identity stable
Astro-Han May 4, 2026
90bc76a
fix(app): bind review artifacts to source directory
Astro-Han May 5, 2026
12b2e11
fix(app): scope local model cache by directory
Astro-Han May 5, 2026
3bffa2e
fix(app): restore model selection on directory change
Astro-Han May 5, 2026
cb6d2f0
test(app): cover local model selection boundaries
Astro-Han May 5, 2026
01b6f96
fix(app): gate session actions during cache hydration
Astro-Han May 5, 2026
800d800
fix(app): gate session actions on hydrated state
Astro-Han May 5, 2026
f5608a5
fix(app): track session status hydration separately
Astro-Han May 5, 2026
a4003de
fix(app): harden session action readiness
Astro-Han May 5, 2026
b110195
fix(app): degrade session status readiness on failure
Astro-Han May 5, 2026
33edf35
fix(app): preserve active status during degraded bootstrap
Astro-Han May 5, 2026
5b0b9ec
fix(app): wait for local model cache hydration
Astro-Han May 5, 2026
9d2245f
fix(app): resync session model after local cache ready
Astro-Han May 5, 2026
471d3d9
fix(app): isolate review and status hydration races
Astro-Han May 5, 2026
b8949b5
fix(app): handle directory status and store pins
Astro-Han May 5, 2026
7b106b7
fix: gate session actions on directory readiness
Astro-Han May 5, 2026
13f8b52
fix: avoid permanent session action locks
Astro-Han May 5, 2026
94e799d
fix: separate submit and session action readiness
Astro-Han May 5, 2026
c8dcadc
fix: gate submit readiness separately from stop actions
Astro-Han May 5, 2026
ee84e79
fix: keep disabled prompt keys blocked
Astro-Han May 5, 2026
3531bfa
fix: handle local and sync readiness edge cases
Astro-Han May 5, 2026
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
18 changes: 9 additions & 9 deletions packages/app/src/pages/directory-layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@ import { DataProvider } from "@opencode-ai/ui/context"
import { showToast } from "@opencode-ai/ui/toast"
import { base64Encode } from "@opencode-ai/util/encode"
import { useLocation, useNavigate, useParams } from "@solidjs/router"
import { createEffect, createMemo, type ParentProps, Show } from "solid-js"
import { createEffect, createMemo, type Accessor, type ParentProps, Show } from "solid-js"
import { useLanguage } from "@/context/language"
import { LocalProvider } from "@/context/local"
import { SDKProvider } from "@/context/sdk"
import { SyncProvider, useSync } from "@/context/sync"
import { decode64 } from "@/utils/base64"

function DirectoryDataProvider(props: ParentProps<{ directory: string }>) {
function DirectoryDataProvider(props: ParentProps<{ directory: Accessor<string> }>) {
const location = useLocation()
const navigate = useNavigate()
const params = useParams()
const sync = useSync()
const slug = createMemo(() => base64Encode(props.directory))
const slug = createMemo(() => base64Encode(props.directory()))

createEffect(() => {
const next = sync.data.path.directory
if (!next || next === props.directory) return
if (!next || next === props.directory()) return
const path = location.pathname.slice(slug().length + 1)
navigate(`/${base64Encode(next)}${path}${location.search}${location.hash}`, { replace: true })
})
Expand All @@ -32,7 +32,7 @@ function DirectoryDataProvider(props: ParentProps<{ directory: string }>) {
return (
<DataProvider
data={sync.data}
directory={props.directory}
directory={props.directory()}
onNavigateToSession={(sessionID: string) => navigate(`/${slug()}/session/${sessionID}`)}
onSessionHref={(sessionID: string) => `/${slug()}/session/${sessionID}`}
>
Expand Down Expand Up @@ -70,11 +70,11 @@ export default function Layout(props: ParentProps) {
})

return (
<Show when={resolved()} keyed>
{(resolved) => (
<SDKProvider directory={() => resolved}>
<Show when={resolved()}>
{(directory) => (
<SDKProvider directory={directory}>
<SyncProvider>
<DirectoryDataProvider directory={resolved}>
<DirectoryDataProvider directory={directory}>
Comment thread
Astro-Han marked this conversation as resolved.
Resolved
{props.children}
</DirectoryDataProvider>
</SyncProvider>
Expand Down
4 changes: 2 additions & 2 deletions packages/app/src/pages/session.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ export default function Page() {

const timelineInteraction = createSessionTimelineInteraction({
routeSessionID: () => params.id,
sessionKey,
sessionKey: timelineSessionKey,
sessionID: timelineSessionID,
messagesReady: timelineMessagesReady,
loadedMessages: () => timelineMessages().length,
Expand Down Expand Up @@ -570,7 +570,7 @@ export default function Page() {
setMobileTab={setMobileTab}
language={language}
routeSessionID={params.id}
routeReady={timeline.routeMessagesReady()}
routeReady={timelineMessagesReady()}
transitioning={timeline.transitioning()}
timelineSessionID={timelineSessionID()}
timelineSessionKey={timelineSessionKey()}
Expand Down
11 changes: 11 additions & 0 deletions packages/app/src/pages/session/session-main-view.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ describe("shouldShowSessionOpeningState", () => {
).toBe(false)
})

test("does not replace an already-ready same-session timeline during a transient cache miss", () => {
expect(
shouldShowSessionOpeningState({
activeSessionID: "ses_target",
routeSessionID: "ses_target",
routeReady: true,
timelineSessionID: "ses_target",
}),
).toBe(false)
})

test("does not show loading for a mismatched timeline identity", () => {
expect(
shouldShowSessionOpeningState({
Expand Down
4 changes: 1 addition & 3 deletions packages/app/src/pages/session/session-main-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,7 @@ export function SessionMainView(props: {
</Match>
<Match
when={
props.activeSessionID && props.timelineSessionID && props.timelineMessagesReady
? props.timelineSessionID
: undefined
props.activeSessionID && props.timelineSessionID ? props.timelineSessionID : undefined
}
>
<MessageTimeline
Expand Down
64 changes: 52 additions & 12 deletions packages/app/src/pages/session/session-view-controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ describe("createSessionViewController", () => {
})

expect(controller.route.id()).toBe("ses_source")
expect(controller.route.key()).toBe("repo/ses_source")
expect(controller.route.key()).toBe("ses_source")
expect(controller.route.ready()).toBe(true)
expect(controller.visible.id()).toBe("ses_source")
expect(controller.visible.key()).toBe("repo/ses_source")
expect(controller.visible.key()).toBe("ses_source")
expect(controller.visible.ready()).toBe(true)
expect(controller.transitioning()).toBe(false)

Expand All @@ -32,10 +32,10 @@ describe("createSessionViewController", () => {
})

expect(controller.route.id()).toBe("ses_target")
expect(controller.route.key()).toBe("repo/ses_target")
expect(controller.route.key()).toBe("ses_target")
expect(controller.route.ready()).toBe(false)
expect(controller.visible.id()).toBe("ses_target")
expect(controller.visible.key()).toBe("repo/ses_target")
expect(controller.visible.key()).toBe("ses_target")
expect(controller.visible.ready()).toBe(false)
expect(controller.transitioning()).toBe(true)

Expand All @@ -57,8 +57,8 @@ describe("nextSessionViewState", () => {
routeReady: false,
visibleSessionID: "ses_target",
transitioning: true,
routeSessionKey: "repo/ses_target",
visibleSessionKey: "repo/ses_target",
routeSessionKey: "ses_target",
visibleSessionKey: "ses_target",
})

const ready = nextSessionViewState({
Expand All @@ -72,8 +72,8 @@ describe("nextSessionViewState", () => {
routeReady: true,
visibleSessionID: "ses_target",
transitioning: false,
routeSessionKey: "repo/ses_target",
visibleSessionKey: "repo/ses_target",
routeSessionKey: "ses_target",
visibleSessionKey: "ses_target",
})
})

Expand All @@ -85,9 +85,9 @@ describe("nextSessionViewState", () => {
})

expect(next.routeSessionID).toBeUndefined()
expect(next.routeSessionKey).toBe("repo")
expect(next.routeSessionKey).toBe("")
expect(next.visibleSessionID).toBeUndefined()
expect(next.visibleSessionKey).toBe("repo")
expect(next.visibleSessionKey).toBe("")
expect(next.routeReady).toBe(true)
expect(next.transitioning).toBe(false)
})
Expand All @@ -104,8 +104,48 @@ describe("nextSessionViewState", () => {
routeReady: false,
visibleSessionID: "ses_target",
transitioning: true,
routeSessionKey: "repo-b/ses_target",
visibleSessionKey: "repo-b/ses_target",
routeSessionKey: "ses_target",
visibleSessionKey: "ses_target",
})
})

test("keeps the same timeline identity and ready state across a transient directory cache miss", () => {
const ready = nextSessionViewState({
directory: "repo-worktree",
routeSessionID: "ses_target",
routeMessagesReady: true,
})

const next = nextSessionViewState({
directory: "repo-root",
routeSessionID: "ses_target",
routeMessagesReady: false,
previous: ready,
})

expect(next.routeSessionKey).toBe("ses_target")
expect(next.visibleSessionKey).toBe("ses_target")
expect(next.routeReady).toBe(true)
expect(next.transitioning).toBe(false)
})

test("does not keep ready state when switching to another session", () => {
const ready = nextSessionViewState({
directory: "repo",
routeSessionID: "ses_source",
routeMessagesReady: true,
})

const next = nextSessionViewState({
directory: "repo",
routeSessionID: "ses_target",
routeMessagesReady: false,
previous: ready,
})

expect(next.routeSessionID).toBe("ses_target")
expect(next.visibleSessionID).toBe("ses_target")
expect(next.routeReady).toBe(false)
expect(next.transitioning).toBe(true)
})
})
28 changes: 22 additions & 6 deletions packages/app/src/pages/session/session-view-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ export type SessionViewStateInput = {
directory: string
routeSessionID: string | undefined
routeMessagesReady: boolean
previous?: SessionViewState
}

export type SessionViewState = {
routeSessionID: string | undefined
routeReady: boolean
visibleSessionID: string | undefined
transitioning: boolean
routeSessionKey: string
visibleSessionKey: string
}

export type SessionViewControllerInput = {
Expand All @@ -12,33 +22,39 @@ export type SessionViewControllerInput = {
routeMessagesReady: Accessor<boolean>
}

export function sessionKey(input: { directory: string; sessionID: string | undefined }) {
return `${input.directory}${input.sessionID ? `/${input.sessionID}` : ""}`
export function sessionKey(input: { sessionID: string | undefined }) {
return input.sessionID ?? ""
}

export function nextSessionViewState(input: SessionViewStateInput) {
const routeReady = !input.routeSessionID || input.routeMessagesReady
const sameSession =
input.previous?.routeSessionID === input.routeSessionID &&
input.previous?.visibleSessionID === input.routeSessionID &&
!!input.routeSessionID
const keepReady = sameSession && !!input.previous?.routeReady && !input.routeMessagesReady
const routeReady = !input.routeSessionID || input.routeMessagesReady || keepReady
const visibleSessionID = input.routeSessionID

return {
routeSessionID: input.routeSessionID,
routeReady,
visibleSessionID,
transitioning: !routeReady,
routeSessionKey: sessionKey({ directory: input.directory, sessionID: input.routeSessionID }),
visibleSessionKey: sessionKey({ directory: input.directory, sessionID: visibleSessionID }),
routeSessionKey: sessionKey({ sessionID: input.routeSessionID }),
visibleSessionKey: sessionKey({ sessionID: visibleSessionID }),
}
}

export function createSessionViewController(input: SessionViewControllerInput) {
type State = ReturnType<typeof nextSessionViewState> & { directory: string }
type State = SessionViewState & { directory: string }
const state = createMemo((current: State | undefined): State => {
const directory = input.directory()
return {
...nextSessionViewState({
directory,
routeSessionID: input.routeSessionID(),
routeMessagesReady: input.routeMessagesReady(),
previous: current,
}),
directory,
}
Expand Down
67 changes: 67 additions & 0 deletions packages/app/src/pages/session/use-session-timeline-data.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { describe, expect, test } from "bun:test"
import type { Message } from "@opencode-ai/sdk/v2/client"
import { readTimelineMessages } from "./use-session-timeline-data"

const userMessage = (id: string): Message =>
({
id,
role: "user",
sessionID: "ses_target",
time: { created: 1 },
}) as Message

describe("readTimelineMessages", () => {
test("keeps last-good messages for the same session when the current store briefly loses its cache", () => {
const loaded = [userMessage("msg_1"), userMessage("msg_2")]
const ready = readTimelineMessages({
sessionID: "ses_target",
raw: loaded,
lastGood: undefined,
})

const missing = readTimelineMessages({
sessionID: "ses_target",
raw: undefined,
lastGood: ready.lastGood,
})

expect(missing.messages).toBe(loaded)
expect(missing.lastGood).toBe(ready.lastGood)
})

test("does not reuse last-good messages after switching to another session", () => {
const loaded = [userMessage("msg_1")]
const ready = readTimelineMessages({
sessionID: "ses_source",
raw: loaded,
lastGood: undefined,
})

const missing = readTimelineMessages({
sessionID: "ses_target",
raw: undefined,
lastGood: ready.lastGood,
})

expect(missing.messages).toEqual([])
expect(missing.lastGood).toBe(ready.lastGood)
})

test("clears last-good messages when there is no active session", () => {
const loaded = [userMessage("msg_1")]
const ready = readTimelineMessages({
sessionID: "ses_source",
raw: loaded,
lastGood: undefined,
})

const missing = readTimelineMessages({
sessionID: undefined,
raw: undefined,
lastGood: ready.lastGood,
})

expect(missing.messages).toEqual([])
expect(missing.lastGood).toBeUndefined()
})
})
32 changes: 31 additions & 1 deletion packages/app/src/pages/session/use-session-timeline-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,29 @@ import { syncSessionModel } from "@/pages/session/session-model-helpers"
import { diffs as list } from "@/utils/diffs"
import { same } from "@/utils/same"

type LastGoodMessages = { sessionID: string; messages: ReturnType<typeof readSessionMessages> } | undefined

export function readTimelineMessages(input: {
sessionID: string | undefined
raw: unknown
lastGood: LastGoodMessages
}): { messages: ReturnType<typeof readSessionMessages>; lastGood: LastGoodMessages } {
if (!input.sessionID) {
return { messages: emptyMessages, lastGood: undefined }
}

if (input.raw !== undefined) {
const messages = readSessionMessages(input.raw)
return { messages, lastGood: { sessionID: input.sessionID, messages } }
}

if (input.lastGood?.sessionID === input.sessionID) {
return { messages: input.lastGood.messages, lastGood: input.lastGood }
}

return { messages: emptyMessages, lastGood: input.lastGood }
}

export function createSessionTimelineData(input: {
directory: () => string
routeSessionID: () => string | undefined
Expand Down Expand Up @@ -48,10 +71,17 @@ export function createSessionTimelineData(input: {
return input.sync.session.get(id)
})
const isChildSession = createMemo(() => !!sessionInfo()?.parentID)
let lastGoodMessages: LastGoodMessages
const messages = createMemo(
() => {
const id = sessionID()
return readSessionMessages(id ? input.sync.data.message[id] : undefined)
const next = readTimelineMessages({
sessionID: id,
raw: id ? input.sync.data.message[id] : undefined,
lastGood: lastGoodMessages,
})
lastGoodMessages = next.lastGood
return next.messages
},
emptyMessages,
{ equals: same },
Expand Down
Loading