Skip to content

Commit 8b08444

Browse files
fix: hoist assistantDirectory before useAssistantSessionLauncher, drop sessionLoading from skeleton guard
1 parent 0469ab8 commit 8b08444

3 files changed

Lines changed: 21 additions & 6 deletions

File tree

frontend/src/pages/AssistantRedirect.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,17 @@ export function AssistantRedirect() {
6464
navigate(getAssistantSessionListPath(), { replace: true })
6565
}, [navigate])
6666

67+
const assistantDirectory = repo?.fullPath ?? cachedAssistantDirectory
68+
const assistantFileBasePath = assistantDirectory?.split('/').filter(Boolean).at(-1)
69+
6770
const { openAssistant } = useAssistantSessionLauncher({
6871
repoId,
6972
opcodeUrl,
70-
directory: repo?.fullPath,
73+
directory: assistantDirectory,
7174
onNavigate: handleNavigate,
7275
onMissingCachedSession: handleMissingCachedSession,
7376
})
7477

75-
const assistantDirectory = repo?.fullPath ?? cachedAssistantDirectory
76-
const assistantFileBasePath = assistantDirectory?.split('/').filter(Boolean).at(-1)
77-
7878
useSSE(opcodeUrl, assistantDirectory)
7979

8080
const createSessionMutation = useCreateSession(opcodeUrl, assistantDirectory, (session) => {

frontend/src/pages/SessionDetail.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export function SessionDetail() {
132132
const { isConnected, isReconnecting } = useSSE(opcodeUrl, repoDirectory, sessionId);
133133

134134
const { data: rawMessages, isLoading: messagesLoading } = useMessages(opcodeUrl, sessionId, repoDirectory);
135-
const { data: session, isLoading: sessionLoading } = useSession(
135+
const { data: session } = useSession(
136136
opcodeUrl,
137137
sessionId,
138138
repoDirectory,
@@ -493,7 +493,7 @@ export function SessionDetail() {
493493

494494
<div className="relative flex-1 overflow-hidden flex flex-col">
495495
<div key={sessionId} ref={messageContainerRef} className="flex-1 overflow-y-auto overflow-x-hidden overscroll-contain [mask-image:linear-gradient(to_bottom,transparent,black_16px,black)]" style={{ paddingBottom: promptOverlayHeight + inputBottomOffset + PROMPT_OVERLAY_CLEARANCE_PX }}>
496-
{(!repoDirectory && repoLoading) || !repoDirectory || sessionLoading || messagesLoading ? (
496+
{(!repoDirectory && repoLoading) || !repoDirectory || messagesLoading ? (
497497
<MessageSkeleton />
498498
) : opcodeUrl && repoDirectory ? (
499499
<MessageThread

frontend/src/pages/__tests__/SessionDetail.first-load-directory.test.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,4 +258,19 @@ describe('SessionDetail first-load navigation directory', () => {
258258

259259
expect(queryByText('Messages loading skeleton')).toBeNull()
260260
})
261+
262+
it('renders assistant messages while session metadata is still loading', async () => {
263+
mocks.useSession.mockReturnValue({ data: undefined, isLoading: true })
264+
265+
const { queryByText, getByText } = renderSession({
266+
pathname: '/repos/0/sessions/sess-assistant',
267+
state: { directory: '/abs/assistant' },
268+
})
269+
270+
await waitFor(() => {
271+
expect(getByText('Messages rendered')).toBeTruthy()
272+
})
273+
274+
expect(queryByText('Messages loading skeleton')).toBeNull()
275+
})
261276
})

0 commit comments

Comments
 (0)