mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-29 15:52:36 +01:00
fix: upstream deployed document-comment, routine-annotation, workspace & board-polling fixes (#8536)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - This change touches several already-shipped subsystems — document-comment annotations, the selected-agent Conference Room chat surface, routine description annotations, workspace-operation tracking, and the board polling/inbox UI > - A batch of incremental fixes and two small backend additions had accumulated on a local mainline and were deployed to a live instance, but never landed upstream — so each `origin/master` sync kept re-diverging > - Leaving them un-upstreamed means the same delta has to be re-merged on every sync and risks being lost or silently reverted > - This pull request rebases that delta cleanly on top of current `origin/master` (preserving recent upstream work such as reusable sandbox leases and the relation-list collapse controls) and brings it up for review > - The benefit is that mainline and the deployed instance converge, and these fixes/additions get normal review + CI + Greptile coverage ## Linked Issues or Issue Description No single GitHub issue tracks this; it is a bundle of bug fixes and two small feature additions. Following the issue-template fields: **Bug fixes (what was wrong → what this does):** - Document comments rendered out of document order, didn't live-update across clients, swallowed save failures, and lost the markdown text selection on re-render. Now: doc-order sort, live updates, surfaced save-failure state, stable selection across re-renders. - The board polling hot path returned oversized payloads on every poll. Now: an opt-in `summary` projection trims the heartbeat-run list payload. - Assorted UI fixes: sidebar nav peek/streamlining edge cases, markdown file-viewer re-mount/line-height issues on iOS Safari, inbox badge/skill deep-link tab selection, and `⌘.` work-mode cycling on iOS. **Feature additions:** - `workspace_operations.issue_id` — associate a workspace operation with the issue that triggered it (new migration `0106`, schema, service, shared type). - Routine **description annotations** — comment threads on a routine's description document, mirroring issue document annotations (new migration `0107`, `routine_documents` schema, routes/service, editable-sections UI). - Selected-agent **Conference Room chat** surface wiring and live issue-thread updates. **Related PR:** #8229 (`feat(control-plane): add annotation and workspace controls`, draft) covers overlapping annotation/workspace-control territory — flagging it so a reviewer can reconcile the two rather than double-merging. ## What Changed - `feat(workspace)`: `workspace_operations.issue_id` migration + schema/service/type; issue workspace property controls reconciled with upstream's evolved "Service" row. - `feat(routines)`: routine description annotations — `routine_documents` schema, migration `0107`, routes/service, `editable-sections` UI. - `fix(document-comments)`: doc-order sort, live updates, save-failure surfacing, stable markdown selection (+ storybook story, rerender test). - `feat(chat)`: selected-agent Conference Room chat surface and live issue-thread updates (`LiveUpdatesProvider`, `issue-chat-messages`, interactions service). - `perf(board)`: opt-in `summary` projection for the board polling/heartbeat-run list payload, plus assorted sidebar / file-viewer / inbox / IssueProperties UI fixes. Organized into 5 logical commits. Migrations are numbered incrementally after upstream's latest (`0105`) — `0106` then `0107`, no journal collision. ## Verification - Built by 3-way merging the deployed delta onto current `origin/master`; the only merge conflict (`IssueProperties.test.tsx`, two adjacent test blocks) was resolved in favor of upstream's evolved "green service link above the workspace row" layout, which matches the merged component's rendered output. - Confirmed recent upstream work is preserved post-merge: reusable sandbox lease teardown (`#8513`), the IssueProperties relation-list collapse controls, and the sidebar streamlined-nav default. - Confirmed the net diff vs `origin/master` is exactly the intended feature delta (65 files) and that overlapping server files (`issues.ts`, `agents.ts`, `heartbeat.ts`) only add feature code without disturbing upstream logic. - This delta is already running on a live deployed instance. - Full typecheck/test suite + Greptile to run in CI (see checklist). ## Risks - Two new migrations (`0106`, `0107`). Both are additive (new table / new nullable column) and ordered after upstream's `0105`; no data backfill, low risk. If another migration-bearing PR merges first, renumber before merge. - Largest blast radius is in the merged overlapping UI/service files; covered by the existing test suites for those files plus CI. - Overlaps thematically with draft PR #8229 — reviewers should reconcile rather than merge both blindly. ## Model Used Claude Opus 4.8 (`claude-opus-4-8`), extended thinking, with tool use (git, shell). Agentic coding workflow. ## 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) - [ ] 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 - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [ ] I will address all Greptile and reviewer comments before requesting merge --------- Co-authored-by: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
2dbaf4a7fa
commit
e68188c438
70 files changed
+4322
-538
No files matched your search
@@ -139,6 +139,9 @@ describe("LiveUpdatesProvider issue invalidation", () => {
|
||||
expect(invalidations).toContainEqual({
|
||||
queryKey: queryKeys.issues.documentRevisions("issue-1", "plan"),
|
||||
});
|
||||
expect(invalidations).toContainEqual({
|
||||
queryKey: ["issues", "document-annotations", "issue-1", "plan"],
|
||||
});
|
||||
expect(invalidations).toContainEqual({
|
||||
queryKey: queryKeys.issues.documents("PAP-9403"),
|
||||
});
|
||||
@@ -148,6 +151,9 @@ describe("LiveUpdatesProvider issue invalidation", () => {
|
||||
expect(invalidations).toContainEqual({
|
||||
queryKey: queryKeys.issues.documentRevisions("PAP-9403", "plan"),
|
||||
});
|
||||
expect(invalidations).toContainEqual({
|
||||
queryKey: ["issues", "document-annotations", "PAP-9403", "plan"],
|
||||
});
|
||||
expect(invalidations).not.toContainEqual({
|
||||
queryKey: queryKeys.issues.documents("issue-1"),
|
||||
refetchType: "inactive",
|
||||
@@ -186,6 +192,83 @@ describe("LiveUpdatesProvider issue invalidation", () => {
|
||||
expect(invalidations).toContainEqual({
|
||||
queryKey: ["issues", "document-revisions", "issue-1"],
|
||||
});
|
||||
expect(invalidations).toContainEqual({
|
||||
queryKey: ["issues", "document-annotations", "issue-1"],
|
||||
});
|
||||
});
|
||||
|
||||
it("refreshes document annotation caches when annotation activity arrives", () => {
|
||||
const invalidations: unknown[] = [];
|
||||
const queryClient = {
|
||||
invalidateQueries: (input: unknown) => {
|
||||
invalidations.push(input);
|
||||
},
|
||||
getQueryData: () => undefined,
|
||||
};
|
||||
|
||||
__liveUpdatesTestUtils.invalidateActivityQueries(
|
||||
queryClient as never,
|
||||
"company-1",
|
||||
{
|
||||
entityType: "issue",
|
||||
entityId: "issue-1",
|
||||
action: "issue.document_annotation_comment_added",
|
||||
actorType: "user",
|
||||
actorId: "user-2",
|
||||
details: {
|
||||
identifier: "PAP-9403",
|
||||
documentKey: "plan",
|
||||
threadId: "thread-1",
|
||||
commentId: "comment-1",
|
||||
},
|
||||
},
|
||||
{ userId: "user-1", agentId: null },
|
||||
);
|
||||
|
||||
expect(invalidations).toContainEqual({
|
||||
queryKey: ["issues", "document-annotations", "issue-1", "plan"],
|
||||
});
|
||||
expect(invalidations).toContainEqual({
|
||||
queryKey: ["issues", "document-annotations", "PAP-9403", "plan"],
|
||||
});
|
||||
expect(invalidations).not.toContainEqual({
|
||||
queryKey: queryKeys.issues.documents("issue-1"),
|
||||
});
|
||||
});
|
||||
|
||||
it("refreshes routine description annotation caches when routine annotation activity arrives", () => {
|
||||
const invalidations: unknown[] = [];
|
||||
const queryClient = {
|
||||
invalidateQueries: (input: unknown) => {
|
||||
invalidations.push(input);
|
||||
},
|
||||
getQueryData: () => undefined,
|
||||
};
|
||||
|
||||
__liveUpdatesTestUtils.invalidateActivityQueries(
|
||||
queryClient as never,
|
||||
"company-1",
|
||||
{
|
||||
entityType: "routine",
|
||||
entityId: "routine-1",
|
||||
action: "routine.document_annotation_comment_added",
|
||||
actorType: "user",
|
||||
actorId: "user-2",
|
||||
details: {
|
||||
documentKey: "description",
|
||||
threadId: "thread-1",
|
||||
commentId: "comment-1",
|
||||
},
|
||||
},
|
||||
{ userId: "user-1", agentId: null },
|
||||
);
|
||||
|
||||
expect(invalidations).toContainEqual({
|
||||
queryKey: ["routines"],
|
||||
});
|
||||
expect(invalidations).toContainEqual({
|
||||
queryKey: ["routines", "document-annotations", "routine-1", "description"],
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps self-authored comment events from refetching the active issue tree", () => {
|
||||
|
||||
@@ -415,6 +415,20 @@ const ISSUE_DOCUMENT_ACTIVITY_ACTIONS = new Set([
|
||||
"issue.document_restored",
|
||||
"issue.document_deleted",
|
||||
]);
|
||||
const ISSUE_DOCUMENT_ANNOTATION_ACTIVITY_ACTIONS = new Set([
|
||||
"issue.document_annotation_thread_created",
|
||||
"issue.document_annotation_comment_added",
|
||||
"issue.document_annotation_thread_resolved",
|
||||
"issue.document_annotation_thread_reopened",
|
||||
"issue.document_annotation_remapped",
|
||||
]);
|
||||
const ROUTINE_DOCUMENT_ANNOTATION_ACTIVITY_ACTIONS = new Set([
|
||||
"routine.document_annotation_thread_created",
|
||||
"routine.document_annotation_comment_added",
|
||||
"routine.document_annotation_thread_resolved",
|
||||
"routine.document_annotation_thread_reopened",
|
||||
"routine.document_annotation_remapped",
|
||||
]);
|
||||
const AGENT_TOAST_STATUSES = new Set(["error"]);
|
||||
const RUN_TOAST_STATUSES = new Set(["failed", "timed_out", "cancelled"]);
|
||||
|
||||
@@ -710,6 +724,18 @@ function invalidateActivityQueries(
|
||||
queryClient.invalidateQueries({ queryKey: ["issues", "document-revisions", ref], ...invalidationOptions });
|
||||
}
|
||||
}
|
||||
if (
|
||||
action &&
|
||||
(ISSUE_DOCUMENT_ACTIVITY_ACTIONS.has(action) || ISSUE_DOCUMENT_ANNOTATION_ACTIVITY_ACTIONS.has(action))
|
||||
) {
|
||||
const documentKey = readString(details?.key) ?? readString(details?.documentKey);
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: documentKey
|
||||
? ["issues", "document-annotations", ref, documentKey]
|
||||
: ["issues", "document-annotations", ref],
|
||||
...invalidationOptions,
|
||||
});
|
||||
}
|
||||
if (action?.startsWith("issue.thread_interaction_")) {
|
||||
queryClient.invalidateQueries({ queryKey: queryKeys.issues.interactions(ref), ...invalidationOptions });
|
||||
}
|
||||
@@ -761,6 +787,12 @@ function invalidateActivityQueries(
|
||||
|
||||
if (entityType === "routine" || entityType === "routine_trigger" || entityType === "routine_run") {
|
||||
queryClient.invalidateQueries({ queryKey: ["routines"] });
|
||||
if (entityType === "routine" && action && ROUTINE_DOCUMENT_ANNOTATION_ACTIVITY_ACTIONS.has(action) && entityId) {
|
||||
const documentKey = readString(details?.key) ?? readString(details?.documentKey) ?? "description";
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ["routines", "document-annotations", entityId, documentKey],
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// @vitest-environment jsdom
|
||||
|
||||
import { act } from "react";
|
||||
import { flushSync } from "react-dom";
|
||||
import { createRoot, type Root } from "react-dom/client";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { SidebarProvider, useSidebar } from "./SidebarContext";
|
||||
@@ -13,6 +13,10 @@ const COLLAPSED_STORAGE_KEY = "paperclip.sidebar.collapsed";
|
||||
// Mutable media state driving the matchMedia mock.
|
||||
const mediaState = { mobile: false, hoverFine: true };
|
||||
|
||||
function act(callback: () => void) {
|
||||
flushSync(callback);
|
||||
}
|
||||
|
||||
function setViewport({ mobile, hoverFine }: { mobile?: boolean; hoverFine?: boolean }) {
|
||||
if (typeof mobile === "boolean") mediaState.mobile = mobile;
|
||||
if (typeof hoverFine === "boolean") mediaState.hoverFine = hoverFine;
|
||||
@@ -248,6 +252,42 @@ describe("SidebarContext", () => {
|
||||
act(() => capturedValue?.setPeeking(true));
|
||||
expect(capturedValue?.peeking).toBe(false);
|
||||
});
|
||||
|
||||
// iPadOS Safari keeps the hover/pointer media query false even with a
|
||||
// trackpad attached (PAP-10725); a real cursor still emits "mouse" pointer
|
||||
// events, which must unlock peek at runtime.
|
||||
it("peeks once a mouse-type pointer event is seen (iPad + trackpad)", () => {
|
||||
localStorage.setItem(COLLAPSED_STORAGE_KEY, "1");
|
||||
setViewport({ mobile: false, hoverFine: false });
|
||||
active = renderProvider();
|
||||
expect(capturedValue?.collapsed).toBe(true);
|
||||
|
||||
// No cursor seen yet → peek stays gated despite the media query.
|
||||
act(() => capturedValue?.setPeeking(true));
|
||||
expect(capturedValue?.peeking).toBe(false);
|
||||
|
||||
// A trackpad/mouse moves: a "mouse" pointer event unlocks peek.
|
||||
act(() => {
|
||||
const e = new Event("pointermove");
|
||||
(e as unknown as { pointerType: string }).pointerType = "mouse";
|
||||
window.dispatchEvent(e);
|
||||
});
|
||||
expect(capturedValue?.peeking).toBe(true);
|
||||
});
|
||||
|
||||
it("ignores touch pointer events (touch-only stays gated)", () => {
|
||||
localStorage.setItem(COLLAPSED_STORAGE_KEY, "1");
|
||||
setViewport({ mobile: false, hoverFine: false });
|
||||
active = renderProvider();
|
||||
|
||||
act(() => capturedValue?.setPeeking(true));
|
||||
act(() => {
|
||||
const e = new Event("pointerover");
|
||||
(e as unknown as { pointerType: string }).pointerType = "touch";
|
||||
window.dispatchEvent(e);
|
||||
});
|
||||
expect(capturedValue?.peeking).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("back-compat", () => {
|
||||
|
||||
@@ -112,11 +112,36 @@ export function SidebarProvider({ children }: { children: ReactNode }) {
|
||||
useEffect(() => {
|
||||
if (typeof window.matchMedia !== "function") return;
|
||||
const mql = window.matchMedia(PEEK_POINTER_QUERY);
|
||||
const onChange = (e: MediaQueryListEvent) => setPointerCanPeek(e.matches);
|
||||
// Latch on only — see the runtime detection below for why this never flips
|
||||
// back to false.
|
||||
const onChange = (e: MediaQueryListEvent) => {
|
||||
if (e.matches) setPointerCanPeek(true);
|
||||
};
|
||||
mql.addEventListener("change", onChange);
|
||||
return () => mql.removeEventListener("change", onChange);
|
||||
}, []);
|
||||
|
||||
// iPadOS Safari does not flip the `(hover: hover) and (pointer: fine)` media
|
||||
// query when a trackpad/mouse is attached, so the query above stays false even
|
||||
// though a real cursor is driving the UI — and hover-peek never triggers
|
||||
// (PAP-10725). Detect a fine pointer at runtime instead: a genuine
|
||||
// mouse/trackpad emits pointer events with `pointerType: "mouse"`, whereas
|
||||
// touch reports "touch" and the Pencil reports "pen", so this never enables on
|
||||
// touch-only input. Treat peek capability as a one-way latch — once a cursor
|
||||
// has been seen we keep peek available for the session.
|
||||
useEffect(() => {
|
||||
if (pointerCanPeek || typeof window.PointerEvent !== "function") return;
|
||||
const onPointer = (e: PointerEvent) => {
|
||||
if (e.pointerType === "mouse") setPointerCanPeek(true);
|
||||
};
|
||||
window.addEventListener("pointerover", onPointer, { passive: true });
|
||||
window.addEventListener("pointermove", onPointer, { passive: true });
|
||||
return () => {
|
||||
window.removeEventListener("pointerover", onPointer);
|
||||
window.removeEventListener("pointermove", onPointer);
|
||||
};
|
||||
}, [pointerCanPeek]);
|
||||
|
||||
// Precedence (highest wins): forced (active secondary sidebar) > explicit user
|
||||
// pin > route request > default expanded. The force is ephemeral and never
|
||||
// touches the persisted pin, so dropping it restores the user's preference.
|
||||
|
||||
Reference in new issue
Block a user