fix: apply CodeRabbit auto-fixes

This commit is contained in:
Chris Scott committed 2026-10-23 20:52:17 -04:00
1 parent d99fcc268e
commit df9200880e
15 files changed
+87 -89

No files matched your search

@@ -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)]
@@ -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)
@@ -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)
@@ -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()
@@ -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()
@@ -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 })
@@ -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<HTMLInputElement | null>
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}
@@ -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',
)
})
})
@@ -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(() => {