(props: {
tab: SessionTab
id: string
index: () => number
active: () => boolean
activeServerKey: ServerConnection.Key
forceTruncate: boolean
serverCtx: () => ServerCtx | undefined
onNavigate: (element: HTMLDivElement) => void
onClose: () => void
})
| 20 | const sortableTransition = { duration: 0 } |
| 21 | |
| 22 | function SessionTabSlot(props: { |
| 23 | tab: SessionTab |
| 24 | id: string |
| 25 | index: () => number |
| 26 | active: () => boolean |
| 27 | activeServerKey: ServerConnection.Key |
| 28 | forceTruncate: boolean |
| 29 | serverCtx: () => ServerCtx | undefined |
| 30 | onNavigate: (element: HTMLDivElement) => void |
| 31 | onClose: () => void |
| 32 | }) { |
| 33 | const tabs = useTabs() |
| 34 | const language = useLanguage() |
| 35 | const sortable = useSortable({ |
| 36 | get id() { |
| 37 | return props.id |
| 38 | }, |
| 39 | get index() { |
| 40 | return props.index() |
| 41 | }, |
| 42 | }) |
| 43 | let ref!: HTMLDivElement |
| 44 | const sdk = createMemo(() => props.serverCtx()?.sdk ?? null) |
| 45 | const cachedSession = createMemo(() => props.serverCtx()?.sync.session.peek(props.tab.sessionId)) |
| 46 | const [loadedSession] = createResource( |
| 47 | () => { |
| 48 | const ctx = props.serverCtx() |
| 49 | return ctx ? { id: props.tab.sessionId, ctx } : null |
| 50 | }, |
| 51 | ({ id, ctx }) => ctx.sync.session.resolve(id).catch(() => undefined), |
| 52 | ) |
| 53 | const session = createMemo(() => cachedSession() ?? loadedSession()) |
| 54 | const missingSession = createMemo(() => !!props.serverCtx() && !loadedSession.loading && !session()) |
| 55 | let prefetched = false |
| 56 | |
| 57 | createEffect(() => { |
| 58 | const ctx = props.serverCtx() |
| 59 | const value = session() |
| 60 | if (!ctx || !value || prefetched) return |
| 61 | prefetched = true |
| 62 | createRoot((dispose) => { |
| 63 | try { |
| 64 | void ctx.sync |
| 65 | .ensureDirSyncContext(value.directory) |
| 66 | .session.sync(value.id) |
| 67 | .catch(() => {}) |
| 68 | .finally(dispose) |
| 69 | } catch { |
| 70 | dispose() |
| 71 | } |
| 72 | }) |
| 73 | }) |
| 74 | |
| 75 | createEffect(() => { |
| 76 | const value = session() |
| 77 | const current = sdk() |
| 78 | if (!value || !current) return |
| 79 | createTabPromptState(tabs, props.tab, current.scope, { |
nothing calls this directly
no test coverage detected