Files
opencode-manager/frontend/src/pages/Repos.tsx
T
Chris Scott 632ce132bb fix(frontend): stabilize ScheduleJobDialog render loop and improve accessibility (#315)
Resolve a "Maximum update depth exceeded" render loop in ScheduleJobDialog
while prompt templates are loading, and add accessibility labels across the
frontend. Also unregister the service worker in dev to avoid stale caches.

- ScheduleJobDialog: use a stable EMPTY_TEMPLATES constant and split template
  matching into its own effect keyed on [templates, job, open] instead of
  running inside the init effect that depends on templates
- Add ScheduleJobDialog.loading.test.tsx regression test for the loading state
- serviceWorker: unregister existing registrations and clear caches in DEV so
  stale workers do not serve outdated assets locally
- App: replace shell div with semantic <main>
- SettingsDialog: add sr-only DialogTitle for screen readers
- Add aria-labels to icon-only buttons in back-button, combobox, header,
  GlobalSchedules, and Repos
- index.html: add mobile-web-app-capable meta
2026-07-22 22:09:18 -04:00

78 lines
2.8 KiB
TypeScript

import { useState } from "react";
import { useNavigate } from "react-router-dom";
import { RepoList } from "@/components/repo/RepoList";
import { AddRepoDialog } from "@/components/repo/AddRepoDialog";
import { FileBrowserSheet } from "@/components/file-browser/FileBrowserSheet";
import { Header } from "@/components/ui/header";
import { Button } from "@/components/ui/button";
import { Plus, FolderOpen, CalendarClock } from "lucide-react";
import { PendingActionsGroup } from "@/components/notifications/PendingActionsGroup";
import { useSidebarAction } from "@/hooks/useSidebarAction";
import { useDialogParam } from "@/hooks/useDialogParam";
export function Repos() {
const navigate = useNavigate();
const [addRepoOpen, setAddRepoOpen] = useState(false);
const [fileBrowserOpen, setFileBrowserOpen] = useDialogParam('files');
const handleCloseFileBrowser = () => {
setFileBrowserOpen(false);
};
useSidebarAction('new-repo', () => {
setAddRepoOpen(true);
});
return (
<div className="h-dvh max-h-dvh overflow-hidden bg-gradient-to-br from-background via-background to-background flex flex-col">
<Header>
<div className="flex items-center gap-3">
<Header.Title logo>OpenCode</Header.Title>
</div>
<Header.Actions>
<div className="flex items-center gap-1">
<PendingActionsGroup />
</div>
<Button
variant="ghost"
size="icon"
onClick={() => setFileBrowserOpen(true)}
aria-label="Open files"
className="hidden sm:flex text-muted-foreground hover:text-foreground hover:bg-accent transition-all duration-200 h-8 w-8"
>
<FolderOpen className="w-4 h-4" />
</Button>
<Button
variant="outline"
onClick={() => navigate('/schedules')}
size="sm"
className="hidden sm:flex text-foreground border-border hover:bg-accent transition-all duration-200 hover:scale-105"
>
<CalendarClock className="w-4 h-4 mr-2" />
All Schedules
</Button>
<Button onClick={() => setAddRepoOpen(true)} size="sm">
<Plus className="w-4 h-4 mr-1" />
Repo
</Button>
<span>
<Header.Settings />
</span>
</Header.Actions>
</Header>
<div className="container mx-auto flex-1 pt-2 px-2 min-h-0 overflow-auto pb-[calc(env(safe-area-inset-bottom)+60px)] sm:pb-0">
<RepoList />
</div>
<AddRepoDialog open={addRepoOpen} onOpenChange={setAddRepoOpen} />
<FileBrowserSheet
isOpen={fileBrowserOpen}
onClose={handleCloseFileBrowser}
basePath=""
repoName="Workspace Root"
allowNavigateAboveBase={true}
/>
</div>
);
}