this function must be kept up to date with getBlockTermDurableAtom in frontend/app/store/global.ts
(block *waveobj.Block)
| 1346 | |
| 1347 | // this function must be kept up to date with getBlockTermDurableAtom in frontend/app/store/global.ts |
| 1348 | func IsBlockTermDurable(block *waveobj.Block) bool { |
| 1349 | if block == nil { |
| 1350 | return false |
| 1351 | } |
| 1352 | |
| 1353 | // Check if view is "term", and controller is "shell" |
| 1354 | if block.Meta.GetString(waveobj.MetaKey_View, "") != "term" || block.Meta.GetString(waveobj.MetaKey_Controller, "") != "shell" { |
| 1355 | return false |
| 1356 | } |
| 1357 | |
| 1358 | // 1. Check if block has a JobId |
| 1359 | if block.JobId != "" { |
| 1360 | return true |
| 1361 | } |
| 1362 | |
| 1363 | // 2. Check if connection is local or WSL (not durable) |
| 1364 | connName := block.Meta.GetString(waveobj.MetaKey_Connection, "") |
| 1365 | if conncontroller.IsLocalConnName(connName) || conncontroller.IsWslConnName(connName) { |
| 1366 | return false |
| 1367 | } |
| 1368 | |
| 1369 | // 3. Check config hierarchy: blockmeta → connection → global (default true) |
| 1370 | // Check block meta first |
| 1371 | if val, exists := block.Meta[waveobj.MetaKey_TermDurable]; exists { |
| 1372 | if boolVal, ok := val.(bool); ok { |
| 1373 | return boolVal |
| 1374 | } |
| 1375 | } |
| 1376 | // Check connection config |
| 1377 | fullConfig := wconfig.GetWatcher().GetFullConfig() |
| 1378 | if connName != "" { |
| 1379 | if connConfig, exists := fullConfig.Connections[connName]; exists { |
| 1380 | if connConfig.TermDurable != nil { |
| 1381 | return *connConfig.TermDurable |
| 1382 | } |
| 1383 | } |
| 1384 | } |
| 1385 | // Check global settings |
| 1386 | if fullConfig.Settings.TermDurable != nil { |
| 1387 | return *fullConfig.Settings.TermDurable |
| 1388 | } |
| 1389 | // Default to true for non-local connections |
| 1390 | return true |
| 1391 | } |
| 1392 | |
| 1393 | func IsBlockIdTermDurable(blockId string) bool { |
| 1394 | block, err := wstore.DBGet[*waveobj.Block](context.Background(), blockId) |
no test coverage detected