feat(web/ui): unify session opening and add repo card in project list

- Add openSession utility with tab deduplication/focus
- Use openSession in navbar live sessions, use-instance-actions, and project tool links
- Pass onAddRepository to ProjectListItem and add dashed 'Add Repository' card
- Style add-repo card in projects.css
This commit is contained in:
Developer
2026-06-16 21:31:38 +00:00
parent d5119f29f6
commit bf698b3ff2
6 changed files with 82 additions and 67 deletions
+24
View File
@@ -0,0 +1,24 @@
import type { Session } from "../api/sessions";
const tabRefs = new Map<string, Window | null>();
export function openSession(session: Session): void {
const key = session.id;
const existing = tabRefs.get(key);
if (existing && !existing.closed) {
existing.focus();
return;
}
let url: string;
if (session.url) {
url = session.url;
} else if (session.tool_type_interfaces?.includes("terminal")) {
url = `/instances/${session.id}/terminal`;
} else {
url = `/projects/${session.project_id}`;
}
const w = window.open(url, `session-${session.id}`);
tabRefs.set(key, w);
}