|
|
@@ -9,7 +9,7 @@ import { Font } from "@opencode-ai/ui/font"
|
|
|
import { Splash } from "@opencode-ai/ui/logo"
|
|
|
import { ThemeProvider } from "@opencode-ai/ui/theme/context"
|
|
|
import { MetaProvider } from "@solidjs/meta"
|
|
|
-import { type BaseRouterProps, Navigate, Route, Router, useParams, useSearchParams } from "@solidjs/router"
|
|
|
+import { type BaseRouterProps, Navigate, Route, Router, useNavigate, useParams, useSearchParams } from "@solidjs/router"
|
|
|
import { QueryClient, QueryClientProvider } from "@tanstack/solid-query"
|
|
|
import { Effect } from "effect"
|
|
|
import {
|
|
|
@@ -32,7 +32,7 @@ import { CommandProvider, useCommand, type CommandOption } from "@/context/comma
|
|
|
import { CommentsProvider } from "@/context/comments"
|
|
|
import { FileProvider } from "@/context/file"
|
|
|
import { ServerSDKProvider } from "@/context/server-sdk"
|
|
|
-import { ServerSyncProvider } from "@/context/server-sync"
|
|
|
+import { ServerSyncProvider, useServerSync } from "@/context/server-sync"
|
|
|
import { GlobalProvider, useGlobal } from "@/context/global"
|
|
|
import { HighlightsProvider } from "@/context/highlights"
|
|
|
import { LanguageProvider, type Locale, useLanguage } from "@/context/language"
|
|
|
@@ -52,9 +52,10 @@ import LegacyLayout from "@/pages/layout"
|
|
|
import NewLayout from "@/pages/layout-new"
|
|
|
import { ErrorPage } from "./pages/error"
|
|
|
import { useCheckServerHealth } from "./utils/server-health"
|
|
|
-import { legacySessionServer, requireServerKey, sessionHref } from "./utils/session-route"
|
|
|
+import { legacySessionHref, legacySessionServer, requireServerKey, sessionHref } from "./utils/session-route"
|
|
|
+import { createSessionLineage } from "@/pages/session/session-lineage"
|
|
|
|
|
|
-import { SessionPage, TargetSessionRouteContent } from "@/pages/session"
|
|
|
+import { SessionPage, SessionRouteErrorBoundary, TargetSessionRouteContent } from "@/pages/session"
|
|
|
import { NewHome, LegacyHome } from "@/pages/home"
|
|
|
|
|
|
const NewSession = lazy(() => import("@/pages/new-session"))
|
|
|
@@ -88,10 +89,14 @@ const SessionRoute = () => {
|
|
|
tabs.newDraft({ server: server.key, directory: sdk().directory }, search.prompt)
|
|
|
})
|
|
|
|
|
|
- return <SessionPage />
|
|
|
+ return (
|
|
|
+ <SessionRouteErrorBoundary sessionID={params.id}>
|
|
|
+ <SessionPage />
|
|
|
+ </SessionRouteErrorBoundary>
|
|
|
+ )
|
|
|
}
|
|
|
|
|
|
-const TargetSessionRoute = () => {
|
|
|
+function TargetServerRoute(props: ParentProps) {
|
|
|
const params = useParams<{ serverKey: string; id: string }>()
|
|
|
const global = useGlobal()
|
|
|
const conn = createMemo(() => {
|
|
|
@@ -105,14 +110,47 @@ const TargetSessionRoute = () => {
|
|
|
// re-resolves reactively instead); both rely on this key for server changes.
|
|
|
<Show when={requireServerKey(params.serverKey)} keyed>
|
|
|
<ServerSDKProvider server={conn}>
|
|
|
- <ServerSyncProvider server={conn}>
|
|
|
- <TargetSessionRouteContent />
|
|
|
- </ServerSyncProvider>
|
|
|
+ <ServerSyncProvider server={conn}>{props.children}</ServerSyncProvider>
|
|
|
</ServerSDKProvider>
|
|
|
</Show>
|
|
|
)
|
|
|
}
|
|
|
|
|
|
+const TargetSessionRoute = () => (
|
|
|
+ <TargetServerRoute>
|
|
|
+ <TargetSessionRouteContent />
|
|
|
+ </TargetServerRoute>
|
|
|
+)
|
|
|
+
|
|
|
+function LegacyTargetSessionRoute() {
|
|
|
+ const params = useParams<{ serverKey: string; id: string }>()
|
|
|
+ return (
|
|
|
+ <TargetServerRoute>
|
|
|
+ <SessionRouteErrorBoundary sessionID={params.id} serverKey={requireServerKey(params.serverKey)}>
|
|
|
+ <LegacyTargetSessionRedirect />
|
|
|
+ </SessionRouteErrorBoundary>
|
|
|
+ </TargetServerRoute>
|
|
|
+ )
|
|
|
+}
|
|
|
+
|
|
|
+function LegacyTargetSessionRedirect() {
|
|
|
+ const params = useParams<{ id: string }>()
|
|
|
+ const navigate = useNavigate()
|
|
|
+ const sync = useServerSync()
|
|
|
+ const current = createSessionLineage(
|
|
|
+ () => params.id,
|
|
|
+ () => sync().session.lineage,
|
|
|
+ )
|
|
|
+
|
|
|
+ createEffect(() => {
|
|
|
+ const directory = current()?.session.directory
|
|
|
+ if (!directory) return
|
|
|
+ navigate(legacySessionHref(directory, params.id), { replace: true })
|
|
|
+ })
|
|
|
+
|
|
|
+ return null
|
|
|
+}
|
|
|
+
|
|
|
// Wraps the non-draft routes. They are gated on (and keyed to) the globally selected
|
|
|
// server via ServerKey, then provide the server-scoped shell (Permission/Layout/
|
|
|
// Notification/Models + the visual Layout) for that server.
|
|
|
@@ -542,7 +580,14 @@ function Routes(props: { serverScoped?: JSX.Element }) {
|
|
|
<LegacyServerLayout serverScoped={props.serverScoped}>{routeProps.children}</LegacyServerLayout>
|
|
|
)}
|
|
|
>
|
|
|
- <Show when={!settings.general.newLayoutDesigns()}>{<Route path="/" component={LegacyHome} />}</Show>
|
|
|
+ <Show when={!settings.general.newLayoutDesigns()}>
|
|
|
+ {
|
|
|
+ <>
|
|
|
+ <Route path="/" component={LegacyHome} />
|
|
|
+ <Route path="/server/:serverKey/session/:id" component={LegacyTargetSessionRoute} />
|
|
|
+ </>
|
|
|
+ }
|
|
|
+ </Show>
|
|
|
<Route path="/:dir" component={DirectoryLayout}>
|
|
|
<Route path="/" component={() => <Navigate href="session" />} />
|
|
|
<Route path="/session/:id?" component={SessionRoute} />
|
|
|
@@ -550,15 +595,15 @@ function Routes(props: { serverScoped?: JSX.Element }) {
|
|
|
</Route>
|
|
|
<Show when={settings.general.newLayoutDesigns()}>
|
|
|
<Route path="/" component={NewHome} />
|
|
|
- <Route path="/:dir/session/:id" component={LegacyTargetSessionRoute} />
|
|
|
+ <Route path="/:dir/session/:id" component={NewLayoutLegacySessionRedirect} />
|
|
|
+ <Route path="/server/:serverKey/session/:id" component={TargetSessionRoute} />
|
|
|
</Show>
|
|
|
<Route path="/new-session" component={DraftRoute} />
|
|
|
- <Route path="/server/:serverKey/session/:id" component={TargetSessionRoute} />
|
|
|
</>
|
|
|
)
|
|
|
}
|
|
|
|
|
|
-function LegacyTargetSessionRoute() {
|
|
|
+function NewLayoutLegacySessionRedirect() {
|
|
|
const server = useServer()
|
|
|
const tabs = useTabs()
|
|
|
const params = useParams<{ id: string }>()
|