Compare commits

..
Author SHA1 Message Date
Mohamed Boudra cbedec1ed6 fix(app): keep a panel's render error inside that panel
A render exception in any workspace panel, in the explorer or a split
pane, had no boundary between it and the root error boundary, so it
replaced the whole app with the root error screen. A workspace saved
with that panel selected took the app down again on every open.

The plugin surface boundary already contained errors for plugin
surfaces. Its error-catching core is now a shared RenderErrorBoundary,
and the panel host wraps every mounted panel in it. A failed panel
shows the error with a Retry button; the other panels, the chat, the
sidebar and workspace switching keep working. Plugin surfaces keep
their own "Plugin failed" state because their boundary sits inside the
panel and catches first.
2026-11-29 17:53:33 +01:00
Feraidoon MehriandClaude Opus 5.5 d63f0204e5 fix(cli): list pending permissions of background agents in permit ls (#10655)
permit ls read one page of fetch_agents without includeBackground, so it missed requests from background agents and from any agent past the first 200. Read every page through fetchAllAgents and include background agents when the host supports them.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 16:12:45 +00:00
22 changed files with 388 additions and 191 deletions
@@ -205,7 +205,6 @@ export function useWorkspaceCommandCenterActions(): void {
const { overrides } = useKeyboardShortcutOverrides();
const { gitActions, isGit, archiveWorkspace } = useGitActions({
serverId: serverId ?? "",
workspaceId,
cwd: cwd ?? "",
icons: GIT_ACTION_ICONS,
});
@@ -0,0 +1,52 @@
import { Component, type ErrorInfo, type ReactNode } from "react";
interface RenderErrorBoundaryProps {
children: ReactNode;
/** A caught error is cleared when any of these values change, so new content renders. */
resetKeys: readonly unknown[];
/** The error state shown in place of the children. `retry` renders the children again. */
renderError(error: string, retry: () => void): ReactNode;
onError(error: unknown, componentStack: string | null | undefined): void;
}
interface RenderErrorBoundaryState {
error: string | null;
}
/**
* Keeps a render error inside one surface. Without it the error reaches the root boundary,
* which replaces the whole app.
*/
export class RenderErrorBoundary extends Component<
RenderErrorBoundaryProps,
RenderErrorBoundaryState
> {
state: RenderErrorBoundaryState = { error: null };
static getDerivedStateFromError(error: unknown): RenderErrorBoundaryState {
return { error: error instanceof Error ? error.message : String(error) };
}
componentDidCatch(error: unknown, info: ErrorInfo): void {
this.props.onError(error, info.componentStack);
}
componentDidUpdate(previous: RenderErrorBoundaryProps): void {
if (this.state.error !== null && resetKeysChanged(previous.resetKeys, this.props.resetKeys)) {
this.retry();
}
}
retry = (): void => {
this.setState({ error: null });
};
render() {
if (this.state.error !== null) return this.props.renderError(this.state.error, this.retry);
return this.props.children;
}
}
function resetKeysChanged(previous: readonly unknown[], next: readonly unknown[]): boolean {
return previous.length !== next.length || previous.some((key, index) => key !== next[index]);
}
@@ -1,80 +0,0 @@
import { afterEach, describe, expect, it } from "vitest";
import { useSessionStore, type WorkspaceDescriptor } from "@/stores/session-store";
import { selectGitActionsWorkspace } from "./actions-workspace";
const SERVER_ID = "git-actions-server";
function createWorkspace(id: string, workspaceDirectory: string): WorkspaceDescriptor {
return {
id,
projectId: "project-1",
projectDisplayName: "Project 1",
projectRootPath: workspaceDirectory,
workspaceDirectory,
projectKind: "git",
workspaceKind: "worktree",
name: id,
status: "done",
archivingAt: null,
statusEnteredAt: null,
diffStat: null,
scripts: [],
createdAt: null,
lastUserMessageAt: null,
};
}
function seed(workspaces: WorkspaceDescriptor[]): void {
const store = useSessionStore.getState();
store.initializeSession(SERVER_ID, null);
store.mergeWorkspaces(SERVER_ID, workspaces);
}
afterEach(() => {
useSessionStore.getState().clearSession(SERVER_ID);
});
describe("selectGitActionsWorkspace", () => {
it("resolves the workspace the git actions belong to, not another one in the same directory", () => {
seed([createWorkspace("ws-a", "/repo"), createWorkspace("ws-b", "/repo")]);
const workspace = selectGitActionsWorkspace(useSessionStore.getState(), {
serverId: SERVER_ID,
workspaceId: "ws-b",
workspaceDirectory: "/repo",
});
expect(workspace?.id).toBe("ws-b");
});
// Each retained workspace subscribes through this selector. Returning the same descriptor when
// another workspace on the host changes keeps hidden workspaces from re-rendering their git
// actions on every workspace switch.
it("keeps the descriptor reference when another workspace on the host changes", () => {
seed([createWorkspace("ws-a", "/repo-a"), createWorkspace("ws-b", "/repo-b")]);
const input = { serverId: SERVER_ID, workspaceId: "ws-a", workspaceDirectory: "/repo-a" };
const before = selectGitActionsWorkspace(useSessionStore.getState(), input);
useSessionStore
.getState()
.mergeWorkspaces(SERVER_ID, [{ ...createWorkspace("ws-b", "/repo-b"), status: "running" }]);
expect(useSessionStore.getState().sessions[SERVER_ID]?.workspaces.get("ws-b")?.status).toBe(
"running",
);
expect(before?.id).toBe("ws-a");
expect(selectGitActionsWorkspace(useSessionStore.getState(), input)).toBe(before);
});
it("falls back to the workspace in the checkout directory when the caller names no workspace", () => {
seed([createWorkspace("ws-a", "/repo-a"), createWorkspace("ws-b", "/repo-b")]);
const workspace = selectGitActionsWorkspace(useSessionStore.getState(), {
serverId: SERVER_ID,
workspaceId: null,
workspaceDirectory: "/repo-b",
});
expect(workspace?.id).toBe("ws-b");
});
});
-38
View File
@@ -1,38 +0,0 @@
import type { SessionsSnapshot } from "@/stores/session-store-hooks/selectors";
import type { WorkspaceDescriptor } from "@/stores/session-store";
import { resolveWorkspaceMapKeyByIdentity } from "@/utils/workspace-identity";
export interface GitActionsWorkspaceInput {
serverId: string;
/** The workspace that renders the git actions, or null when the caller has none. */
workspaceId: string | null | undefined;
/** The checkout directory, used to find the workspace when the caller names none. */
workspaceDirectory: string | null | undefined;
}
/**
* The workspace descriptor the git actions archive. Returns the stored descriptor itself, so a
* subscriber re-renders only when this workspace changes, not when another workspace on the host
* does.
*/
export function selectGitActionsWorkspace(
state: SessionsSnapshot,
input: GitActionsWorkspaceInput,
): WorkspaceDescriptor | null {
const workspaces = state.sessions[input.serverId]?.workspaces;
const workspaceKey = input.workspaceId
? resolveWorkspaceMapKeyByIdentity({ workspaces, workspaceId: input.workspaceId })
: null;
if (workspaceKey) {
return workspaces?.get(workspaceKey) ?? null;
}
if (!input.workspaceDirectory) {
return null;
}
for (const candidate of workspaces?.values() ?? []) {
if (candidate.workspaceDirectory === input.workspaceDirectory) {
return candidate;
}
}
return null;
}
-1
View File
@@ -1767,7 +1767,6 @@ export function ChangesSurface({
);
const { gitActions, branchLabel } = useGitActions({
serverId,
workspaceId,
cwd,
icons: GIT_ACTION_ICONS,
});
+46 -20
View File
@@ -28,11 +28,14 @@ import type { CheckoutPrMergeMethod } from "@getpaseo/protocol/messages";
import { openExternalUrl } from "@/utils/open-external-url";
import { useToast } from "@/contexts/toast-context";
import { useSessionStore, type WorkspaceDescriptor } from "@/stores/session-store";
import {
useActiveWorkspaceSelection,
type ActiveWorkspaceSelection,
} from "@/stores/navigation-active-workspace-store";
import { redirectIfArchivingActiveWorkspace } from "@/utils/sidebar-workspace-archive-redirect";
import { getFocusedWorkspaceSelection } from "@/navigation/workspace-route-navigation";
import { selectGitActionsWorkspace } from "@/git/actions-workspace";
import { type WorktreeArchiveWarningLabels } from "@/git/worktree-archive-warning";
import { useWorkspaceArchive } from "@/workspace/use-workspace-archive";
import { resolveWorkspaceMapKeyByIdentity } from "@/utils/workspace-identity";
import { readValidatedString } from "@/storage/validated-storage";
export type { GitActionId, GitAction, GitActions } from "@/git/policy";
@@ -197,8 +200,6 @@ function deriveGitActionsState(args: DeriveGitActionsStateArgs): DerivedGitActio
interface UseGitActionsInput {
serverId: string;
/** The workspace these actions belong to; a retained, hidden workspace passes its own. */
workspaceId: string | null | undefined;
cwd: string;
icons: {
commit: ReactElement;
@@ -221,13 +222,38 @@ interface UseGitActionsResult {
interface UseWorkspaceScreenArchiveControllerInput {
serverId: string;
workspaceId: string | null | undefined;
activeWorkspaceSelection: ActiveWorkspaceSelection | null;
workspaceDirectory: string | null | undefined;
branchLabel: string;
gitStatus: CheckoutStatusPayload | null;
t: (key: string, options?: Record<string, unknown>) => string;
}
function resolveArchiveWorkspaceDescriptor(input: {
workspaces: Map<string, WorkspaceDescriptor> | undefined;
activeWorkspaceSelection: ActiveWorkspaceSelection | null;
workspaceDirectory: string | null | undefined;
}): WorkspaceDescriptor | null {
const activeWorkspaceKey = input.activeWorkspaceSelection
? resolveWorkspaceMapKeyByIdentity({
workspaces: input.workspaces,
workspaceId: input.activeWorkspaceSelection.workspaceId,
})
: null;
if (activeWorkspaceKey) {
return input.workspaces?.get(activeWorkspaceKey) ?? null;
}
if (!input.workspaceDirectory) {
return null;
}
for (const candidate of input.workspaces?.values() ?? []) {
if (candidate.workspaceDirectory === input.workspaceDirectory) {
return candidate;
}
}
return null;
}
function resolveWorkspaceArchiveRisk(
workspace: WorkspaceDescriptor | null,
gitStatus: CheckoutStatusPayload | null,
@@ -258,16 +284,23 @@ function availableArchive(
function useWorkspaceScreenArchiveController({
serverId,
workspaceId,
activeWorkspaceSelection,
workspaceDirectory,
branchLabel,
gitStatus,
t,
}: UseWorkspaceScreenArchiveControllerInput) {
const workspaceDescriptor = useSessionStore((state) =>
selectGitActionsWorkspace(state, { serverId, workspaceId, workspaceDirectory }),
);
const sessionWorkspaces = useSessionStore((state) => state.sessions[serverId]?.workspaces);
const [isHidingWorkspace, setIsHidingWorkspace] = useState(false);
const workspaceDescriptor = useMemo(
() =>
resolveArchiveWorkspaceDescriptor({
workspaces: sessionWorkspaces,
activeWorkspaceSelection,
workspaceDirectory,
}),
[activeWorkspaceSelection, sessionWorkspaces, workspaceDirectory],
);
const archiveRisk = resolveWorkspaceArchiveRisk(workspaceDescriptor, gitStatus);
const controller = useWorkspaceArchive({
@@ -280,10 +313,7 @@ function useWorkspaceScreenArchiveController({
warningLabels: getWorktreeArchiveWarningLabels(t),
onSetHiding: setIsHidingWorkspace,
onArchiveStarted: (archived) => {
redirectIfArchivingActiveWorkspace({
...archived,
activeWorkspaceSelection: getFocusedWorkspaceSelection(),
});
redirectIfArchivingActiveWorkspace({ ...archived, activeWorkspaceSelection });
},
});
@@ -294,14 +324,10 @@ function useWorkspaceScreenArchiveController({
};
}
export function useGitActions({
serverId,
workspaceId,
cwd,
icons,
}: UseGitActionsInput): UseGitActionsResult {
export function useGitActions({ serverId, cwd, icons }: UseGitActionsInput): UseGitActionsResult {
const { t } = useTranslation();
const toast = useToast();
const activeWorkspaceSelection = useActiveWorkspaceSelection();
const [postShipArchiveSuggested, setPostShipArchiveSuggested] = useState(false);
const [shipDefault, setShipDefault] = useState<"merge" | "pr">("pr");
@@ -620,7 +646,7 @@ export function useGitActions({
const archiveController = useWorkspaceScreenArchiveController({
serverId,
workspaceId,
activeWorkspaceSelection,
workspaceDirectory: status?.cwd,
branchLabel,
gitStatus,
+1 -3
View File
@@ -4,14 +4,12 @@ import { useGitActions } from "@/git/use-actions";
interface WorkspaceActionsProps {
serverId: string;
workspaceId: string;
cwd: string;
}
export function WorkspaceActions({ serverId, workspaceId, cwd }: WorkspaceActionsProps) {
export function WorkspaceActions({ serverId, cwd }: WorkspaceActionsProps) {
const { gitActions } = useGitActions({
serverId,
workspaceId,
cwd,
icons: GIT_ACTION_ICONS,
});
+3
View File
@@ -2183,6 +2183,9 @@ export const ar: TranslationResources = {
archiveFinishedRetry: "إعادة المحاولة ({{failed}}/{{total}})",
},
panels: {
renderError: {
title: "تعذّر عرض هذه اللوحة",
},
draft: {
newAgent: "وكيل جديد",
creatingAgent: "وكيل الخلق",
+3
View File
@@ -2213,6 +2213,9 @@ export const en = {
archiveFinishedRetry: "Retry ({{failed}}/{{total}})",
},
panels: {
renderError: {
title: "Unable to show this panel",
},
draft: {
newAgent: "New Agent",
creatingAgent: "Creating agent",
+3
View File
@@ -2239,6 +2239,9 @@ export const es: TranslationResources = {
archiveFinishedRetry: "Reintentar ({{failed}}/{{total}})",
},
panels: {
renderError: {
title: "No se puede mostrar este panel",
},
draft: {
newAgent: "Nuevo agente",
creatingAgent: "Agente creador",
+3
View File
@@ -2236,6 +2236,9 @@ export const fr: TranslationResources = {
archiveFinishedRetry: "Réessayer ({{failed}}/{{total}})",
},
panels: {
renderError: {
title: "Impossible d'afficher ce panneau",
},
draft: {
newAgent: "Nouvel agent",
creatingAgent: "Création de l’agent",
+3
View File
@@ -2206,6 +2206,9 @@ export const ja: TranslationResources = {
archiveFinishedRetry: "再試行 ({{failed}}/{{total}})",
},
panels: {
renderError: {
title: "このパネルを表示できません",
},
draft: {
newAgent: "新しいエージェント",
creatingAgent: "エージェントを作成中",
+3
View File
@@ -2195,6 +2195,9 @@ export const ko: TranslationResources = {
archiveFinishedRetry: "다시 시도 ({{failed}}/{{total}})",
},
panels: {
renderError: {
title: "이 패널을 표시할 수 없습니다",
},
draft: {
newAgent: "새 에이전트",
creatingAgent: "에이전트 생성 중",
+3
View File
@@ -2223,6 +2223,9 @@ export const ptBR: TranslationResources = {
archiveFinishedRetry: "Tentar novamente ({{failed}}/{{total}})",
},
panels: {
renderError: {
title: "Não foi possível exibir este painel",
},
draft: {
newAgent: "Novo Agente",
creatingAgent: "Criando agente",
+3
View File
@@ -2223,6 +2223,9 @@ export const ru: TranslationResources = {
archiveFinishedRetry: "Повторить ({{failed}}/{{total}})",
},
panels: {
renderError: {
title: "Не удалось показать эту панель",
},
draft: {
newAgent: "Новый агент",
creatingAgent: "Создание агента",
+3
View File
@@ -2160,6 +2160,9 @@ export const zhCN: TranslationResources = {
archiveFinishedRetry: "重试 ({{failed}}/{{total}})",
},
panels: {
renderError: {
title: "无法显示此面板",
},
draft: {
newAgent: "新建 Agent",
creatingAgent: "正在创建 Agent",
@@ -1,6 +1,7 @@
import React, { Component, type ErrorInfo, type ReactNode } from "react";
import type { ReactNode } from "react";
import { Text } from "react-native";
import { StyleSheet } from "react-native-unistyles";
import { RenderErrorBoundary } from "@/components/render-error-boundary";
interface SurfaceErrorBoundaryProps {
children: ReactNode;
@@ -10,42 +11,30 @@ interface SurfaceErrorBoundaryProps {
renderError?(error: string): ReactNode;
}
interface SurfaceErrorBoundaryState {
error: string | null;
export function SurfaceErrorBoundary({
children,
installation,
resetKey,
Surface,
renderError,
}: SurfaceErrorBoundaryProps) {
return (
<RenderErrorBoundary
resetKeys={[installation, resetKey, Surface]}
onError={warnSurfaceRenderFailed}
renderError={renderError ?? renderPluginFailed}
>
{children}
</RenderErrorBoundary>
);
}
export class SurfaceErrorBoundary extends Component<
SurfaceErrorBoundaryProps,
SurfaceErrorBoundaryState
> {
state: SurfaceErrorBoundaryState = { error: null };
function renderPluginFailed(error: string) {
return <Text style={styles.errorText}>Plugin failed: {error}</Text>;
}
static getDerivedStateFromError(error: unknown): SurfaceErrorBoundaryState {
return { error: error instanceof Error ? error.message : String(error) };
}
componentDidCatch(error: Error, info: ErrorInfo): void {
console.warn("[Plugins] Surface render failed", error, info.componentStack);
}
componentDidUpdate(previous: SurfaceErrorBoundaryProps): void {
if (
this.state.error &&
(previous.installation !== this.props.installation ||
previous.resetKey !== this.props.resetKey ||
previous.Surface !== this.props.Surface)
) {
this.setState({ error: null });
}
}
render() {
if (this.state.error) {
if (this.props.renderError) return this.props.renderError(this.state.error);
return <Text style={styles.errorText}>Plugin failed: {this.state.error}</Text>;
}
return this.props.children;
}
function warnSurfaceRenderFailed(error: unknown, componentStack: string | null | undefined): void {
console.warn("[Plugins] Surface render failed", error, componentStack);
}
const styles = StyleSheet.create((theme) => ({
@@ -0,0 +1,131 @@
/**
* @vitest-environment jsdom
*/
import { act } from "@testing-library/react";
import React from "react";
import { createRoot, type Root } from "react-dom/client";
import { Text, View } from "react-native";
import { afterEach, describe, expect, it, vi } from "vitest";
import { definePanel, registerPanel } from "@/panels/panel-registry";
import { buildWorkspacePaneContentModel } from "@/screens/workspace/workspace-pane-content";
import { WorkspacePanelHost } from "@/screens/workspace/workspace-panel-host";
import type { WorkspaceTabDescriptor } from "@/screens/workspace/workspace-tabs-types";
let panelFails = true;
function FailingPanel() {
if (panelFails) throw new Error("Changes exploded");
return <Text>Changes recovered</Text>;
}
function HealthyPanel() {
return <Text>Draft panel</Text>;
}
// The workspace screen registers the real panels; these stand in for the two kinds the test opens.
registerPanel(
definePanel("agent", {
component: FailingPanel,
useDescriptor: () => {
throw new Error("The test panel has no descriptor");
},
}),
);
registerPanel(
definePanel("draft", {
component: HealthyPanel,
useDescriptor: () => {
throw new Error("The test panel has no descriptor");
},
}),
);
const failingTab: WorkspaceTabDescriptor = {
key: "agent_agent-a",
tabId: "agent_agent-a",
kind: "agent",
target: { kind: "agent", agentId: "agent-a" },
};
const healthyTab: WorkspaceTabDescriptor = {
key: "draft_draft-a",
tabId: "draft_draft-a",
kind: "draft",
target: { kind: "draft", draftId: "draft-a" },
};
function buildContent({ tab }: { paneId: string; tab: WorkspaceTabDescriptor }) {
return buildWorkspacePaneContentModel({
tab,
normalizedServerId: "server-a",
normalizedWorkspaceId: "workspace-a",
host: "main",
onOpenTab: vi.fn(),
onOpenPreferredTarget: vi.fn(),
onOpenTargetToSide: vi.fn(),
onCloseCurrentTab: vi.fn(),
onRetargetCurrentTab: vi.fn(),
onSetCurrentTabState: vi.fn(),
onOpenWorkspaceFile: vi.fn(),
onOpenImportSheet: vi.fn(),
});
}
function Workspace({ activeTabId }: { activeTabId: string }) {
return (
<View>
<Text>Sidebar</Text>
<WorkspacePanelHost
paneId="pane-a"
tabs={[failingTab, healthyTab]}
activeTabId={activeTabId}
normalizedServerId="server-a"
normalizedWorkspaceId="workspace-a"
isWorkspaceFocused
isPaneFocused
buildPaneContentModel={buildContent}
/>
</View>
);
}
function byTestId(container: HTMLElement, testID: string): HTMLElement | null {
return container.querySelector(`[data-testid="${testID}"]`);
}
describe("WorkspacePanelHost", () => {
let root: Root | null = null;
let container: HTMLElement | null = null;
afterEach(() => {
if (root) act(() => root?.unmount());
root = null;
container?.remove();
container = null;
panelFails = true;
vi.restoreAllMocks();
});
it("keeps a panel's render error inside that panel and retries it", () => {
vi.spyOn(console, "error").mockImplementation(() => undefined);
vi.spyOn(console, "warn").mockImplementation(() => undefined);
container = document.createElement("div");
document.body.appendChild(container);
root = createRoot(container);
act(() => root?.render(<Workspace activeTabId={failingTab.tabId} />));
expect(container.textContent).toContain("Sidebar");
expect(byTestId(container, "panel-render-error")?.textContent).toContain("Changes exploded");
act(() => root?.render(<Workspace activeTabId={healthyTab.tabId} />));
expect(container.textContent).toContain("Draft panel");
panelFails = false;
act(() => root?.render(<Workspace activeTabId={failingTab.tabId} />));
const retry = byTestId(container, "panel-render-error-retry");
expect(retry).not.toBeNull();
act(() => retry?.click());
expect(byTestId(container, "panel-render-error")).toBeNull();
expect(container.textContent).toContain("Changes recovered");
expect(container.textContent).toContain("Sidebar");
});
});
@@ -1,5 +1,11 @@
import { memo, useCallback, useEffect, useMemo, useRef } from "react";
import { useTranslation } from "react-i18next";
import { View } from "react-native";
import { StyleSheet } from "react-native-unistyles";
import { RenderErrorBoundary } from "@/components/render-error-boundary";
import { RetainedPanel } from "@/components/retained-panel";
import { Alert } from "@/components/ui/alert";
import { Button } from "@/components/ui/button";
import { useModifiedPanelTabIds } from "@/panels/panel-instance-attributes";
import {
WorkspacePaneContent,
@@ -52,17 +58,44 @@ const MountedTab = memo(function MountedTab({
return (
<RenderProfile id={`DesktopMountedTab:${tab.kind}:${tab.tabId}`}>
<RetainedPanel active={visible}>
<WorkspacePaneContent
content={content}
isWorkspaceFocused={isWorkspaceFocused}
isPaneFocused={interactive}
onFocusPane={onFocusPane ? handleFocusPane : undefined}
/>
<RenderErrorBoundary
resetKeys={[tab]}
onError={logPanelRenderError}
renderError={renderPanelError}
>
<WorkspacePaneContent
content={content}
isWorkspaceFocused={isWorkspaceFocused}
isPaneFocused={interactive}
onFocusPane={onFocusPane ? handleFocusPane : undefined}
/>
</RenderErrorBoundary>
</RetainedPanel>
</RenderProfile>
);
});
function logPanelRenderError(error: unknown, componentStack: string | null | undefined): void {
console.error("[WorkspacePanel] Render failed", error, componentStack);
}
function renderPanelError(error: string, retry: () => void) {
return <PanelRenderError error={error} onRetry={retry} />;
}
function PanelRenderError({ error, onRetry }: { error: string; onRetry: () => void }) {
const { t } = useTranslation();
return (
<View style={styles.renderError} testID="panel-render-error">
<Alert variant="error" title={t("panels.renderError.title")} description={error}>
<Button variant="outline" size="sm" onPress={onRetry} testID="panel-render-error-retry">
{t("common.actions.retry")}
</Button>
</Alert>
</View>
);
}
function useStableTabs(tabs: WorkspaceTabDescriptor[]) {
const cacheRef = useRef(new Map<string, WorkspaceTabDescriptor>());
const stableTabs = useMemo(() => {
@@ -136,3 +169,9 @@ export function WorkspacePanelHost({
);
});
}
const styles = StyleSheet.create((theme) => ({
renderError: {
padding: theme.spacing[4],
},
}));
@@ -3283,11 +3283,7 @@ function WorkspaceScreenContent({
) : null}
{workspaceDirectory ? (
<>
<WorkspaceActions
serverId={normalizedServerId}
workspaceId={normalizedWorkspaceId}
cwd={workspaceDirectory}
/>
<WorkspaceActions serverId={normalizedServerId} cwd={workspaceDirectory} />
{workspaceActionsInBar ? null : explorerControls.headerAction}
</>
) : null}
+19 -2
View File
@@ -2,6 +2,7 @@ import type { Command } from "commander";
import type { AgentPermissionRequest } from "@getpaseo/protocol/agent-types";
import type { AgentSnapshotPayload } from "@getpaseo/protocol/messages";
import { connectToDaemon } from "../../utils/client.js";
import { fetchAllAgents, type AgentDirectoryClient } from "../../utils/agent-directory.js";
import type { CommandOptions, ListResult, OutputSchema, CommandError } from "../../output/index.js";
/** Permission list item for display */
@@ -56,6 +57,23 @@ export function listPendingPermissions(agents: AgentSnapshotPayload[]): PermitLs
};
}
export interface PermitAgentsClient extends AgentDirectoryClient {
supportsBackgroundWorkspaces(): boolean;
}
/**
* Read every agent that can hold a pending permission: all pages, and background agents too,
* since unattended workers are the ones most likely to be waiting on a prompt.
*/
export function fetchPermitAgents(client: PermitAgentsClient): Promise<AgentSnapshotPayload[]> {
return fetchAllAgents(client, {
filter: {
includeArchived: true,
...(client.supportsBackgroundWorkspaces() ? { includeBackground: true } : {}),
},
});
}
export interface PermitLsOptions extends CommandOptions {
host?: string;
}
@@ -67,8 +85,7 @@ export async function runLsCommand(
const client = await connectToDaemon({ target: options.daemonTarget });
try {
const agentsPayload = await client.fetchAgents({ filter: { includeArchived: true } });
const agents = agentsPayload.entries.map((entry) => entry.agent);
const agents = await fetchPermitAgents(client);
await client.close();
return listPendingPermissions(agents);
@@ -3,7 +3,7 @@ import type { AgentSnapshotPayload } from "@getpaseo/protocol/messages";
import { describe, expect, it } from "vitest";
import { render } from "../../output/render.js";
import { permitResponseSchema, toPermissionResponseItem } from "./allow.js";
import { listPendingPermissions } from "./ls.js";
import { fetchPermitAgents, listPendingPermissions } from "./ls.js";
const agentId = "2d85f428-fdaf-4d98-906f-c583de2b805f";
@@ -43,3 +43,45 @@ describe("permit allow and deny output", () => {
expect(answered.map((item) => item.requestId)).toEqual([writeRequest.id]);
});
});
describe("permit ls agent directory read", () => {
function fakeClient(pages: AgentSnapshotPayload[][], supportsBackground: boolean) {
const calls: unknown[] = [];
return {
calls,
supportsBackgroundWorkspaces: () => supportsBackground,
async fetchAgents(options?: unknown) {
calls.push(options);
const index = calls.length - 1;
return {
entries: (pages[index] ?? []).map((entry) => ({ agent: entry })),
pageInfo: { nextCursor: index + 1 < pages.length ? `cursor-${index + 1}` : null },
};
},
};
}
it("includes background agents and reads past the first page", async () => {
const backgroundAgent = {
id: "7b0e3f52-9d1c-4f0a-8a59-0f1d2e3c4b5a",
pendingPermissions: [writeRequest],
} as AgentSnapshotPayload;
const client = fakeClient([[{ id: agentId } as AgentSnapshotPayload], [backgroundAgent]], true);
const result = listPendingPermissions(await fetchPermitAgents(client));
expect(result.data.map((item) => item.agentId)).toEqual([backgroundAgent.id]);
expect(client.calls).toEqual([
expect.objectContaining({ filter: { includeArchived: true, includeBackground: true } }),
expect.objectContaining({ page: expect.objectContaining({ cursor: "cursor-1" }) }),
]);
});
it("leaves background out on hosts without background workspaces", async () => {
const client = fakeClient([[agent]], false);
await fetchPermitAgents(client);
expect(client.calls).toEqual([expect.objectContaining({ filter: { includeArchived: true } })]);
});
});