(blockId: string)
| 288 | // Note: null/false both map to false in the Go code, but this returns a special null value |
| 289 | // to indicate when the block is not even eligible to be durable |
| 290 | function getBlockTermDurableAtom(blockId: string): Atom<null | boolean> { |
| 291 | const blockCache = getSingleBlockAtomCache(blockId); |
| 292 | const durableAtomName = "#termdurable"; |
| 293 | let durableAtom = blockCache.get(durableAtomName); |
| 294 | if (durableAtom != null) { |
| 295 | return durableAtom; |
| 296 | } |
| 297 | durableAtom = atom((get) => { |
| 298 | const blockAtom = WOS.getWaveObjectAtom<Block>(WOS.makeORef("block", blockId)); |
| 299 | const block = get(blockAtom); |
| 300 | |
| 301 | if (block == null) { |
| 302 | return null; |
| 303 | } |
| 304 | |
| 305 | // Check if view is "term", and controller is "shell" |
| 306 | if (block.meta?.view != "term" || block.meta?.controller != "shell") { |
| 307 | return null; |
| 308 | } |
| 309 | |
| 310 | // 1. Check if block has a JobId |
| 311 | if (block.jobid != null && block.jobid != "") { |
| 312 | return true; |
| 313 | } |
| 314 | |
| 315 | // 2. Check if connection is local or WSL (not eligible for durability) |
| 316 | const connName = block.meta?.connection ?? ""; |
| 317 | if (isLocalConnName(connName) || isWslConnName(connName)) { |
| 318 | return null; |
| 319 | } |
| 320 | |
| 321 | // 3. Check config hierarchy: blockmeta → connection → global (default true) |
| 322 | const durableConfigAtom = getOverrideConfigAtom(blockId, "term:durable"); |
| 323 | const durableConfig = get(durableConfigAtom); |
| 324 | if (durableConfig != null) { |
| 325 | return durableConfig; |
| 326 | } |
| 327 | |
| 328 | // Default to true for non-local connections |
| 329 | return true; |
| 330 | }); |
| 331 | blockCache.set(durableAtomName, durableAtom); |
| 332 | return durableAtom; |
| 333 | } |
| 334 | |
| 335 | function useBlockAtom<T>(blockId: string, name: string, makeFn: () => Atom<T>): Atom<T> { |
| 336 | const blockCache = getSingleBlockAtomCache(blockId); |
no test coverage detected