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:
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user