mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-13 04:02:28 +02:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - The issue properties panel can show external objects such as GitHub pull requests. > - Those objects are resolved by external-object providers and then displayed as compact status labels. > - A GitHub pull request could remain in the fallback `unknown` state and appear as `Not yet resolved`. > - That label is confusing when the object is known but has not been refreshed yet. > - This pull request refreshes due external objects from the heartbeat scheduler and improves the unknown-status copy. > - The benefit is a properties panel that moves from pending refresh to the real pull request state without a manual refresh. ## Linked Issues or Issue Description No public GitHub issue exists for this bug. I searched for related public issues and pull requests using the terms `Not yet refreshed`, `external objects refresh`, and `external PR status`, and did not find a duplicate implementation. **What happened?** The issue properties panel could show a GitHub pull request as `Not yet resolved` even when the referenced pull request was valid. The object stayed stale unless a manual refresh path ran. **Expected behavior** A known external object should show pending-refresh copy while it waits for provider data. When the scheduler refreshes it, the properties panel should show the provider status such as open, merged, or closed. **Steps to reproduce** 1. Create or view an issue that references a GitHub pull request. 2. Open the issue properties panel. 3. Observe the external object row before a manual refresh has run. **Paperclip version or commit** Current `master` before this pull request. **Deployment mode** Local dev and self-hosted server. **Installation method** Built from source. **Agent adapter(s) involved** Not adapter-specific. **Database mode** Not database-related. **Access context** Board view. **Privacy checklist** I reviewed this description and did not include logs, credentials, private URLs, internal issue IDs, or PII. ## What Changed - Added a heartbeat scheduler tick that refreshes due external objects for active companies. - Kept manual external-object refresh behavior on the same service path. - Changed display copy so known provider objects use liveness labels such as `Not yet refreshed`, while fresh unknown provider statuses show `Status unavailable`. - Added server and UI tests for scheduled refresh and label behavior. ## Verification - `corepack pnpm install --frozen-lockfile` - `pnpm check:token-gates` - `pnpm exec vitest run server/src/__tests__/external-objects-service.test.ts server/src/__tests__/server-startup-feedback-export.test.ts ui/src/components/ExternalObjectPill.test.tsx ui/src/components/IssueProperties.test.tsx ui/src/lib/external-objects.test.ts` - `pnpm --filter @paperclipai/ui typecheck` - `pnpm --filter @paperclipai/server typecheck` - `pnpm --filter @paperclipai/server build` - `pnpm --filter @paperclipai/ui build` - `pnpm run typecheck:build-gaps` - GitHub PR checks passed on head `0e7fcd30` - Greptile reported 5/5 on head `0e7fcd30` with no unresolved review threads Notes: - I ran recursive typecheck and build first. Both hit container resource limits with exit 137 during concurrent package work, so I reran the affected server and UI targets separately. - An unrelated workspace-runtime auto-port test fails in this container with a PID ownership mismatch. It is outside the files changed here. ## Risks Low to medium risk. The scheduler does more periodic external-object work, so the main risk is extra provider refresh load. The implementation bounds the work to active companies, due non-terminal objects, and 50 objects per company per tick. The path also stays behind the external-objects experimental setting. ## Model Used OpenAI GPT-5 Codex in the Codex execution environment, with shell and GitHub CLI tool use. The runtime did not expose a more specific internal model ID or context window. ## 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 not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] 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>
208 lines
7.3 KiB
TypeScript
208 lines
7.3 KiB
TypeScript
// @vitest-environment node
|
||
|
||
import { describe, expect, it } from "vitest";
|
||
import { renderToStaticMarkup } from "react-dom/server";
|
||
import { ExternalObjectPill } from "./ExternalObjectPill";
|
||
import { ExternalObjectStatusSummary } from "./ExternalObjectStatusSummary";
|
||
|
||
describe("ExternalObjectPill", () => {
|
||
it("renders a clickable anchor when a URL is provided", () => {
|
||
const html = renderToStaticMarkup(
|
||
<ExternalObjectPill
|
||
object={{
|
||
providerKey: "github",
|
||
objectType: "pull_request",
|
||
statusCategory: "succeeded",
|
||
liveness: "fresh",
|
||
displayTitle: "Add external refs",
|
||
url: "https://github.com/acme/web/pull/241",
|
||
}}
|
||
sourceCount={4}
|
||
sourceSummary="description, 3 comments"
|
||
/>,
|
||
);
|
||
expect(html).toContain('href="https://github.com/acme/web/pull/241"');
|
||
expect(html).toContain('data-mention-kind="external-object"');
|
||
expect(html).toContain('data-external-status="succeeded"');
|
||
expect(html).toContain('data-external-liveness="fresh"');
|
||
expect(html).toContain("×4");
|
||
expect(html).toContain('aria-label="GitHub pull request — Succeeded: Add external refs"');
|
||
});
|
||
|
||
it("falls back to a non-interactive span when no URL is supplied", () => {
|
||
const html = renderToStaticMarkup(
|
||
<ExternalObjectPill
|
||
object={{
|
||
providerKey: null,
|
||
objectType: null,
|
||
statusCategory: "unknown",
|
||
liveness: "unknown",
|
||
url: null,
|
||
}}
|
||
/>,
|
||
);
|
||
expect(html).toContain('data-mention-kind="external-object"');
|
||
expect(html).not.toContain("<a ");
|
||
expect(html).toContain('aria-label="External object — Not yet resolved"');
|
||
});
|
||
|
||
it("applies the dashed-border liveness overlay when stale or auth_required", () => {
|
||
const stale = renderToStaticMarkup(
|
||
<ExternalObjectPill
|
||
object={{
|
||
providerKey: "github",
|
||
objectType: "pull_request",
|
||
statusCategory: "failed",
|
||
liveness: "stale",
|
||
url: "https://github.com/acme/web/pull/242",
|
||
}}
|
||
/>,
|
||
);
|
||
expect(stale).toContain("opacity-70");
|
||
expect(stale).toContain("[border-style:dashed]");
|
||
|
||
const auth = renderToStaticMarkup(
|
||
<ExternalObjectPill
|
||
object={{
|
||
providerKey: "hubspot",
|
||
objectType: "lead",
|
||
statusCategory: "auth_required",
|
||
liveness: "auth_required",
|
||
url: "https://app.hubspot.com/leads/99",
|
||
}}
|
||
/>,
|
||
);
|
||
expect(auth).toContain("[border-style:dashed]");
|
||
});
|
||
|
||
it("does not show a source count when only a single mention is present", () => {
|
||
const html = renderToStaticMarkup(
|
||
<ExternalObjectPill
|
||
object={{
|
||
providerKey: "github",
|
||
objectType: "pull_request",
|
||
statusCategory: "succeeded",
|
||
liveness: "fresh",
|
||
url: "https://github.com/acme/web/pull/241",
|
||
}}
|
||
sourceCount={1}
|
||
/>,
|
||
);
|
||
expect(html).not.toContain("×");
|
||
});
|
||
|
||
it("labels detected GitHub pull requests without fetched status as not refreshed", () => {
|
||
const html = renderToStaticMarkup(
|
||
<ExternalObjectPill
|
||
object={{
|
||
providerKey: "github",
|
||
objectType: "pull_request",
|
||
statusCategory: "unknown",
|
||
liveness: "unknown",
|
||
displayTitle: "acme/web#241",
|
||
url: "https://github.com/acme/web/pull/241",
|
||
}}
|
||
/>,
|
||
);
|
||
|
||
expect(html).toContain("PR 241 - Not yet refreshed");
|
||
expect(html).toContain('aria-label="GitHub pull request — Not yet refreshed: acme/web#241"');
|
||
expect(html).not.toContain("Not yet resolved");
|
||
});
|
||
|
||
it("uses the object link label, provider icon, and visible status when supplied", () => {
|
||
const html = renderToStaticMarkup(
|
||
<ExternalObjectPill
|
||
object={{
|
||
providerKey: "github",
|
||
objectType: "pull_request",
|
||
displayKey: "Github Pull Request",
|
||
iconKey: "github",
|
||
statusCategory: "succeeded",
|
||
statusIconKey: null,
|
||
liveness: "fresh",
|
||
statusLabel: "Merged",
|
||
displayTitle: "acme/web#241: Add rich object presentation metadata",
|
||
url: "https://github.com/acme/web/pull/241",
|
||
}}
|
||
/>,
|
||
);
|
||
expect(html).toContain("Merged");
|
||
expect(html).toContain("PR 241 - Merged");
|
||
expect(html).not.toContain("acme/web#241</span>");
|
||
expect(html).toContain("text-violet-600");
|
||
expect(html).not.toContain(">Github Pull Request</span>");
|
||
expect(html).toContain('aria-label="Github Pull Request — Merged: acme/web#241: Add rich object presentation metadata"');
|
||
});
|
||
|
||
it("labels generic URL link objects as URL instead of URL link", () => {
|
||
const html = renderToStaticMarkup(
|
||
<ExternalObjectPill
|
||
object={{
|
||
providerKey: "url",
|
||
objectType: "link",
|
||
statusCategory: "unknown",
|
||
liveness: "unknown",
|
||
displayTitle: null,
|
||
url: "https://example.com/",
|
||
}}
|
||
/>,
|
||
);
|
||
|
||
expect(html).toContain('aria-label="URL — Not yet resolved"');
|
||
expect(html).not.toContain("URL link");
|
||
});
|
||
});
|
||
|
||
describe("ExternalObjectStatusSummary", () => {
|
||
it("hides itself when there are no external objects", () => {
|
||
const html = renderToStaticMarkup(<ExternalObjectStatusSummary summary={null} />);
|
||
expect(html).toBe("");
|
||
});
|
||
|
||
it("hides itself when the highest severity is muted", () => {
|
||
const html = renderToStaticMarkup(
|
||
<ExternalObjectStatusSummary
|
||
summary={{
|
||
total: 2,
|
||
byStatusCategory: { closed: 2 },
|
||
byLiveness: { fresh: 2 },
|
||
highestSeverity: "muted",
|
||
staleCount: 0,
|
||
authRequiredCount: 0,
|
||
unreachableCount: 0,
|
||
objects: [],
|
||
}}
|
||
/>,
|
||
);
|
||
expect(html).toBe("");
|
||
});
|
||
|
||
it("shows the dominant-severity icon and count", () => {
|
||
const html = renderToStaticMarkup(
|
||
<ExternalObjectStatusSummary
|
||
summary={{
|
||
total: 5,
|
||
byStatusCategory: { failed: 3, succeeded: 2 },
|
||
byLiveness: { fresh: 5 },
|
||
highestSeverity: "danger",
|
||
staleCount: 0,
|
||
authRequiredCount: 0,
|
||
unreachableCount: 0,
|
||
objects: [
|
||
{ id: "a", providerKey: "ci", objectType: "deployment", displayTitle: null, statusCategory: "failed", statusTone: "danger", liveness: "fresh", isTerminal: false },
|
||
{ id: "b", providerKey: "ci", objectType: "deployment", displayTitle: null, statusCategory: "failed", statusTone: "danger", liveness: "fresh", isTerminal: false },
|
||
{ id: "c", providerKey: "ci", objectType: "deployment", displayTitle: null, statusCategory: "failed", statusTone: "danger", liveness: "fresh", isTerminal: false },
|
||
{ id: "d", providerKey: "github", objectType: "pull_request", displayTitle: null, statusCategory: "succeeded", statusTone: "success", liveness: "fresh", isTerminal: true },
|
||
{ id: "e", providerKey: "github", objectType: "pull_request", displayTitle: null, statusCategory: "succeeded", statusTone: "success", liveness: "fresh", isTerminal: true },
|
||
],
|
||
}}
|
||
/>,
|
||
);
|
||
expect(html).toContain('data-external-status="failed"');
|
||
expect(html).toContain('data-external-tone="danger"');
|
||
expect(html).toContain(">3<");
|
||
expect(html).toContain("aria-label=\"External objects: 3 failed, 2 succeeded, 5 total\"");
|
||
});
|
||
});
|