61723934b9
* fix: isolate saved layouts from stale sessions * fix: preserve session tabs in saved layouts * fix: handle materialized saved layout visibility * fix: preserve sibling sessions on env switch * fix: load task sessions before saved layouts * fix: preserve sibling tabs on layout fast paths * test: cover layout session id deduplication
21 lines
758 B
TypeScript
21 lines
758 B
TypeScript
type LayoutSession = { id: string };
|
|
|
|
export async function resolveLayoutApplySessionIds(args: {
|
|
activeTaskId: string | null;
|
|
activeSessionId: string | null;
|
|
sessionsLoaded: boolean;
|
|
loadSessions: (force?: boolean) => Promise<unknown> | unknown;
|
|
getSessionsForTask: (taskId: string) => readonly LayoutSession[];
|
|
}): Promise<string[]> {
|
|
const { activeTaskId, activeSessionId, sessionsLoaded, loadSessions, getSessionsForTask } = args;
|
|
if (activeTaskId && !sessionsLoaded) await loadSessions(true);
|
|
|
|
const sessionIds = activeTaskId
|
|
? getSessionsForTask(activeTaskId).map((session) => session.id)
|
|
: [];
|
|
if (activeSessionId && !sessionIds.includes(activeSessionId)) {
|
|
sessionIds.unshift(activeSessionId);
|
|
}
|
|
return sessionIds;
|
|
}
|