2b60dd2932
Persist platform_source across session creation, transcript ingestion, API query paths, and viewer state so Claude and Codex data can coexist without bleeding into each other. - add platform-source normalization helpers and persist platform_source in sdk_sessions via migration 24 with backfill and indexing - thread platformSource through CLI hooks, transcript processing, context generation, pagination, search routes, SSE payloads, and session management - expose source-aware project catalogs, viewer tabs, context preview selectors, and source badges for observations, prompts, and summaries - start the transcript watcher from the worker for transcript-based clients and preserve platform source during Codex ingestion - auto-start the worker from the MCP server for MCP-only clients and tighten stdio-driven cleanup during shutdown - keep createSDKSession backward compatible with existing custom-title callers while allowing explicit platform source forwarding
37 lines
1.0 KiB
TypeScript
37 lines
1.0 KiB
TypeScript
export const DEFAULT_PLATFORM_SOURCE = 'claude';
|
|
|
|
function sanitizeRawSource(value: string): string {
|
|
return value.trim().toLowerCase().replace(/\s+/g, '-');
|
|
}
|
|
|
|
export function normalizePlatformSource(value?: string | null): string {
|
|
if (!value) return DEFAULT_PLATFORM_SOURCE;
|
|
|
|
const source = sanitizeRawSource(value);
|
|
if (!source) return DEFAULT_PLATFORM_SOURCE;
|
|
|
|
if (source === 'transcript') return 'codex';
|
|
if (source.includes('codex')) return 'codex';
|
|
if (source.includes('cursor')) return 'cursor';
|
|
if (source.includes('claude')) return 'claude';
|
|
|
|
return source;
|
|
}
|
|
|
|
export function sortPlatformSources(sources: string[]): string[] {
|
|
const priority = ['claude', 'codex', 'cursor'];
|
|
|
|
return [...sources].sort((a, b) => {
|
|
const aPriority = priority.indexOf(a);
|
|
const bPriority = priority.indexOf(b);
|
|
|
|
if (aPriority !== -1 || bPriority !== -1) {
|
|
if (aPriority === -1) return 1;
|
|
if (bPriority === -1) return -1;
|
|
return aPriority - bPriority;
|
|
}
|
|
|
|
return a.localeCompare(b);
|
|
});
|
|
}
|