Files
Termix/src/ui/api/open-tabs-api.ts
T

112 lines
2.9 KiB
TypeScript
Raw Normal View History

2026-06-04 15:16:53 -04:00
import { authApi } from "@/main-axios";
// OPEN TABS API
// ============================================================================
export interface OpenTabRecord {
id: string;
userId: string;
tabType: string;
hostId: number | null;
label: string;
tabOrder: number;
backendSessionId: string | null;
createdAt: string;
updatedAt: string;
}
export interface OpenTabSyncPayload {
id: string;
tabType: string;
hostId?: number | null;
label: string;
tabOrder: number;
backendSessionId?: string | null;
}
export interface OpenTabUpsertPayload {
id: string;
tabType: string;
hostId?: number | null;
label: string;
tabOrder: number;
backendSessionId?: string | null;
}
export interface ActiveSessionInfo {
sessionId: string;
hostId: number;
hostName: string;
tabInstanceId: string | null;
isConnected: boolean;
createdAt: number;
}
export async function getOpenTabs(): Promise<OpenTabRecord[]> {
const response = await authApi.get("/open-tabs");
return response.data;
}
export async function syncOpenTabs(tabs: OpenTabSyncPayload[]): Promise<void> {
await authApi.put("/open-tabs", { tabs });
}
export async function deleteOpenTab(instanceId: string): Promise<void> {
await authApi.delete(`/open-tabs/${instanceId}`);
}
export async function patchOpenTab(
instanceId: string,
updates: Partial<
Pick<OpenTabRecord, "label" | "tabOrder" | "backendSessionId">
>,
): Promise<void> {
await authApi.patch(`/open-tabs/${instanceId}`, updates);
}
export async function addOpenTab(tab: OpenTabUpsertPayload): Promise<void> {
await authApi.post("/open-tabs", tab);
}
export async function getActiveSessions(): Promise<ActiveSessionInfo[]> {
const response = await authApi.get("/open-tabs/active-sessions");
return response.data;
}
// ============================================================================
// USER PREFERENCES API
// ============================================================================
export interface UserPreferences {
reopenTabsOnLogin: boolean;
theme?: string | null;
fontSize?: string | null;
accentColor?: string | null;
language?: string | null;
+2
2026-06-16 15:59:53 -05:00
storageMode?: string | null;
commandAutocomplete?: boolean | null;
commandPaletteEnabled?: boolean | null;
showHostTags?: boolean | null;
hostTrayOnClick?: boolean | null;
pinAppRail?: boolean | null;
2026-06-29 13:28:26 -05:00
expandAppRailOnHover?: boolean | null;
+2
2026-06-16 15:59:53 -05:00
foldersCollapsed?: boolean | null;
confirmSnippetExecution?: boolean | null;
disableUpdateCheck?: boolean | null;
confirmTabClose?: boolean | null;
hiddenRailTabs?: string | null;
2026-06-21 15:55:41 -05:00
compactHostView?: boolean | null;
statusColorScheme?: string | null;
2026-06-04 15:16:53 -04:00
}
export async function getUserPreferences(): Promise<UserPreferences> {
const response = await authApi.get("/user-preferences");
return response.data;
}
export async function saveUserPreferences(
prefs: Partial<UserPreferences>,
): Promise<void> {
await authApi.put("/user-preferences", prefs);
}