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 { const response = await authApi.get("/open-tabs"); return response.data; } export async function syncOpenTabs(tabs: OpenTabSyncPayload[]): Promise { await authApi.put("/open-tabs", { tabs }); } export async function deleteOpenTab(instanceId: string): Promise { await authApi.delete(`/open-tabs/${instanceId}`); } export async function patchOpenTab( instanceId: string, updates: Partial< Pick >, ): Promise { await authApi.patch(`/open-tabs/${instanceId}`, updates); } export async function addOpenTab(tab: OpenTabUpsertPayload): Promise { await authApi.post("/open-tabs", tab); } export async function getActiveSessions(): Promise { 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; storageMode?: string | null; commandAutocomplete?: boolean | null; commandPaletteEnabled?: boolean | null; showHostTags?: boolean | null; hostTrayOnClick?: boolean | null; pinAppRail?: boolean | null; foldersCollapsed?: boolean | null; confirmSnippetExecution?: boolean | null; disableUpdateCheck?: boolean | null; confirmTabClose?: boolean | null; hiddenRailTabs?: string | null; } export async function getUserPreferences(): Promise { const response = await authApi.get("/user-preferences"); return response.data; } export async function saveUserPreferences( prefs: Partial, ): Promise { await authApi.put("/user-preferences", prefs); }