open-swe/ui/src/routes/__root.tsx
Johannes du Plessis 911c835c2a
feat: chat with your PR on the review page (#1534)
* feat: chat with your PR on the review page

Add a sandbox-less `chat` graph that answers questions about a single PR
from its diff, the published review findings, and read-only GitHub access.

- agent/chat.py: deepagents graph, no sandbox (default StateBackend, file
  mutation + execute tools excluded). PR context is seeded as virtual files
  under /pr/; a repo-scoped App token is resolved in-graph.
- tools: read_repo_file, search_repo_code, list_review_findings.
- dashboard/review_chat_api.py + routes: per-user chat thread, LangGraph
  stream/commands/state/history proxy pinned to the chat assistant, seeds
  diff/findings/overview on first run. Gated by repo access.
- UI: Chat tab wired to a chat-scoped StreamProvider (replaces Coming Soon).

* feat: admin setting for review-chat default model

Add a 'Open SWE Review Chat' default to team settings (default_chat_model /
default_chat_reasoning_effort). get_team_default_model("chat") inherits the
Agent default when unset; the chat graph resolves through it. Admin RolePicker
gains an 'Agent default' inherit option that clears the override.

* feat: multi-conversation review chat (tabs, new chat, history)

Replace the single per-PR chat thread with multiple per-user conversations:
- threads minted client-side; first message persists with a title derived
  from the prompt.
- list + delete endpoints; chat panel gets a tab strip (history), new-chat
  (+), close (x), refresh, an intro greeting, and suggested prompts.
- get_review_chat now returns availability only (ids are client-minted).

* ui fixes

* ui: review-chat history dropdown, full-width AI replies, resizable side panel

* fix(review-chat): enforce per-user thread ownership on proxy endpoints; reseed PR context on head change

---------

Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
2026-06-15 17:17:30 -07:00

77 lines
2.5 KiB
TypeScript

import {
HeadContent,
Outlet,
Scripts,
createRootRoute,
} from "@tanstack/react-router"
import { TanStackRouterDevtoolsPanel } from "@tanstack/react-router-devtools"
import { TanStackDevtools } from "@tanstack/react-devtools"
import { QueryClientProvider } from "@tanstack/react-query"
import { ReactQueryDevtools } from "@tanstack/react-query-devtools"
import { useState } from "react"
import appCss from "../styles.css?url"
import { makeQueryClient } from "@/lib/query"
const themeInitScript = `(function(){try{var t=localStorage.getItem("open-swe-theme");var d=t==="dark"||((!t||t==="system")&&window.matchMedia("(prefers-color-scheme: dark)").matches);var r=document.documentElement;r.classList.toggle("dark",d);r.style.colorScheme=d?"dark":"light";}catch(e){}})();`
export const Route = createRootRoute({
head: () => ({
meta: [
{ charSet: "utf-8" },
{
name: "viewport",
content: "width=device-width, initial-scale=1, maximum-scale=1",
},
{ name: "theme-color", content: "#000000" },
{ title: "open-swe" },
],
links: [
{ rel: "stylesheet", href: appCss },
{ rel: "manifest", href: "/manifest.webmanifest" },
{ rel: "icon", type: "image/png", href: "/favicon.png" },
{ rel: "apple-touch-icon", href: "/apple-touch-icon.png" },
],
}),
notFoundComponent: () => (
<main className="container mx-auto p-4 pt-16">
<h1 className="text-2xl font-medium">404</h1>
<p className="text-muted-foreground">
The requested page could not be found.
</p>
</main>
),
shellComponent: RootDocument,
})
function RootDocument({ children }: { children: React.ReactNode }) {
const [queryClient] = useState(() => makeQueryClient())
return (
<html lang="en" suppressHydrationWarning>
<head>
<script dangerouslySetInnerHTML={{ __html: themeInitScript }} />
<HeadContent />
</head>
<body>
<QueryClientProvider client={queryClient}>
{children ?? <Outlet />}
{import.meta.env.VITE_DEVTOOLS !== "false" && (
<>
<TanStackDevtools
config={{ position: "bottom-right" }}
plugins={[
{
name: "Tanstack Router",
render: <TanStackRouterDevtoolsPanel />,
},
]}
/>
<ReactQueryDevtools initialIsOpen={false} />
</>
)}
</QueryClientProvider>
<Scripts />
</body>
</html>
)
}