The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | import { scopeThreadRef } from "@t3tools/client-runtime/environment"; |
| 2 | import type { ScopedThreadRef } from "@t3tools/contracts"; |
| 3 | import { useNavigate } from "@tanstack/react-router"; |
| 4 | |
| 5 | import { type LinkedThreadSurface, linkedThreadRouteParams } from "../linkedThreadSurface"; |
| 6 | import { type ThreadSurface, useRightPanelStore } from "../rightPanelStore"; |
| 7 | import { buildThreadRouteParams } from "../threadRoutes"; |
| 8 | |
| 9 | /** |
| 10 | * Moves a side thread's tab from `panelRef`'s panel to the main screen. The tab closes, without |
| 11 | * the cleanup Close does, so the way back does not show the thread beside itself. |
| 12 | */ |
| 13 | export function useOpenSurfaceInMainView(panelRef: ScopedThreadRef | null) { |
| 14 | const navigate = useNavigate(); |
| 15 | return (surface: ThreadSurface | LinkedThreadSurface) => { |
| 16 | if (panelRef === null) return; |
| 17 | useRightPanelStore.getState().closeSurface(panelRef, surface.id); |
| 18 | if (surface.kind === "linked-thread") { |
| 19 | void navigate({ |
| 20 | to: "/linked/$viaEnvironmentId/$linkedEnvironmentId/$linkedThreadId", |
| 21 | params: linkedThreadRouteParams(surface), |
| 22 | }); |
| 23 | return; |
| 24 | } |
| 25 | void navigate({ |
| 26 | to: "/$environmentId/$threadId", |
| 27 | params: buildThreadRouteParams(scopeThreadRef(panelRef.environmentId, surface.threadId)), |
| 28 | }); |
| 29 | }; |
| 30 | } |