fix(frontend): address CodeRabbit review findings on the transcript branch

- wrap long retry errors instead of truncating them
- keep the server switcher in the home header for the local server too
- accept trailing-slash session detail routes in isSessionDetailRoute
This commit is contained in:
Chris Scott committed 2026-10-21 23:41:12 -04:00
1 parent 8d8960849e
commit 276bc1b920
5 files changed
+15 -8

No files matched your search

@@ -31,7 +31,7 @@ export const RetryPart = memo(function RetryPart({ retry }: RetryPartProps) {
}, [nextTimestamp])
return (
<div className="my-1 flex min-w-0 items-center gap-2 text-xs">
<div className="my-1 flex min-w-0 flex-wrap items-center gap-2 text-xs">
<RefreshCw
className="w-3.5 h-3.5 flex-shrink-0 text-warning animate-spin"
style={{ animationDuration: '2s' }}
@@ -43,7 +43,7 @@ export const RetryPart = memo(function RetryPart({ retry }: RetryPartProps) {
<span className="text-warning/80">(retrying...)</span>
)}
<span aria-hidden="true" className="text-muted-foreground">·</span>
<span className="min-w-0 truncate text-muted-foreground">{retry.error.message}</span>
<span className="min-w-0 break-words text-muted-foreground">{retry.error.message}</span>
</div>
)
})
+5
View File
@@ -217,6 +217,11 @@ describe('isSessionDetailRoute', () => {
expect(isSessionDetailRoute('/servers/https%3A%2F%2Fhost/sessions/ses_abc')).toBe(true);
});
it('matches trailing-slash session detail routes', () => {
expect(isSessionDetailRoute('/repos/42/sessions/abc/')).toBe(true);
expect(isSessionDetailRoute('/servers/srv_kitchen/sessions/ses_abc/')).toBe(true);
});
it('rejects everything else', () => {
expect(isSessionDetailRoute('/')).toBe(false);
expect(isSessionDetailRoute('/repos/42')).toBe(false);
+2 -1
View File
@@ -66,7 +66,8 @@ export function parseServerSessionRoute(pathname: string): { serverId: string; s
}
export function isSessionDetailRoute(pathname: string): boolean {
return /^\/repos\/[^/]+\/sessions\/[^/]+$/.test(pathname) || parseServerSessionRoute(pathname) !== null;
const normalizedPathname = pathname.replace(/\/+$/, '');
return /^\/repos\/[^/]+\/sessions\/[^/]+$/.test(normalizedPathname) || parseServerSessionRoute(normalizedPathname) !== null;
}
export function parseRepoRoute(pathname: string): { repoId: number | null; section: string | null; sessionId: string | null } {
+2 -3
View File
@@ -40,7 +40,7 @@ export function Repos() {
<div className="flex items-center gap-1">
<PendingActionsGroup />
</div>
{isLocalServer ? (
{isLocalServer && (
<Button
variant="ghost"
size="icon"
@@ -50,9 +50,8 @@ export function Repos() {
>
<FolderOpen className="w-4 h-4" />
</Button>
) : (
<LinkedServersNav variant="header" />
)}
<LinkedServersNav variant="header" />
<Button
variant="outline"
onClick={() => navigate('/schedules')}
+4 -2
View File
@@ -163,10 +163,12 @@ describe('Repos', () => {
expect(within(switcher).getByRole('img', { name: 'Connected' })).toBeInTheDocument()
})
it('does not show the server switcher in the header for the local server', () => {
it('shows the server switcher on the local server and keeps local-only actions', () => {
renderRepos()
expect(screen.queryByRole('button', { name: /Switch server/ })).not.toBeInTheDocument()
expect(screen.getByRole('button', { name: 'Switch server, current: OC Manager' })).toBeInTheDocument()
expect(screen.getByRole('button', { name: 'Repo' })).toBeInTheDocument()
expect(screen.getByRole('button', { name: 'Open files' })).toBeInTheDocument()
})
it('switches servers and opens server settings from the header dropdown', async () => {