* fix(subagents): preserve opened children on parent archive Opening a managed child represents user ownership only while that client's tab remains open. Track that intent per client, detach surviving children during parent archive, and keep single and bulk tab-close behavior consistent. * fix(subagents): mark generic tab openings Centralize managed child tab ownership in agent navigation so list, command-center, deep-link, notification, and subagent-track openings all mark ownership before creating the tab. Use stable localized errors for lifecycle failures. * fix(subagents): classify cold tab openings Fetch uncached agents before deciding whether tab ownership must be recorded, so notification, desktop, and cold-route openings cannot bypass parent archive protection. * fix(app): translate navigation fallback errors * fix(navigation): allow offline workspace intents * refactor(app): derive subagent ownership from open tabs * fix(server): serialize subagent lifecycle ownership
32 lines
1.0 KiB
TypeScript
32 lines
1.0 KiB
TypeScript
export const PARENT_AGENT_ID_LABEL = "paseo.parent-agent-id";
|
|
const OPEN_AGENT_TAB_LABEL_PREFIX = "paseo.open-agent-tab.";
|
|
|
|
export function getOpenAgentTabLabel(clientId: string): string {
|
|
return `${OPEN_AGENT_TAB_LABEL_PREFIX}${clientId}`;
|
|
}
|
|
|
|
export function isOpenAgentTabLabel(label: string): boolean {
|
|
return label.startsWith(OPEN_AGENT_TAB_LABEL_PREFIX);
|
|
}
|
|
|
|
export interface AgentLabelSource {
|
|
labels?: Record<string, unknown> | null;
|
|
}
|
|
|
|
export function getParentAgentIdFromLabels(labels: Record<string, unknown> | null | undefined) {
|
|
const parentAgentId = labels?.[PARENT_AGENT_ID_LABEL];
|
|
return typeof parentAgentId === "string" && parentAgentId.trim().length > 0
|
|
? parentAgentId.trim()
|
|
: null;
|
|
}
|
|
|
|
export function isDelegatedAgent(agent: AgentLabelSource): boolean {
|
|
return getParentAgentIdFromLabels(agent.labels) !== null;
|
|
}
|
|
|
|
export function hasOpenAgentTab(labels: Record<string, unknown> | null | undefined): boolean {
|
|
return Object.entries(labels ?? {}).some(
|
|
([label, value]) => isOpenAgentTabLabel(label) && value === "true",
|
|
);
|
|
}
|