Files
agent-radar 2ed3415fb7
Publish Claude Code Binaries / Stage and publish binaries (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-arm64 (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build linux-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build windows-amd64 (push) Canceled after 0s
Sync Tutti Agent Skills / sync (push) Canceled after 0s
Windows Agent Adapters / Test Windows agent adapters (push) Canceled after 0s
Windows Daemon Adapters / Test Windows daemon adapters (push) Canceled after 0s
Publish Tutti App Runtime / Publish runtime catalog (push) Canceled after 0s
源码快照 @ 2026-09-01 (source-only, 剔除非源码素材)
2026-09-01 20:17:27 +08:00

90 lines
2.4 KiB
TypeScript

import type { AgentActivitySession } from "@tutti-os/agent-activity-core";
import { resolveAgentGUIProviderDisplayLabel } from "../shared/agentConversationTitleProjection.ts";
export interface ResolveAgentGuiWorkbenchHeaderTitleInput {
agentName?: string | null;
conversationTitle?: string | null;
provider?: string | null;
}
export interface ResolveAgentGuiWorkbenchSessionTitleInput {
agentSessionId?: string | null;
fallbackTitle?: string | null;
optimisticTitle?: string | null;
session?: Pick<AgentActivitySession, "title"> | null;
}
export interface AgentGuiWorkbenchSessionTitleResult {
agentSessionId: string | null;
source: "snapshot" | "optimistic" | "fallback" | "none";
title: string | null;
}
export function resolveAgentGuiWorkbenchHeaderTitle({
agentName,
conversationTitle,
provider
}: ResolveAgentGuiWorkbenchHeaderTitleInput): string | null {
return (
stripTitle(agentName) ||
stripTitle(resolveAgentGUIProviderDisplayLabel(provider, "")) ||
stripTitle(conversationTitle) ||
null
);
}
export function resolveAgentGuiWorkbenchSessionTitle({
agentSessionId,
fallbackTitle,
optimisticTitle,
session = null
}: ResolveAgentGuiWorkbenchSessionTitleInput): AgentGuiWorkbenchSessionTitleResult {
const normalizedAgentSessionId = agentSessionId?.trim() ?? "";
if (!normalizedAgentSessionId) {
return { agentSessionId: null, source: "none", title: null };
}
const snapshotTitle = stripTitle(session?.title);
if (snapshotTitle) {
return {
agentSessionId: normalizedAgentSessionId,
source: "snapshot",
title: snapshotTitle
};
}
const projectedOptimisticTitle = stripTitle(optimisticTitle);
if (projectedOptimisticTitle) {
return {
agentSessionId: normalizedAgentSessionId,
source: "optimistic",
title: projectedOptimisticTitle
};
}
if (session) {
return {
agentSessionId: normalizedAgentSessionId,
source: "none",
title: null
};
}
const fallbackDisplayTitle = stripTitle(fallbackTitle);
return fallbackDisplayTitle
? {
agentSessionId: normalizedAgentSessionId,
source: "fallback",
title: fallbackDisplayTitle
}
: {
agentSessionId: normalizedAgentSessionId,
source: "none",
title: null
};
}
function stripTitle(value: string | null | undefined): string {
return value?.trim() ?? "";
}