Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ apps/pi-extension/review-core.ts
.idea
.DS_Store
*.suo

# Claude Code session-local runtime state (lock files, scheduled-task state).
# Machine-specific; never belongs in the repo.
.claude/
*.ntvs*
*.njsproj
*.sln
Expand Down
423 changes: 396 additions & 27 deletions apps/hook/dev-mock-api.ts

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion packages/editor/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,18 @@ import { SidebarContainer } from '@plannotator/ui/components/sidebar/SidebarCont
import type { ArchivedPlan } from '@plannotator/ui/components/sidebar/ArchiveBrowser';
import { PlanDiffViewer } from '@plannotator/ui/components/plan-diff/PlanDiffViewer';
import type { PlanDiffMode } from '@plannotator/ui/components/plan-diff/PlanDiffModeSwitcher';
import { DEMO_PLAN_CONTENT } from './demoPlan';
// Demo content toggle. Default: the original Real-time Collaboration plan.
// Opt-in diff-engine stress test: `VITE_DIFF_DEMO=1 bun run dev:hook` swaps
// in the 20-case Auth Service Refactor test plan. dev-mock-api.ts reads the
// same env var on the server side so V2/V3 stay paired.
import { DEMO_PLAN_CONTENT as DEFAULT_DEMO_PLAN_CONTENT } from './demoPlan';
import { DIFF_DEMO_PLAN_CONTENT } from './demoPlanDiffDemo';
const USE_DIFF_DEMO =
import.meta.env.VITE_DIFF_DEMO === '1' ||
import.meta.env.VITE_DIFF_DEMO === 'true';
const DEMO_PLAN_CONTENT = USE_DIFF_DEMO
? DIFF_DEMO_PLAN_CONTENT
: DEFAULT_DEMO_PLAN_CONTENT;
import { useCheckboxOverrides } from './hooks/useCheckboxOverrides';

type NoteAutoSaveResults = {
Expand Down
93 changes: 56 additions & 37 deletions packages/editor/demoPlan.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
export const DEMO_PLAN_CONTENT = `# Implementation Plan: Real-time Collaboration

## Context

This proposal introduces real-time collaborative editing to the Plannotator editor, letting reviewers annotate the same plan simultaneously with sub-second visibility of each other's cursors and edits. We are targeting **production-grade concurrency** for up to 50 active collaborators per document, with end-to-end edit-to-visible latency under 150ms at the 95th percentile. The implementation uses operational transforms running on a dedicated Node.js gateway that speaks \`WebSocket\` to clients and \`gRPC\` to the storage tier. See [the technical design doc](https://docs.example.com/realtime-v2) for the full rationale and rollout plan.

Runtime parameters for phase one:

\`\`\`typescript
export const COLLAB_CONFIG = {
maxCollaborators: 50,
heartbeatIntervalMs: 5_000,
operationBatchSize: 32,
gateway: "wss://collab.plannotator.ai",
} as const;
\`\`\`

## Overview
Add real-time collaboration features to the editor using _**[WebSocket API](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API)**_ and *[operational transforms](https://en.wikipedia.org/wiki/Operational_transformation)*.

Expand Down Expand Up @@ -58,43 +73,6 @@ CREATE TABLE collaborators (
CREATE INDEX idx_collaborators_document ON collaborators(document_id);
\`\`\`

### Architecture

\`\`\`mermaid
flowchart LR
subgraph Client["Client Browser"]
UI[React UI] --> OT[OT Engine]
OT <--> WS[WebSocket Client]
end

subgraph Server["Backend"]
WSS[WebSocket Server] <--> OTS[OT Transform]
OTS <--> DB[(PostgreSQL)]
end

WS <--> WSS
\`\`\`

### Service Dependencies (Graphviz)

\`\`\`graphviz
digraph CollaborationStack {
rankdir=LR;
node [shape=box, style="rounded"];

Browser [label="Client Browser"];
API [label="WebSocket API"];
OT [label="OT Engine"];
Redis [label="Presence Cache"];
Postgres [label="PostgreSQL"];

Browser -> API;
API -> OT;
OT -> Redis;
OT -> Postgres;
}
\`\`\`

## Phase 2: Operational Transforms

> The key insight is that we need to transform operations against concurrent operations to maintain consistency.
Expand Down Expand Up @@ -330,5 +308,46 @@ export const CursorOverlay: React.FC<CursorOverlayProps> = ({

---

## Appendix: Diagrams

### Architecture

\`\`\`mermaid
flowchart LR
subgraph Client["Client Browser"]
UI[React UI] --> OT[OT Engine]
OT <--> WS[WebSocket Client]
end

subgraph Server["Backend"]
WSS[WebSocket Server] <--> OTS[OT Transform]
OTS <--> DB[(PostgreSQL)]
end

WS <--> WSS
\`\`\`

### Service Dependencies (Graphviz)

\`\`\`graphviz
digraph CollaborationStack {
rankdir=LR;
node [shape=box, style="rounded"];

Browser [label="Client Browser"];
API [label="WebSocket API"];
OT [label="OT Engine"];
Redis [label="Presence Cache"];
Postgres [label="PostgreSQL"];

Browser -> API;
API -> OT;
OT -> Redis;
OT -> Postgres;
}
\`\`\`

---

**Target:** Ship MVP in next sprint
`;
Loading