@@ -9,7 +9,7 @@ import { Font } from "@opencode-ai/ui/font"
99import { Splash } from "@opencode-ai/ui/logo"
1010import { ThemeProvider } from "@opencode-ai/ui/theme/context"
1111import { MetaProvider } from "@solidjs/meta"
12- import { type BaseRouterProps , Navigate , Route , Router , useParams , useSearchParams } from "@solidjs/router"
12+ import { type BaseRouterProps , Navigate , Route , Router , useNavigate , useParams , useSearchParams } from "@solidjs/router"
1313import { QueryClient , QueryClientProvider } from "@tanstack/solid-query"
1414import { Effect } from "effect"
1515import {
@@ -32,7 +32,7 @@ import { CommandProvider, useCommand, type CommandOption } from "@/context/comma
3232import { CommentsProvider } from "@/context/comments"
3333import { FileProvider } from "@/context/file"
3434import { ServerSDKProvider } from "@/context/server-sdk"
35- import { ServerSyncProvider } from "@/context/server-sync"
35+ import { ServerSyncProvider , useServerSync } from "@/context/server-sync"
3636import { GlobalProvider , useGlobal } from "@/context/global"
3737import { HighlightsProvider } from "@/context/highlights"
3838import { LanguageProvider , type Locale , useLanguage } from "@/context/language"
@@ -52,9 +52,10 @@ import LegacyLayout from "@/pages/layout"
5252import NewLayout from "@/pages/layout-new"
5353import { ErrorPage } from "./pages/error"
5454import { useCheckServerHealth } from "./utils/server-health"
55- import { legacySessionServer , requireServerKey , sessionHref } from "./utils/session-route"
55+ import { legacySessionHref , legacySessionServer , requireServerKey , sessionHref } from "./utils/session-route"
56+ import { createSessionLineage } from "@/pages/session/session-lineage"
5657
57- import { SessionPage , TargetSessionRouteContent } from "@/pages/session"
58+ import { SessionPage , SessionRouteErrorBoundary , TargetSessionRouteContent } from "@/pages/session"
5859import { NewHome , LegacyHome } from "@/pages/home"
5960
6061const NewSession = lazy ( ( ) => import ( "@/pages/new-session" ) )
@@ -88,10 +89,14 @@ const SessionRoute = () => {
8889 tabs . newDraft ( { server : server . key , directory : sdk ( ) . directory } , search . prompt )
8990 } )
9091
91- return < SessionPage />
92+ return (
93+ < SessionRouteErrorBoundary sessionID = { params . id } >
94+ < SessionPage />
95+ </ SessionRouteErrorBoundary >
96+ )
9297}
9398
94- const TargetSessionRoute = ( ) => {
99+ function TargetServerRoute ( props : ParentProps ) {
95100 const params = useParams < { serverKey : string ; id : string } > ( )
96101 const global = useGlobal ( )
97102 const conn = createMemo ( ( ) => {
@@ -105,14 +110,47 @@ const TargetSessionRoute = () => {
105110 // re-resolves reactively instead); both rely on this key for server changes.
106111 < Show when = { requireServerKey ( params . serverKey ) } keyed >
107112 < ServerSDKProvider server = { conn } >
108- < ServerSyncProvider server = { conn } >
109- < TargetSessionRouteContent />
110- </ ServerSyncProvider >
113+ < ServerSyncProvider server = { conn } > { props . children } </ ServerSyncProvider >
111114 </ ServerSDKProvider >
112115 </ Show >
113116 )
114117}
115118
119+ const TargetSessionRoute = ( ) => (
120+ < TargetServerRoute >
121+ < TargetSessionRouteContent />
122+ </ TargetServerRoute >
123+ )
124+
125+ function LegacyTargetSessionRoute ( ) {
126+ const params = useParams < { serverKey : string ; id : string } > ( )
127+ return (
128+ < TargetServerRoute >
129+ < SessionRouteErrorBoundary sessionID = { params . id } serverKey = { requireServerKey ( params . serverKey ) } >
130+ < LegacyTargetSessionRedirect />
131+ </ SessionRouteErrorBoundary >
132+ </ TargetServerRoute >
133+ )
134+ }
135+
136+ function LegacyTargetSessionRedirect ( ) {
137+ const params = useParams < { id : string } > ( )
138+ const navigate = useNavigate ( )
139+ const sync = useServerSync ( )
140+ const current = createSessionLineage (
141+ ( ) => params . id ,
142+ ( ) => sync ( ) . session . lineage ,
143+ )
144+
145+ createEffect ( ( ) => {
146+ const directory = current ( ) ?. session . directory
147+ if ( ! directory ) return
148+ navigate ( legacySessionHref ( directory , params . id ) , { replace : true } )
149+ } )
150+
151+ return null
152+ }
153+
116154// Wraps the non-draft routes. They are gated on (and keyed to) the globally selected
117155// server via ServerKey, then provide the server-scoped shell (Permission/Layout/
118156// Notification/Models + the visual Layout) for that server.
@@ -542,23 +580,30 @@ function Routes(props: { serverScoped?: JSX.Element }) {
542580 < LegacyServerLayout serverScoped = { props . serverScoped } > { routeProps . children } </ LegacyServerLayout >
543581 ) }
544582 >
545- < Show when = { ! settings . general . newLayoutDesigns ( ) } > { < Route path = "/" component = { LegacyHome } /> } </ Show >
583+ < Show when = { ! settings . general . newLayoutDesigns ( ) } >
584+ {
585+ < >
586+ < Route path = "/" component = { LegacyHome } />
587+ < Route path = "/server/:serverKey/session/:id" component = { LegacyTargetSessionRoute } />
588+ </ >
589+ }
590+ </ Show >
546591 < Route path = "/:dir" component = { DirectoryLayout } >
547592 < Route path = "/" component = { ( ) => < Navigate href = "session" /> } />
548593 < Route path = "/session/:id?" component = { SessionRoute } />
549594 </ Route >
550595 </ Route >
551596 < Show when = { settings . general . newLayoutDesigns ( ) } >
552597 < Route path = "/" component = { NewHome } />
553- < Route path = "/:dir/session/:id" component = { LegacyTargetSessionRoute } />
598+ < Route path = "/:dir/session/:id" component = { NewLayoutLegacySessionRedirect } />
599+ < Route path = "/server/:serverKey/session/:id" component = { TargetSessionRoute } />
554600 </ Show >
555601 < Route path = "/new-session" component = { DraftRoute } />
556- < Route path = "/server/:serverKey/session/:id" component = { TargetSessionRoute } />
557602 </ >
558603 )
559604}
560605
561- function LegacyTargetSessionRoute ( ) {
606+ function NewLayoutLegacySessionRedirect ( ) {
562607 const server = useServer ( )
563608 const tabs = useTabs ( )
564609 const params = useParams < { id : string } > ( )
0 commit comments