feat(frontend): open session details from the header

Pressing the session title opens a details sheet with server, project, branch and directory and inline rename. Linked-server sessions show a server icon and their branch, child sessions show a parent session pill, a banner marks paused live updates while the stream reconnects, and the header context indicator is removed now that usage lives on the model pill.
This commit is contained in:
Chris Scott committed 2026-10-23 20:18:27 -04:00
1 parent 52162d5c4a
commit d99fcc268e
20 files changed
+732 -418

No files matched your search

@@ -8,7 +8,7 @@ import type {
V2Event,
} from '@opencode-manager/shared/opencode'
import { useSessionTranscript } from './useSessionTranscript'
import { ContextUsageIndicator } from '@/components/session/ContextUsageIndicator'
import { useContextUsage } from './useContextUsage'
import { OpenCodeServerProvider } from '@/contexts/OpenCodeServerContext'
import { applySessionEvent, emptySessionTranscript } from '@/lib/session-projection'
import type { TranscriptCache } from '@/lib/session-projection'
@@ -1129,13 +1129,8 @@ describe('useSessionTranscript', () => {
function PageConsumers() {
const { messages } = useSessionTranscript(SESSION_ID, DIRECTORY)
pageMessages.current = messages
return (
<ContextUsageIndicator
directory={DIRECTORY}
sessionID={SESSION_ID}
isConnected
/>
)
useContextUsage(SESSION_ID, DIRECTORY)
return null
}
render(<PageConsumers />, { wrapper: createWrapper(queryClient) })
+62
View File
@@ -0,0 +1,62 @@
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { renderHook, waitFor } from '@testing-library/react'
import type { ReactNode } from 'react'
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { useVcsInfo } from './useVcsInfo'
const mocks = vi.hoisted(() => ({ getVcsInfo: vi.fn() }))
vi.mock('@/api/opencode', () => ({ getVcsInfo: mocks.getVcsInfo }))
function createWrapper() {
const queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } })
return ({ children }: { children: ReactNode }) => (
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
)
}
describe('useVcsInfo', () => {
beforeEach(() => {
mocks.getVcsInfo.mockReset()
mocks.getVcsInfo.mockResolvedValue({
branch: { current: 'feat/header', default: 'main' },
})
})
it('reads the branch of the directory from the given server', async () => {
const { result } = renderHook(() => useVcsInfo('/abs/repo', 'srv_kitchen'), {
wrapper: createWrapper(),
})
await waitFor(() => expect(result.current.data?.branch.current).toBe('feat/header'))
expect(mocks.getVcsInfo).toHaveBeenCalledWith('/abs/repo', 'srv_kitchen')
})
it('stays disabled without a directory', () => {
const { result } = renderHook(() => useVcsInfo(undefined, 'srv_kitchen'), {
wrapper: createWrapper(),
})
expect(result.current.fetchStatus).toBe('idle')
expect(mocks.getVcsInfo).not.toHaveBeenCalled()
})
it('stays disabled when the caller disables it', () => {
renderHook(() => useVcsInfo('/abs/repo', 'srv_kitchen', { enabled: false }), {
wrapper: createWrapper(),
})
expect(mocks.getVcsInfo).not.toHaveBeenCalled()
})
it('shares one cache entry between callers of the same directory and server', async () => {
const wrapper = createWrapper()
const first = renderHook(() => useVcsInfo('/abs/repo', 'srv_kitchen'), { wrapper })
const second = renderHook(() => useVcsInfo('/abs/repo', 'srv_kitchen'), { wrapper })
await waitFor(() => expect(first.result.current.data?.branch.current).toBe('feat/header'))
await waitFor(() => expect(second.result.current.data?.branch.current).toBe('feat/header'))
expect(mocks.getVcsInfo).toHaveBeenCalledTimes(1)
})
})
+33
View File
@@ -0,0 +1,33 @@
import { useQuery } from '@tanstack/react-query'
import { getVcsInfo } from '@/api/opencode'
import { serverScopedKey } from '@/lib/serverScope'
export interface UseVcsInfoOptions {
enabled?: boolean
}
/**
* Reads the version-control info of a directory through the OpenCode server in
* scope. The query is keyed by directory and server id, so the session header,
* the project header and the source control panel share one cached read, and a
* linked server reports its own checkout rather than the Manager's.
*
* @param directory Absolute checkout directory; the query stays disabled without one.
* @param serverId Linked server to read from, or the local Manager when omitted.
* @param options.enabled Whether to read the info; defaults to `true`.
*/
export function useVcsInfo(
directory: string | undefined,
serverId: string | undefined,
options: UseVcsInfoOptions = {},
) {
const { enabled = true } = options
return useQuery({
queryKey: [...serverScopedKey(['opencode', 'vcs', directory ?? ''], serverId), 'info'],
queryFn: () => getVcsInfo(directory ?? '', serverId),
enabled: enabled && Boolean(directory),
retry: false,
staleTime: 60_000,
})
}