Skip to content

A desktop coding agent with free access to frontier models.

TypeScript
2.5 KB
Raw Blame
/** @jsxImportSource react */
import type { WorkspaceTasksClient } from "../../workspace/tasks/workspace-tasks-query";
import * as React from "react";
import type { WorkspaceConnectionState } from "../../../../app/types";
import type { SessionNumberShortcutOs } from "../../../shell/session-number-shortcuts";

export type SidebarContextValue = {
  /** Parallel tasks boards: the client that lists a workspace's tasks, and how to open a workspace's board. */
  parallelTasks?: { client: WorkspaceTasksClient; onOpen: (workspaceId: string) => void } | null;
  selectedWorkspaceId: string;
  selectedSessionId: string | null;
  developerMode: boolean;
  showSessionActions?: boolean;
  sessionStatusById?: Record<string, string>;
  newTaskDisabled: boolean;
  connectingWorkspaceId: string | null;
  workspaceConnectionStateById: Record<string, WorkspaceConnectionState>;
  onSelectWorkspace: (workspaceId: string) => Promise<boolean> | boolean | void;
  onOpenSession: (workspaceId: string, sessionId: string) => void;
  onPrefetchSession?: (workspaceId: string, sessionId: string) => void;
  onCreateTaskInWorkspace: (workspaceId: string, groupId?: string) => void;
  onCreateSplitTaskInWorkspace: (workspaceId: string) => void;
  onOpenRenameSession?: (sessionId: string) => void;
  onOpenDeleteSession?: (sessionId: string) => void;
  onArchiveSession?: (sessionId: string, archived: boolean) => void;
  archiveDisabledReason?: string;
  onOpenCreateGroupModal?: (workspaceId: string) => void;
  onOpenRenameWorkspace: (workspaceId: string) => void;
  onShareWorkspace: (workspaceId: string) => void;
  onRevealWorkspace: (workspaceId: string) => void;
  onRecoverWorkspace: (workspaceId: string) => Promise<boolean> | boolean | void;
  onTestWorkspaceConnection: (workspaceId: string) => Promise<boolean> | boolean | void;
  onRetryWorkspaceTasks?: (workspaceId: string) => void;
  onEditWorkspaceConnection: (workspaceId: string) => void;
  onForgetWorkspace: (workspaceId: string) => void;
  expandWorkspace: (workspaceId: string) => void;
  toggleWorkspaceExpanded: (workspaceId: string) => void;
  expandedWorkspaceIds: Set<string>;
  sessionNumberShortcutOs: SessionNumberShortcutOs;
  sessionNumberShortcutByTarget: ReadonlyMap<string, number>;
};

export const SidebarContext = React.createContext<SidebarContextValue | null>(null);

export function useSidebarContext() {
  const context = React.use(SidebarContext);
  if (!context) throw new Error("useSidebarContext must be used within SidebarProvider");
  return context;
}