From df9200880e220e88b5d8f135b424b82185caa1d7 Mon Sep 17 00:00:00 2001 From: Chris Scott <99081550+chriswritescode-dev@users.noreply.github.com> Date: Fri, 23 Oct 2026 20:52:17 -0400 Subject: [PATCH] fix: apply CodeRabbit auto-fixes --- frontend/src/api/opencode.ts | 4 -- .../src/components/model/ModelQuickSelect.tsx | 4 -- .../components/session/ContextUsageMeter.tsx | 4 -- .../components/session/ReconnectingBanner.tsx | 8 ---- .../session/SessionDetailsSheet.test.tsx | 12 +++++ .../session/SessionDetailsSheet.tsx | 10 +--- .../session/SessionPickerDialog.test.tsx | 12 +++++ .../session/SessionPickerDialog.tsx | 11 +---- .../session/SessionPickerSheet.test.tsx | 47 +++++++++++++++++-- .../components/session/SessionPickerSheet.tsx | 9 ++-- .../src/hooks/useSessionPickerRouteScope.ts | 4 -- frontend/src/hooks/useVcsInfo.ts | 11 ----- frontend/src/lib/contextUsage.ts | 16 ------- frontend/src/pages/SessionDetail.tsx | 22 +++++---- .../__tests__/SessionDetail.remote.test.tsx | 2 +- 15 files changed, 87 insertions(+), 89 deletions(-) diff --git a/frontend/src/api/opencode.ts b/frontend/src/api/opencode.ts index e3eb90ac..5d9afd2a 100644 --- a/frontend/src/api/opencode.ts +++ b/frontend/src/api/opencode.ts @@ -37,10 +37,6 @@ export type OpenCodeLocationInfo = Awaited>[number] -/** - * The timestamp a project list sorts and labels on: the server's last-activity time, falling back - * to the record's update time for a project that has never recorded activity. - */ export function projectActivityTimestamp(project: OpenCodeProject): number { return project.time.active || project.time.updated } diff --git a/frontend/src/components/model/ModelQuickSelect.tsx b/frontend/src/components/model/ModelQuickSelect.tsx index 691b4371..40e58808 100644 --- a/frontend/src/components/model/ModelQuickSelect.tsx +++ b/frontend/src/components/model/ModelQuickSelect.tsx @@ -87,10 +87,6 @@ interface ContextUsageStripProps { compactDisabled: boolean } -/** - * Compact context-window strip pinned above the picker header: the tone meter, then one line with the - * used and limit token counts, the percentage, and the session compaction action. - */ function ContextUsageStrip({ usage, onCompact, compactDisabled }: ContextUsageStripProps) { const percentage = usage.usagePercentage const toneClass = CONTEXT_USAGE_TEXT_CLASS[contextUsageTone(percentage)] diff --git a/frontend/src/components/session/ContextUsageMeter.tsx b/frontend/src/components/session/ContextUsageMeter.tsx index 5423a969..d2545f62 100644 --- a/frontend/src/components/session/ContextUsageMeter.tsx +++ b/frontend/src/components/session/ContextUsageMeter.tsx @@ -6,10 +6,6 @@ interface ContextUsageMeterProps { className?: string } -/** - * Two-pixel context-window meter: a muted track with a tone-coloured fill sized to `min(percentage, 100)`. - * Purely decorative, so the surrounding readout carries the accessible label. - */ export function ContextUsageMeter({ percentage, className }: ContextUsageMeterProps) { const width = percentage === null ? 0 : Math.min(percentage, 100) diff --git a/frontend/src/components/session/ReconnectingBanner.tsx b/frontend/src/components/session/ReconnectingBanner.tsx index 208fac94..38198635 100644 --- a/frontend/src/components/session/ReconnectingBanner.tsx +++ b/frontend/src/components/session/ReconnectingBanner.tsx @@ -4,14 +4,6 @@ export interface ReconnectingBannerProps { connected: boolean } -/** - * Full-width strip under the session header that reports a paused event - * stream. It stays hidden until the stream has connected at least once, so a - * first paint before the subscription settles does not read as a dropped - * connection. - * - * @param connected Whether the session's event stream is currently connected. - */ export function ReconnectingBanner({ connected }: ReconnectingBannerProps) { const [hasConnected, setHasConnected] = useState(false) diff --git a/frontend/src/components/session/SessionDetailsSheet.test.tsx b/frontend/src/components/session/SessionDetailsSheet.test.tsx index 0b204dc8..46c4e8cc 100644 --- a/frontend/src/components/session/SessionDetailsSheet.test.tsx +++ b/frontend/src/components/session/SessionDetailsSheet.test.tsx @@ -154,6 +154,18 @@ describe('SessionDetailsSheet', () => { ) }) + it('ignores Enter while an IME composition is active', () => { + const mutation = mockRename() + renderSheet() + + fireEvent.click(screen.getByRole('button', { name: 'Rename' })) + const input = screen.getByLabelText('Session title') + fireEvent.change(input, { target: { value: 'にほんご' } }) + fireEvent.keyDown(input, { key: 'Enter', isComposing: true }) + + expect(mutation.mutate).not.toHaveBeenCalled() + }) + it('cancels editing and resets the rename error', () => { const mutation = mockRename({ error: new Error('nope') }) renderSheet() diff --git a/frontend/src/components/session/SessionDetailsSheet.tsx b/frontend/src/components/session/SessionDetailsSheet.tsx index 801ae06e..5d1b10b7 100644 --- a/frontend/src/components/session/SessionDetailsSheet.tsx +++ b/frontend/src/components/session/SessionDetailsSheet.tsx @@ -40,15 +40,6 @@ function InfoRow({ label, value, mono, leading }: InfoRowProps) { ) } -/** - * Session details shown from the session header title. It lists the title, - * server, project, branch and directory untruncated, and renames the session - * inline so the sheet stays open while the new title lands through the session - * query. It renders as a bottom sheet on mobile and a dialog on desktop. - * - * Dismissal is blocked while a rename is pending, and the mutation error resets - * when the sheet reopens so a failed rename cannot leak into the next open. - */ export function SessionDetailsSheet({ open, onOpenChange, @@ -120,6 +111,7 @@ export function SessionDetailsSheet({ value={draft} onChange={(event) => setDraft(event.target.value)} onKeyDown={(event) => { + if (event.nativeEvent.isComposing) return if (event.key !== 'Enter') return event.preventDefault() save() diff --git a/frontend/src/components/session/SessionPickerDialog.test.tsx b/frontend/src/components/session/SessionPickerDialog.test.tsx index 35c32366..63b74c45 100644 --- a/frontend/src/components/session/SessionPickerDialog.test.tsx +++ b/frontend/src/components/session/SessionPickerDialog.test.tsx @@ -394,6 +394,18 @@ describe('SessionPickerDialog', () => { expect(localStorage.getItem('oc:session-picker:all-projects')).toBeNull() }) + it('leaves the persisted scope preference unchanged on Ctrl+A without a current repo', () => { + localStorage.setItem('oc:session-picker:all-projects', 'false') + + renderPicker({ currentRepo: undefined }) + + fireEvent.keyDown(combobox(), { key: 'a', ctrlKey: true }) + + expect(localStorage.getItem('oc:session-picker:all-projects')).toBe('false') + expect(mocks.lastAllDirectories).toBe(true) + expect(screen.getByRole('tab', { name: 'Sessions', selected: true })).toBeInTheDocument() + }) + it('starts a new session in the current repo from the sessions tab header action', () => { const onNavigate = vi.fn() renderPicker({ onNavigate }) diff --git a/frontend/src/components/session/SessionPickerDialog.tsx b/frontend/src/components/session/SessionPickerDialog.tsx index 521ede24..a438d6b0 100644 --- a/frontend/src/components/session/SessionPickerDialog.tsx +++ b/frontend/src/components/session/SessionPickerDialog.tsx @@ -86,7 +86,6 @@ interface SessionPickerDialogProps { onSelectRemoteSession?: (session: Session, serverId: string) => void onDeleteActiveSession: () => void onSelectRepo: (repo: Repo) => void - /** Navigates to a path the panel produced, such as a new session created from the header action. */ onNavigate: (path: string) => void /** Set on a linked-server route to list that server's sessions instead of Manager repos. */ remote?: RemotePickerScope @@ -569,7 +568,7 @@ interface SessionPickerContentProps { onDeleteActiveSession: () => void allProjects: boolean scopeEnabled: boolean - onToggleAllProjects: () => void + onToggleAllProjects?: () => void switchHint: string searchInputRef: React.RefObject searchTrailing?: React.ReactNode @@ -1212,19 +1211,13 @@ export interface SessionPickerPanelProps { onDeleteActiveSession: () => void onSelectRepo: (repo: Repo) => void onNavigate: (path: string) => void - /** Set on a linked-server route to list that server's sessions instead of Manager repos. */ remote?: RemotePickerScope - /** Lists the linked server's projects on a Projects tab; the desktop dialog leaves it off. */ remoteProjects?: boolean - /** Extra controls rendered at the trailing end of every tab's search bar. */ searchTrailing?: React.ReactNode - /** Hands the add-repository action to the host, which renders the dialog above its own surface. */ onAddRepo?: () => void - /** Renders the dialog title element, which only a Radix Dialog can host. */ renderTitle?: (label: string) => React.ReactNode } -/** The tab strip, search bars, lists and header actions shared by the picker dialog and sheet. */ export function SessionPickerPanel({ open, currentRepo, @@ -1423,7 +1416,7 @@ export function SessionPickerPanel({ onDeleteActiveSession={onDeleteActiveSession} allProjects={allProjects} scopeEnabled={scopeEnabled} - onToggleAllProjects={toggleAllProjects} + onToggleAllProjects={scopeEnabled ? toggleAllProjects : undefined} switchHint={switchHint} searchInputRef={searchInputRef} searchTrailing={sessionsTrailing} diff --git a/frontend/src/components/session/SessionPickerSheet.test.tsx b/frontend/src/components/session/SessionPickerSheet.test.tsx index 62c3a192..2181373c 100644 --- a/frontend/src/components/session/SessionPickerSheet.test.tsx +++ b/frontend/src/components/session/SessionPickerSheet.test.tsx @@ -136,13 +136,19 @@ function repo(id: number, name: string, fullPath: string): Repo { } } -function activeWorkItem(id: string, directory: string): ActiveWorkItem { +function activeWorkItem( + id: string, + directory: string, + server?: { id: string; name: string }, +): ActiveWorkItem { const now = Date.now() return { - key: `1:${id}`, + key: `${server?.id ?? LOCAL_OPENCODE_SERVER_ID}:${id}`, state: 'recent', session: session(id, `Active ${id}`, directory, now), - repo: repo(1, 'alpha', directory), + repo: server ? null : repo(1, 'alpha', directory), + serverId: server?.id ?? null, + serverName: server?.name ?? null, updatedAt: now, path: `/repos/1/sessions/${id}`, } @@ -329,4 +335,39 @@ describe('SessionPickerSheet', () => { expect(screen.getByTestId('location')).toHaveTextContent('/repos/1/sessions/ses_active REPLACE') }) + + it('opens a remote activity row on its own server while the local server is selected', async () => { + mocks.activeWorkGroups = { + needsInput: [], + running: [], + recent: [activeWorkItem('ses_kitchen', '/home/me/app', { id: 'srv_kitchen', name: 'Kitchen' })], + } + + renderSheet() + + fireEvent.mouseDown(screen.getByRole('tab', { name: 'Activity' })) + fireEvent.click(await screen.findByRole('option', { name: /Active ses_kitchen/ })) + + expect(screen.getByTestId('location')).toHaveTextContent( + '/servers/srv_kitchen/sessions/ses_kitchen REPLACE', + ) + }) + + it('opens an activity row of another linked server than the selected one', async () => { + useSidebarServerStore.setState({ serverId: 'srv_kitchen' }) + mocks.activeWorkGroups = { + needsInput: [], + running: [], + recent: [activeWorkItem('ses_hall', '/home/me/hall', { id: 'srv_hall', name: 'Hall' })], + } + + renderSheet() + + fireEvent.mouseDown(screen.getByRole('tab', { name: 'Activity' })) + fireEvent.click(await screen.findByRole('option', { name: /Active ses_hall/ })) + + expect(screen.getByTestId('location')).toHaveTextContent( + '/servers/srv_hall/sessions/ses_hall REPLACE', + ) + }) }) diff --git a/frontend/src/components/session/SessionPickerSheet.tsx b/frontend/src/components/session/SessionPickerSheet.tsx index 547d5b70..2934046a 100644 --- a/frontend/src/components/session/SessionPickerSheet.tsx +++ b/frontend/src/components/session/SessionPickerSheet.tsx @@ -14,12 +14,10 @@ interface SessionPickerSheetProps { onClose: () => void } -/** The session picker in a bottom sheet; every navigation replaces the sheet's history entry. */ export function SessionPickerSheet({ isOpen, onClose }: SessionPickerSheetProps) { const navigate = useNavigate() const [addRepoOpen, setAddRepoOpen] = useState(false) const { currentRepo, activeSessionID, remote } = useSessionPickerRouteScope(isOpen) - const remoteServerId = remote?.serverId const navigateReplacing = useCallback( (path: string) => { @@ -40,15 +38,14 @@ export function SessionPickerSheet({ isOpen, onClose }: SessionPickerSheetProps) ) const handleSelectRemoteSession = useCallback( - (session: Session) => { - if (!remoteServerId) return + (session: Session, serverId: string) => { if (session.id === activeSessionID) { onClose() return } - navigateReplacing(getServerSessionPath(remoteServerId, session.id)) + navigateReplacing(getServerSessionPath(serverId, session.id)) }, - [activeSessionID, navigateReplacing, onClose, remoteServerId], + [activeSessionID, navigateReplacing, onClose], ) const handleDeleteActiveSession = useCallback(() => { diff --git a/frontend/src/hooks/useSessionPickerRouteScope.ts b/frontend/src/hooks/useSessionPickerRouteScope.ts index aa1505a1..f9625292 100644 --- a/frontend/src/hooks/useSessionPickerRouteScope.ts +++ b/frontend/src/hooks/useSessionPickerRouteScope.ts @@ -13,10 +13,6 @@ export interface SessionPickerRouteScope { remote: { serverId: string; serverName?: string; projectDirectory?: string } | undefined } -/** - * Resolves what a session picker opened on the current route should list: the Manager repo of a - * repo route, or the selected linked server and its project directory. - */ export function useSessionPickerRouteScope(enabled: boolean): SessionPickerRouteScope { const { pathname, search } = useLocation() const [selectedServerId] = useSidebarServerSelection() diff --git a/frontend/src/hooks/useVcsInfo.ts b/frontend/src/hooks/useVcsInfo.ts index 2a2e2009..fd2525fd 100644 --- a/frontend/src/hooks/useVcsInfo.ts +++ b/frontend/src/hooks/useVcsInfo.ts @@ -6,16 +6,6 @@ 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, @@ -28,6 +18,5 @@ export function useVcsInfo( queryFn: () => getVcsInfo(directory ?? '', serverId), enabled: enabled && Boolean(directory), retry: false, - staleTime: 60_000, }) } diff --git a/frontend/src/lib/contextUsage.ts b/frontend/src/lib/contextUsage.ts index d5e85f01..9a0bf04e 100644 --- a/frontend/src/lib/contextUsage.ts +++ b/frontend/src/lib/contextUsage.ts @@ -18,20 +18,12 @@ export const CONTEXT_USAGE_BG_CLASS: Record = { destructive: 'bg-destructive', } -/** - * Maps a context-window percentage to a semantic tone: under 50 is `success`, under 80 is `warning`, - * and 80 or more is `destructive`. An unknown percentage falls back to `success`. - */ export function contextUsageTone(percentage: number | null): ContextUsageTone { if (percentage === null || percentage < 50) return 'success' if (percentage < 80) return 'warning' return 'destructive' } -/** - * Abbreviates a token count so it fits a one-line readout: exact below a thousand, whole thousands up - * to a million (`41k`), and millions to at most one decimal (`1M`, `1.3M`). - */ export function formatCompactTokens(tokens: number): string { if (tokens < 1000) return String(tokens) if (tokens < 1000000) { @@ -41,10 +33,6 @@ export function formatCompactTokens(tokens: number): string { return `${Number((tokens / 1000000).toFixed(1))}M` } -/** - * Formats context usage for a compact readout: the percentage of the model's context window when both - * a limit and a percentage are known, otherwise a compact token count such as `41k`. - */ export function formatContextUsage(usage: ContextUsage): string { if (usage.contextLimit !== null && usage.usagePercentage !== null) { return `${usage.usagePercentage}%` @@ -52,10 +40,6 @@ export function formatContextUsage(usage: ContextUsage): string { return formatCompactTokens(usage.totalTokens) } -/** - * Builds the screen-reader description of a context-window readout, e.g. `context 42% used` or, when - * the limit is unknown, `context 12k tokens used`. - */ export function contextUsageAccessibleLabel(usage: ContextUsage): string { if (usage.usagePercentage !== null) { return `context ${usage.usagePercentage}% used` diff --git a/frontend/src/pages/SessionDetail.tsx b/frontend/src/pages/SessionDetail.tsx index e34292f1..5c2640d5 100644 --- a/frontend/src/pages/SessionDetail.tsx +++ b/frontend/src/pages/SessionDetail.tsx @@ -817,16 +817,18 @@ export function SessionDetail() {
- +

+ +

{session?.parentID ? (