MCPcopy
hub / github.com/anomalyco/opencode / SessionRoute

Function SessionRoute

packages/app/src/app.tsx:62–92  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

60const NewSession = lazy(() => import("@/pages/new-session"))
61
62const SessionRoute = () => {
63 const settings = useSettings()
64 const params = useParams()
65 const [search] = useSearchParams<{ draftId?: string; prompt?: string }>()
66 const sdk = useSDK()
67 const server = useServer()
68 const tabs = useTabs()
69
70 if (params.id && settings.general.newLayoutDesigns()) {
71 const sessionID = params.id
72 return (
73 <Show when={tabs.ready()}>
74 {(_) => {
75 const persisted = tabs.store.filter((item) => item.type === "session")
76 return <Navigate href={sessionHref(legacySessionServer(persisted, sessionID, server.key), sessionID)} />
77 }}
78 </Show>
79 )
80 }
81
82 // When the new layout is enabled, the legacy new-session route (/:dir/session with no id)
83 // is replaced by a draft at /new-session?draftId=…
84 createEffect(() => {
85 if (!settings.general.newLayoutDesigns()) return
86 if (params.id || search.draftId) return
87 if (!tabs.ready() || !sdk().directory) return
88 tabs.newDraft({ server: server.key, directory: sdk().directory }, search.prompt)
89 })
90
91 return <SessionPage />
92}
93
94const TargetSessionRoute = () => {
95 const params = useParams<{ serverKey: string; id: string }>()

Callers

nothing calls this directly

Calls 4

sessionHrefFunction · 0.90
legacySessionServerFunction · 0.90
sdkFunction · 0.85
readyMethod · 0.80

Tested by

no test coverage detected