MCPcopy
hub / github.com/wavetermdev/waveterm / IsBlockTermDurable

Function IsBlockTermDurable

pkg/jobcontroller/jobcontroller.go:1348–1391  ·  view source on GitHub ↗

this function must be kept up to date with getBlockTermDurableAtom in frontend/app/store/global.ts

(block *waveobj.Block)

Source from the content-addressed store, hash-verified

1346
1347// this function must be kept up to date with getBlockTermDurableAtom in frontend/app/store/global.ts
1348func 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
1393func IsBlockIdTermDurable(blockId string) bool {
1394 block, err := wstore.DBGet[*waveobj.Block](context.Background(), blockId)

Callers 1

IsBlockIdTermDurableFunction · 0.85

Calls 5

IsLocalConnNameFunction · 0.92
IsWslConnNameFunction · 0.92
GetWatcherFunction · 0.92
GetStringMethod · 0.80
GetFullConfigMethod · 0.80

Tested by

no test coverage detected