mirror of
https://github.com/stablyai/orca.git
synced 2026-11-06 03:57:35 +00:00
* Nest chat-UI orchestration workers under the agent that started them Main's lineage projection only walked terminal panes, so workers running in the chat UI never got a parent link and listed flat in the sidebar. It now also projects chat workers, keyed by their visible chat row, and resolves a chat creator or coordinator to that chat's visible row instead of its handle or private mailbox pane key. * Fix public worker lineage across assignment and row identities * Complete terminal lineage provenance and bound active session selection * Repair lineage test runtime boundaries and SQLite counters * Batch public lineage verification after exact recency selection * Use checked runtime values in lineage integration tests * Document the trusted Dispatch SQL row boundary * Keep lineage integration imports within their test programs * Load native lineage fixtures before test execution * test: complete lineage inputs in runtime and sidebar fixtures * test: seed benchmark facts from active dispatches * test: replace partial orchestration DB casts with typed fixtures * test: complete stale-leaf mailbox fixture session input * fix(test): render worker lineage fixture with production list
68 lines
2.5 KiB
TypeScript
68 lines
2.5 KiB
TypeScript
import type { Tab } from './tab-types'
|
|
import { structuredAgentSessionPaneKey } from './structured-agent-session-projection'
|
|
import type { AgentStatusEntry, AgentStatusOrchestrationContext } from './agent-status-types'
|
|
import { isWebTerminalSurfaceTabId } from './terminal-surface-id'
|
|
import { parseLegacyNumericPaneKey, parsePaneKey } from './stable-pane-id'
|
|
|
|
export type AgentStatusPaneIdentity = { tabId: string; paneId: string }
|
|
|
|
export function parseAgentStatusPaneIdentity(
|
|
paneKey: string | undefined,
|
|
representedTab?: Pick<Tab, 'id' | 'entityId' | 'contentType'>
|
|
): AgentStatusPaneIdentity | null {
|
|
if (!paneKey) {
|
|
return null
|
|
}
|
|
if (
|
|
representedTab?.contentType === 'agent-session' &&
|
|
structuredAgentSessionPaneKey(representedTab.id, representedTab.entityId) === paneKey
|
|
) {
|
|
return { tabId: representedTab.id, paneId: paneKey.slice(representedTab.id.length + 1) }
|
|
}
|
|
const parsed = parsePaneKey(paneKey)
|
|
if (parsed) {
|
|
return { tabId: parsed.tabId, paneId: parsed.leafId }
|
|
}
|
|
const legacy = parseLegacyNumericPaneKey(paneKey)
|
|
return legacy ? { tabId: legacy.tabId, paneId: legacy.numericPaneId } : null
|
|
}
|
|
|
|
export function resolveAgentStatusWorktreeId(
|
|
entry: Pick<AgentStatusEntry, 'paneKey' | 'worktreeId' | 'orchestration' | 'connectionId'>,
|
|
worktreeIdByTabId: Pick<ReadonlyMap<string, string>, 'get'>,
|
|
orchestration = entry.orchestration
|
|
): string | null {
|
|
const paneIdentity = parseAgentStatusPaneIdentity(entry.paneKey)
|
|
// Host-reported workspace ownership survives colliding mirrored tab IDs.
|
|
if (
|
|
entry.worktreeId &&
|
|
(entry.connectionId || isWebTerminalSurfaceTabId(paneIdentity?.tabId ?? ''))
|
|
) {
|
|
return entry.worktreeId
|
|
}
|
|
const parentIdentity = parseAgentStatusPaneIdentity(orchestration?.parentPaneKey)
|
|
return (
|
|
worktreeIdByTabId.get(paneIdentity?.tabId ?? '') ??
|
|
entry.worktreeId ??
|
|
worktreeIdByTabId.get(parentIdentity?.tabId ?? '') ??
|
|
null
|
|
)
|
|
}
|
|
|
|
export function mergeAgentStatusOrchestration(
|
|
entry: Pick<AgentStatusEntry, 'orchestration'>,
|
|
runtimeOrchestration: AgentStatusOrchestrationContext | undefined
|
|
): AgentStatusOrchestrationContext | undefined {
|
|
if (!entry.orchestration) {
|
|
return runtimeOrchestration
|
|
}
|
|
if (
|
|
!runtimeOrchestration ||
|
|
entry.orchestration.taskId !== runtimeOrchestration.taskId ||
|
|
entry.orchestration.dispatchId !== runtimeOrchestration.dispatchId
|
|
) {
|
|
return entry.orchestration
|
|
}
|
|
return { ...entry.orchestration, ...runtimeOrchestration }
|
|
}
|