mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-21 16:27:18 +02:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Agent work is issue-centered, and reviewers often need to inspect files, artifacts, and path references produced during that work. > - Before this branch, workspace-relative paths and artifact file references were not first-class inspectable objects in the board UI. > - Safe file viewing needs shared resource contracts, server-side workspace boundary checks, and UI that opens files without exposing arbitrary host paths. > - The workspace file viewer branch needed to stay as one active PR and be rebased onto current `paperclipai/paperclip:master` for review. > - This pull request adds the workspace file resource API, issue-page file viewer and browser, markdown file-reference links, and artifact file chips. > - The benefit is that board users can inspect relevant files from issue context while preserving workspace boundaries and auditability. ## Linked Issues or Issue Description No public GitHub issue exists for this branch. Internal Paperclip issues: `PAP-1953`, `PAP-10539`, `PAP-10733`. Problem / motivation: - Board users need to open workspace-relative files mentioned by agents or attached as work-product metadata without switching to a terminal. - The UI needs to support both direct file-path opening and workspace browsing/searching from an issue page. - The server must enforce company access, workspace boundaries, size limits, rate limits, and safe audit logging. Related PR: - Prior closed attempt: #4442 - Single active PR for this branch: #7681 ## What Changed - Added shared workspace file resource types, validators, and workspace-file `resourceRef` metadata validation for work products. - Added server routes/services for resolving, listing, and previewing workspace-relative files with access checks, scan caps, list-specific limits, and audit logging. - Added the issue file viewer provider, sheet, workspace browser, command-palette action, markdown workspace-file autolinks, and artifact file chips. - Updated issue workspace UI and stories/tests for file browsing and workspace file opening. - Rebased the branch onto current `paperclipai/paperclip:master` and updated the existing single PR branch. - Addressed current-head Greptile follow-ups by applying `offset` consistently across search/recent/changed file listings, restoring stopped-service port ownership checks before auto-port reuse, and stabilizing the workspace browser pagination test. ## Verification Current local verification after rebase to `public/master`: - `pnpm exec vitest run packages/shared/src/work-product.test.ts server/src/__tests__/file-resources.test.ts server/src/__tests__/instance-settings-routes.test.ts server/src/__tests__/instance-settings-service.test.ts server/src/__tests__/workspace-runtime.test.ts ui/src/components/FileViewerSheet.test.tsx ui/src/components/FileViewerSheet.copy.test.tsx ui/src/components/WorkspaceFileBrowser.test.tsx ui/src/components/WorkspaceFileMarkdownBody.test.tsx ui/src/context/FileViewerContext.test.ts ui/src/lib/remark-workspace-file-refs.test.ts ui/src/lib/workspace-file-parser.test.ts ui/src/components/IssueWorkspaceCard.test.tsx` - 13 files passed, 197 tests passed. - `pnpm -r --filter @paperclipai/shared --filter @paperclipai/server --filter @paperclipai/ui typecheck` - passed. - `pnpm exec vitest run ui/src/components/WorkspaceFileBrowser.test.tsx` - 1 file passed, 25 tests passed. - `pnpm exec vitest run server/src/__tests__/file-resources.test.ts server/src/__tests__/workspace-runtime.test.ts` - 2 files passed, 90 tests passed. - `pnpm -r --filter @paperclipai/server typecheck` - passed. - Confirmed branch is `0` behind and `46` ahead of current `public/master` after rebase and follow-up commits. - Confirmed the PR diff does not include `pnpm-lock.yaml`. - Confirmed the PR diff does not include `.github/workflows` changes. - Searched GitHub for duplicate or related workspace file viewer PRs/issues; #4442 is the prior closed attempt and this PR is the single active PR for the branch. - No screenshots were committed; the task explicitly asked not to add design screenshots or images unless they were part of the work. Current remote verification on head `a698a7bc10137baf7d25bd5722e1d6e0343387c1`: - Greptile Review - success, 64 files reviewed, 0 comments added, no unresolved Greptile review threads. - PR workflow `verify` - success. - Typecheck + Release Registry, General tests, workspace test shards, serialized server suites, Build, Canary Dry Run, e2e, Socket, and Snyk - success. - `security-review` - neutral, with output saying a draft advisory was filed for maintainer review and is not a merge block. - `commitperclip PR Review / review` - cancelled after the security gate detected flags and timed out while creating/reviewing the advisory. I reran it once and it cancelled the same way; no actionable code/test failure was exposed in the job logs. ## Risks - This is a broad UI/server feature PR, so review needs to pay attention to route authorization, workspace boundary handling, and markdown autolink false positives. - Workspace browsing intentionally caps list results and scan depth; very large workspaces may require users to refine search terms. - Remote workspace preview remains unavailable until remote file-access support is implemented. - The neutral commitperclip security-review advisory needs maintainer review, but the check output says it is not a merge block. > For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and discuss it in `#dev` before opening the PR. Feature PRs that overlap with planned core work may need to be redirected - check the roadmap first. See `CONTRIBUTING.md`. ## Model Used - OpenAI Codex, GPT-5 coding agent in a Paperclip/Codex local tool-use environment, medium reasoning, with shell/GitHub CLI tool use for branch inspection, verification, rebase, PR update, Greptile review, and CI inspection. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [ ] If this change affects the UI, I have included before/after screenshots - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge --------- Co-authored-by: Paperclip <noreply@paperclip.ing> Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
261 lines
14 KiB
TypeScript
261 lines
14 KiB
TypeScript
export const queryKeys = {
|
|
companies: {
|
|
all: ["companies"] as const,
|
|
detail: (id: string) => ["companies", id] as const,
|
|
stats: ["companies", "stats"] as const,
|
|
},
|
|
companySkills: {
|
|
list: (companyId: string) => ["company-skills", companyId] as const,
|
|
detail: (companyId: string, skillId: string) => ["company-skills", companyId, skillId] as const,
|
|
updateStatus: (companyId: string, skillId: string) =>
|
|
["company-skills", companyId, skillId, "update-status"] as const,
|
|
file: (companyId: string, skillId: string, relativePath: string) =>
|
|
["company-skills", companyId, skillId, "file", relativePath] as const,
|
|
catalog: (filters: { kind?: string; category?: string; q?: string } = {}) =>
|
|
["company-skills", "catalog", filters.kind ?? "__all-kinds__", filters.category ?? "__all-categories__", filters.q ?? ""] as const,
|
|
catalogDetail: (catalogRef: string) => ["company-skills", "catalog", "detail", catalogRef] as const,
|
|
catalogFile: (catalogRef: string, relativePath: string) =>
|
|
["company-skills", "catalog", "file", catalogRef, relativePath] as const,
|
|
},
|
|
teamCatalog: {
|
|
catalog: (filters: { kind?: string; category?: string; q?: string } = {}) =>
|
|
["team-catalog", "catalog", filters.kind ?? "__all-kinds__", filters.category ?? "__all-categories__", filters.q ?? ""] as const,
|
|
catalogDetail: (catalogRef: string) => ["team-catalog", "catalog", "detail", catalogRef] as const,
|
|
catalogFile: (catalogRef: string, relativePath: string) =>
|
|
["team-catalog", "catalog", "file", catalogRef, relativePath] as const,
|
|
installed: (companyId: string) => ["team-catalog", "installed", companyId] as const,
|
|
},
|
|
agents: {
|
|
list: (companyId: string) => ["agents", companyId] as const,
|
|
detail: (id: string) => ["agents", "detail", id] as const,
|
|
runtimeState: (id: string) => ["agents", "runtime-state", id] as const,
|
|
taskSessions: (id: string) => ["agents", "task-sessions", id] as const,
|
|
skills: (id: string) => ["agents", "skills", id] as const,
|
|
instructionsBundle: (id: string) => ["agents", "instructions-bundle", id] as const,
|
|
instructionsFile: (id: string, relativePath: string) =>
|
|
["agents", "instructions-bundle", id, "file", relativePath] as const,
|
|
keys: (agentId: string) => ["agents", "keys", agentId] as const,
|
|
configRevisions: (agentId: string) => ["agents", "config-revisions", agentId] as const,
|
|
adapterModels: (companyId: string, adapterType: string, environmentId?: string | null) =>
|
|
["agents", companyId, "adapter-models", adapterType, environmentId ?? null] as const,
|
|
adapterModelProfiles: (companyId: string, adapterType: string) =>
|
|
["agents", companyId, "adapter-model-profiles", adapterType] as const,
|
|
detectModel: (companyId: string, adapterType: string) =>
|
|
["agents", companyId, "detect-model", adapterType] as const,
|
|
},
|
|
issues: {
|
|
list: (companyId: string) => ["issues", companyId] as const,
|
|
search: (companyId: string, q: string, projectId?: string, limit?: number) =>
|
|
["issues", companyId, "search", q, projectId ?? "__all-projects__", limit ?? "__no-limit__"] as const,
|
|
listAssignedToMe: (companyId: string) => ["issues", companyId, "assigned-to-me"] as const,
|
|
listMineByMe: (companyId: string) => ["issues", companyId, "mine-by-me"] as const,
|
|
listTouchedByMe: (companyId: string) => ["issues", companyId, "touched-by-me"] as const,
|
|
listUnreadTouchedByMe: (companyId: string) => ["issues", companyId, "unread-touched-by-me"] as const,
|
|
listBlockedAttention: (companyId: string) => ["issues", companyId, "blocked-attention"] as const,
|
|
countBlockedAttention: (companyId: string) => ["issues", companyId, "blocked-attention", "count"] as const,
|
|
labels: (companyId: string) => ["issues", companyId, "labels"] as const,
|
|
listByProject: (companyId: string, projectId: string) =>
|
|
["issues", companyId, "project", projectId] as const,
|
|
listPluginOperationsByProject: (companyId: string, projectId: string, originKindPrefix: string) =>
|
|
["issues", companyId, "project", projectId, "plugin-operations", originKindPrefix] as const,
|
|
listByParent: (companyId: string, parentId: string) =>
|
|
["issues", companyId, "parent", parentId] as const,
|
|
listByDescendantRoot: (companyId: string, rootIssueId: string) =>
|
|
["issues", companyId, "descendants", rootIssueId] as const,
|
|
listByExecutionWorkspace: (companyId: string, executionWorkspaceId: string) =>
|
|
["issues", companyId, "execution-workspace", executionWorkspaceId] as const,
|
|
detail: (id: string) => ["issues", "detail", id] as const,
|
|
comments: (issueId: string) => ["issues", "comments", issueId] as const,
|
|
interactions: (issueId: string) => ["issues", "interactions", issueId] as const,
|
|
acceptedPlanDecompositions: (issueId: string) =>
|
|
["issues", "accepted-plan-decompositions", issueId] as const,
|
|
feedbackVotes: (issueId: string) => ["issues", "feedback-votes", issueId] as const,
|
|
costSummary: (issueId: string, options: { excludeRoot?: boolean } = {}) =>
|
|
options.excludeRoot
|
|
? (["issues", "cost-summary", issueId, "exclude-root"] as const)
|
|
: (["issues", "cost-summary", issueId] as const),
|
|
attachments: (issueId: string) => ["issues", "attachments", issueId] as const,
|
|
attachmentPreview: (attachmentId: string) => ["issues", "attachment-preview", attachmentId] as const,
|
|
documents: (issueId: string) => ["issues", "documents", issueId] as const,
|
|
document: (issueId: string, key: string) => ["issues", "document", issueId, key] as const,
|
|
documentRevisions: (issueId: string, key: string) => ["issues", "document-revisions", issueId, key] as const,
|
|
documentAnnotations: (issueId: string, key: string, status: "open" | "resolved" | "all" = "all") =>
|
|
["issues", "document-annotations", issueId, key, status] as const,
|
|
activity: (issueId: string) => ["issues", "activity", issueId] as const,
|
|
runs: (issueId: string) => ["issues", "runs", issueId] as const,
|
|
approvals: (issueId: string) => ["issues", "approvals", issueId] as const,
|
|
liveRuns: (issueId: string) => ["issues", "live-runs", issueId] as const,
|
|
activeRun: (issueId: string) => ["issues", "active-run", issueId] as const,
|
|
workProducts: (issueId: string) => ["issues", "work-products", issueId] as const,
|
|
fileResources: (
|
|
issueId: string,
|
|
options: {
|
|
workspace?: string;
|
|
projectId?: string | null;
|
|
workspaceId?: string | null;
|
|
path?: string | null;
|
|
mode?: string;
|
|
q?: string | null;
|
|
limit?: number;
|
|
offset?: number;
|
|
} = {},
|
|
) =>
|
|
["issues", "file-resources", issueId, "list", options] as const,
|
|
fileResource: (
|
|
issueId: string,
|
|
query: { path: string; workspace?: string; projectId?: string | null; workspaceId?: string | null },
|
|
) =>
|
|
["issues", "file-resources", issueId, "resolve", query] as const,
|
|
fileResourceContent: (
|
|
issueId: string,
|
|
query: { path: string; workspace?: string; projectId?: string | null; workspaceId?: string | null },
|
|
) =>
|
|
["issues", "file-resources", issueId, "content", query] as const,
|
|
},
|
|
routines: {
|
|
list: (companyId: string, filters?: { projectId?: string | null }) =>
|
|
["routines", companyId, filters?.projectId ?? "__all-projects__"] as const,
|
|
detail: (id: string) => ["routines", "detail", id] as const,
|
|
runs: (id: string) => ["routines", "runs", id] as const,
|
|
revisions: (id: string) => ["routines", "revisions", id] as const,
|
|
activity: (companyId: string, id: string) => ["routines", "activity", companyId, id] as const,
|
|
},
|
|
executionWorkspaces: {
|
|
list: (companyId: string, filters?: Record<string, string | boolean | undefined>) =>
|
|
["execution-workspaces", companyId, filters ?? {}] as const,
|
|
summaryList: (companyId: string, filters?: Record<string, string | boolean | undefined>) =>
|
|
["execution-workspaces", companyId, "summary", filters ?? {}] as const,
|
|
detail: (id: string) => ["execution-workspaces", "detail", id] as const,
|
|
closeReadiness: (id: string) => ["execution-workspaces", "close-readiness", id] as const,
|
|
workspaceOperations: (id: string) => ["execution-workspaces", "workspace-operations", id] as const,
|
|
},
|
|
environments: {
|
|
list: (companyId: string) => ["environments", companyId] as const,
|
|
},
|
|
projects: {
|
|
list: (companyId: string) => ["projects", companyId] as const,
|
|
detail: (id: string) => ["projects", "detail", id] as const,
|
|
},
|
|
goals: {
|
|
list: (companyId: string) => ["goals", companyId] as const,
|
|
detail: (id: string) => ["goals", "detail", id] as const,
|
|
},
|
|
artifacts: {
|
|
list: (
|
|
companyId: string,
|
|
kind?: string,
|
|
q?: string,
|
|
groupBy?: string,
|
|
groupIssueId?: string,
|
|
) =>
|
|
[
|
|
"artifacts",
|
|
companyId,
|
|
kind ?? "all",
|
|
q ?? "",
|
|
groupBy ?? "none",
|
|
groupIssueId ?? "",
|
|
] as const,
|
|
},
|
|
budgets: {
|
|
overview: (companyId: string) => ["budgets", "overview", companyId] as const,
|
|
},
|
|
approvals: {
|
|
list: (companyId: string, status?: string) =>
|
|
["approvals", companyId, status] as const,
|
|
detail: (approvalId: string) => ["approvals", "detail", approvalId] as const,
|
|
comments: (approvalId: string) => ["approvals", "comments", approvalId] as const,
|
|
issues: (approvalId: string) => ["approvals", "issues", approvalId] as const,
|
|
},
|
|
access: {
|
|
invites: (companyId: string, state: string = "all", limit: number = 20) =>
|
|
["access", "invites", "paginated-v1", companyId, state, limit] as const,
|
|
joinRequests: (companyId: string, status: string = "pending_approval") =>
|
|
["access", "join-requests", companyId, status] as const,
|
|
companyMembers: (companyId: string) => ["access", "company-members", companyId] as const,
|
|
companyUserDirectory: (companyId: string) => ["access", "company-user-directory", companyId] as const,
|
|
adminUsers: (query: string) => ["access", "admin-users", query] as const,
|
|
userCompanyAccess: (userId: string) => ["access", "user-company-access", userId] as const,
|
|
invite: (token: string) => ["access", "invite", token] as const,
|
|
currentBoardAccess: ["access", "current-board-access"] as const,
|
|
},
|
|
auth: {
|
|
session: ["auth", "session"] as const,
|
|
},
|
|
sidebarPreferences: {
|
|
companyOrder: (userId: string) => ["sidebar-preferences", "company-order", userId] as const,
|
|
projectOrder: (companyId: string, userId: string) =>
|
|
["sidebar-preferences", "project-order", companyId, userId] as const,
|
|
},
|
|
resourceMemberships: {
|
|
mine: (companyId: string) => ["resource-memberships", companyId, "me"] as const,
|
|
},
|
|
instance: {
|
|
generalSettings: ["instance", "general-settings"] as const,
|
|
schedulerHeartbeats: ["instance", "scheduler-heartbeats"] as const,
|
|
experimentalSettings: ["instance", "experimental-settings"] as const,
|
|
},
|
|
cloudUpstreams: (companyId: string) => ["cloud-upstreams", companyId] as const,
|
|
health: ["health"] as const,
|
|
secrets: {
|
|
list: (companyId: string) => ["secrets", companyId] as const,
|
|
providers: (companyId: string) => ["secret-providers", companyId] as const,
|
|
providerConfigs: (companyId: string) => ["secret-provider-configs", companyId] as const,
|
|
usage: (secretId: string) => ["secrets", "usage", secretId] as const,
|
|
accessEvents: (secretId: string) => ["secrets", "access-events", secretId] as const,
|
|
},
|
|
companySearch: {
|
|
search: (companyId: string, q: string, scope: string, limit: number, offset: number) =>
|
|
["company-search", companyId, q, scope, limit, offset] as const,
|
|
},
|
|
dashboard: (companyId: string) => ["dashboard", companyId] as const,
|
|
userProfile: (companyId: string, userSlug: string) =>
|
|
["user-profile", companyId, userSlug] as const,
|
|
sidebarBadges: (companyId: string) => ["sidebar-badges", companyId] as const,
|
|
inboxDismissals: (companyId: string) => ["inbox-dismissals", companyId] as const,
|
|
activity: (companyId: string) => ["activity", companyId] as const,
|
|
costs: (companyId: string, from?: string, to?: string) =>
|
|
["costs", companyId, from, to] as const,
|
|
usageByProvider: (companyId: string, from?: string, to?: string) =>
|
|
["usage-by-provider", companyId, from, to] as const,
|
|
usageByBiller: (companyId: string, from?: string, to?: string) =>
|
|
["usage-by-biller", companyId, from, to] as const,
|
|
financeSummary: (companyId: string, from?: string, to?: string) =>
|
|
["finance-summary", companyId, from, to] as const,
|
|
financeByBiller: (companyId: string, from?: string, to?: string) =>
|
|
["finance-by-biller", companyId, from, to] as const,
|
|
financeByKind: (companyId: string, from?: string, to?: string) =>
|
|
["finance-by-kind", companyId, from, to] as const,
|
|
financeEvents: (companyId: string, from?: string, to?: string, limit: number = 100) =>
|
|
["finance-events", companyId, from, to, limit] as const,
|
|
usageWindowSpend: (companyId: string) =>
|
|
["usage-window-spend", companyId] as const,
|
|
usageQuotaWindows: (companyId: string) =>
|
|
["usage-quota-windows", companyId] as const,
|
|
heartbeats: (companyId: string, agentId?: string) =>
|
|
["heartbeats", companyId, agentId] as const,
|
|
runDetail: (runId: string) => ["heartbeat-run", runId] as const,
|
|
runWorkspaceOperations: (runId: string) => ["heartbeat-run", runId, "workspace-operations"] as const,
|
|
liveRuns: (companyId: string) => ["live-runs", companyId] as const,
|
|
runIssues: (runId: string) => ["run-issues", runId] as const,
|
|
org: (companyId: string) => ["org", companyId] as const,
|
|
skills: {
|
|
available: ["skills", "available"] as const,
|
|
},
|
|
plugins: {
|
|
all: ["plugins"] as const,
|
|
examples: ["plugins", "examples"] as const,
|
|
detail: (pluginId: string) => ["plugins", pluginId] as const,
|
|
health: (pluginId: string) => ["plugins", pluginId, "health"] as const,
|
|
uiContributions: ["plugins", "ui-contributions"] as const,
|
|
config: (pluginId: string) => ["plugins", pluginId, "config"] as const,
|
|
localFolders: (pluginId: string, companyId: string) =>
|
|
["plugins", pluginId, "companies", companyId, "local-folders"] as const,
|
|
dashboard: (pluginId: string) => ["plugins", pluginId, "dashboard"] as const,
|
|
logs: (pluginId: string) => ["plugins", pluginId, "logs"] as const,
|
|
},
|
|
adapters: {
|
|
all: ["adapters"] as const,
|
|
},
|
|
};
|