different-ai/openwork · warning

File not found in this workspace.

Error message

File not found in this workspace.

What it means

When the artifact target is flagged as nonexistent (target.exists === false), the panel's query function throws 'File not found in this workspace.' so React Query shows an error state. This reflects that the workspace no longer (or never did) contain the file at target.value.

Source

Thrown at apps/app/src/react-app/domains/session/artifacts/artifact-panel.tsx:131

    const nextTarget = openTargetFromWorkspaceFile(entry.path, { size: entry.size, updatedAt: entry.mtimeMs });
    if (!nextTarget) return;
    usePanelTabStore.getState().openTab(sessionId, {
      id: nextTarget.id,
      type: "artifact",
      label: nextTarget.name,
      preview: nextTarget.preview,
      target: nextTarget,
    });
  };

  const { data, error, isError, isLoading } = useQuery<ArtifactQueryState>({
    queryKey: ["artifact-panel", workspaceId, target.id, target.updatedAt ?? null] as const,
    queryFn: async () => {
      if (target.kind === "url") {
        throw new Error("URLs open in browser tabs.");
      }
      else if (target.exists === false) {
        throw new Error("File not found in this workspace.");
      }

      if (isTextContent(target)) {
        const result = await client.readWorkspaceFile(workspaceId, target.value);

        return { kind: "text", data: result.content, updatedAt: result.updatedAt ?? null };
      }

      const result = await client.downloadWorkspaceFile(workspaceId, target.value);

      return { kind: "binary", data: result.data, contentType: result.contentType, updatedAt: target.updatedAt ?? null };
    },
    refetchOnReconnect: false,
    refetchOnWindowFocus: false,
    staleTime: Infinity,
    gcTime: 0,
  });

View on GitHub (pinned to 2b7df46e8a)

Solutions

  1. Refresh the session artifact list so deleted/moved files drop out of the panel.
  2. Verify the workspaceId and target.value path still correspond to an existing file.
  3. Restore the file or re-run the agent step that produced the artifact.
  4. Handle the isError state in the panel with a 'file no longer available' message instead of a raw error.

Example fix

// before: stale artifact opened directly
openArtifactPanel({ id, value: "reports/old.md", exists: false });
// after: refetch artifacts and open only existing ones
const artifacts = await refetchArtifacts();
const target = artifacts.find((a) => a.id === id && a.exists !== false);
if (target) openArtifactPanel(target);
Defensive patterns

Strategy: fallback

Validate before calling

if (target.exists === false) {
  return <EmptyState message="File not found in this workspace." />;
}

Type guard

function fileExists(target: ArtifactTarget): boolean {
  return target.kind === "file" && target.exists !== false;
}

Try / catch

const { data, isError, error } = useQuery({ queryKey: [...], queryFn });
if (isError && error.message === "File not found in this workspace.") {
  return <EmptyState message="This file is no longer available." onRefresh={refetchArtifacts} />;
}

Prevention

When it happens

Trigger: ArtifactPanelView's useQuery queryFn runs with target.exists === false — the workspace metadata says the file for this artifact is missing.

Common situations: File deleted or moved after the artifact entry was created; stale artifact list cached with an outdated updatedAt; workspace switched or re-provisioned so the referenced file path no longer exists; session resumed on a fresh workspace.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01). Data as JSON: /api/errors/fbf3a71933fac3a2. Report an issue: GitHub.