MCPcopy Index your code
hub / github.com/wavetermdev/waveterm / getBlockTermDurableAtom

Function getBlockTermDurableAtom

frontend/app/store/global.ts:290–333  ·  view source on GitHub ↗
(blockId: string)

Source from the content-addressed store, hash-verified

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
290function 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
335function useBlockAtom<T>(blockId: string, name: string, makeFn: () => Atom<T>): Atom<T> {
336 const blockCache = getSingleBlockAtomCache(blockId);

Callers 3

constructorMethod · 0.90
getSettingsMenuItemsMethod · 0.90

Calls 6

isLocalConnNameFunction · 0.90
isWslConnNameFunction · 0.90
getSingleBlockAtomCacheFunction · 0.85
getOverrideConfigAtomFunction · 0.85
getMethod · 0.80
setMethod · 0.80

Tested by

no test coverage detected