mirror of
https://github.com/crabwise-ai/crabwalk.git
synced 2026-08-14 09:02:07 +00:00
refactor(graph-layout): update subagent session filtering logic
- Revised the filtering logic for subagent sessions in the layoutGraph function to exclude empty sessions that lack associated actions or execs. This change enhances the accuracy of session representation in the graph layout by ensuring only relevant sessions are displayed.
This commit is contained in:
+11
-11
@@ -67,17 +67,6 @@ export function layoutGraph(
|
||||
.filter((n) => n.type === 'session')
|
||||
.map((n) => n.data as unknown as MonitorSession)
|
||||
|
||||
// Filter out orphan subagents:
|
||||
// - Subagent sessions (by key) must have a valid parent in the list
|
||||
// - Non-subagents are shown if they have no parent or a valid parent
|
||||
const sessions = allSessions.filter(s => {
|
||||
const isSubagent = s.key.includes('subagent')
|
||||
if (isSubagent) {
|
||||
return s.spawnedBy && allSessions.some(p => p.key === s.spawnedBy)
|
||||
}
|
||||
return !s.spawnedBy || allSessions.some(p => p.key === s.spawnedBy)
|
||||
})
|
||||
|
||||
const actions = nodes
|
||||
.filter((n) => n.type === 'action')
|
||||
.map((n) => ({ id: n.id.replace('action-', ''), data: n.data as unknown as MonitorAction }))
|
||||
@@ -86,6 +75,17 @@ export function layoutGraph(
|
||||
.filter((n) => n.type === 'exec')
|
||||
.map((n) => ({ id: n.id.replace('exec-', ''), data: n.data as unknown as MonitorExecProcess }))
|
||||
|
||||
// Filter out empty subagent sessions (no actions or execs attached)
|
||||
const sessions = allSessions.filter(s => {
|
||||
const isSubagent = s.key.includes('subagent')
|
||||
if (isSubagent) {
|
||||
const hasActions = actions.some(a => a.data.sessionKey === s.key)
|
||||
const hasExecs = execs.some(e => e.data.sessionKey === s.key)
|
||||
return hasActions || hasExecs
|
||||
}
|
||||
return true
|
||||
})
|
||||
|
||||
const crabNode = nodes.find((n) => n.type === 'crab')
|
||||
|
||||
// Build session column map - which column is each session in?
|
||||
|
||||
Reference in New Issue
Block a user