Skip to content

Refactor workspace content architecture#664

Merged
urjitc merged 16 commits into
mainfrom
codex/workspace-architecture-greenfield
Jul 18, 2026
Merged

Refactor workspace content architecture#664
urjitc merged 16 commits into
mainfrom
codex/workspace-architecture-greenfield

Conversation

@urjitc

@urjitc urjitc commented Jul 18, 2026

Copy link
Copy Markdown
Member

Summary

  • make WorkspaceKernel the canonical seam for paths, facts, projections, relationships, and event identity
  • keep flashcards, quizzes, and audio recording as explicit future-facing workspace capabilities
  • read extracted pages with bounded sequential R2 body consumption and additive manifest metadata
  • serve live document chunks inside DocumentSession with revision guards and a cached line index
  • validate realtime messages and use one canonical desync recovery path
  • consolidate binary encoding and workspace item policy

Why

The old read path fetched every selected R2 page before consuming any response body. That retained all bodies at once and made resource use scale with page count. Cloudflare changed connection accounting on April 9, 2026, so the historical connection-limit exception is not proven on the current runtime, but the fan-out remains an unnecessary resource pattern.

Workspace semantics were also duplicated across operations, document reads transferred more state than necessary, and several internal interfaces exposed intermediate plumbing rather than a complete operation.

The model-facing contract stays compact: start a path, select physical pages when useful, and continue with an opaque cursor. Storage identity, linking, revision checks, byte budgets, and extraction lifecycle remain internal.

Changes

  • preserve exact Markdown whitespace and valid UTF-16 boundaries
  • retain schema-v1 projection compatibility while adding optional per-page byte metadata
  • enforce per-page, per-selection, and per-batch read budgets
  • keep historical realtime event payloads immutable
  • require stable item IDs and fail duplicate create commands instead of maintaining mutation replay receipts
  • keep client mutation IDs only as realtime event metadata for local echo suppression
  • ignore unknown realtime messages while retaining revision-gap desync recovery
  • fetch item facts only for selected items
  • represent pending extraction separately in telemetry and tool receipts
  • preserve flashcard and quiz schemas, initial content, colors, and disabled Soon menu entries
  • preserve the disabled audio recording entry
  • remove the speculative learning-item retirement migration
  • use one server-safe registry for item schemas, names, labels, colors, and storage metadata
  • validate page manifests through the existing Zod boundary instead of a manual parser
  • use one Base64URL and SHA-256 implementation across cursors, uploads, extraction, and documents
  • remove the hand-written DocumentSession client mirror
  • hide list selection and formatting stages behind one kernel list operation

Testing

  • pnpm exec vp check: 623 files formatted; no lint or type errors in 599 files
  • pnpm knip: passed
  • pnpm test: 25 files and 90 tests passed
  • pnpm test:workers: 1 file and 4 tests passed
  • React Doctor changed-scope: 87/100, matching the PR baseline
  • remaining React Doctor warnings are intentional ordered resource or mutation loops

Review Notes

Start with workspace-content-reader.ts, workspace-page-projection.ts, workspace-item-registry.ts, workspace-kernel-events.ts, and workspace-kernel-schema.ts. The sequential read loops are deliberate resource boundaries. No planning Markdown document is included.

@cursor

cursor Bot commented Jul 18, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@capy-ai

capy-ai Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Capy auto-review is paused for this organization because the usage-cycle auto-review limit has been reached. Increase the limit or turn it off in billing settings to resume automatic reviews.

@github-actions

github-actions Bot commented Jul 18, 2026

Copy link
Copy Markdown

React Doctor found 3 new issues in 3 files · 3 warnings · score 87 / 100 (Great) · 2 fixed · vs main

3 warnings

src/features/workspaces/content/workspace-content-reader.ts

  • ⚠️ L73 await inside a loop async-await-in-loop

src/features/workspaces/extraction/workspace-page-projection.ts

  • ⚠️ L178 await inside a loop async-await-in-loop

src/features/workspaces/operations/create-items.ts

  • ⚠️ L98 await inside a loop async-await-in-loop

Reviewed by React Doctor for commit 50fbf55. See inline comments for fixes.

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Workspace reads now use typed, paginated contracts with document/file continuation, revision checks, and relation paths. Workspace operations use authorized kernel path resolution, while kernel events, projections, realtime state, caching, and tool receipts carry updated item facts and pending statuses.

Changes

Workspace content reads

Layer / File(s) Summary
Typed read contracts and reader
src/features/workspaces/content/*, src/features/workspaces/operations/read-items.ts
Workspace reads now accept explicit start, pages, and continue requests and return typed ready, pending, or failed results.
Document and projection handling
src/features/workspaces/documents/*, src/features/workspaces/extraction/workspace-page-projection.ts
Document chunks use revisioned cursors; file projection reads validate source hashes, page metadata, byte limits, and response-body consumption.

Kernel and operation flow

Layer / File(s) Summary
Kernel path and checkpoint APIs
src/features/workspaces/kernel/*
Kernel APIs add path resolution, tree listing, item-path lookup, relation linking, document checkpoints, fact-aware mutation results, and event hydration.
Authorized operations
src/features/workspaces/operations/*
Workspace operations obtain authorized kernels and pass resolved paths into create, delete, edit, link, list, move, rename, and read flows.

Workspace state and tooling

Layer / File(s) Summary
Realtime and page state
src/features/workspaces/realtime/*, src/features/workspaces/model/workspace-page.ts, src/features/workspaces/cache-workspace.ts
Realtime events and page caches now carry and reconcile itemFacts and revisions, with desync-triggered invalidation.
Tool contracts and receipts
src/features/workspaces/operations/workspace-tool-*, src/features/workspaces/components/ai-chat/*
Read and edit tool inputs, observability summaries, and receipts now reflect request arrays, pending results, and failure counts.
Workspace item model and creation UI
src/features/workspaces/model/*, src/features/workspaces/components/WorkspaceCreateMenu.tsx
Workspace item support is limited to folders, documents, and files, and file upload is exposed as a dedicated creation action.

Estimated code review effort: 5 (Critical) | ~120 minutes

Possibly related PRs

Suggested labels: capy

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 1.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and broadly matches the PR’s main workspace content architecture refactor.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/workspace-architecture-greenfield

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@mintlify

mintlify Bot commented Jul 18, 2026

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
thinkex 🟢 Ready View Preview Jul 18, 2026, 1:56 AM

@mintlify

mintlify Bot commented Jul 18, 2026

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
thinkex 🟡 Building Jul 18, 2026, 1:56 AM

@greptile-apps

greptile-apps Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR refactors workspace content reads and item operations around the kernel seam. The main changes are:

  • Adds WorkspaceContentReader with typed read requests, opaque cursors, live document reads, and extracted-file reads.
  • Moves path resolution, item facts, projections, document checkpoints, and relationships behind WorkspaceKernel.
  • Changes extracted page reads to consume bounded R2 response bodies sequentially.
  • Removes unused flashcard, quiz, and audio-recording item surfaces.
  • Adds a planning document for first-party document AI editing.

Confidence Score: 4/5

Mostly safe to merge after fixing the batch-create relation bug.

One contained issue remains in ordered batch item creation with relations. The main read-path and projection changes are isolated behind new seams and covered by focused tests.

src/features/workspaces/operations/create-items.ts; src/features/workspaces/operations/relations.ts

T-Rex T-Rex Logs

What T-Rex did

  • T-Rex executed a focused Vitest repro to validate createWorkspaceItemsOperation with an ordered batch that creates /A followed by /B and a relation to /A.
  • The repro showed that only /A was created and the second item failed with relation_path_not_found for /A, so /B and its relation could not be created.
  • Artifacts were collected to document the repro, including the focused Vitest harness, the Vitest configuration, and the failing test output.
  • Broader proofs were collected to show additional context, including a passing narrow proof log and a broader proof log indicating no test files were found.

View all artifacts

T-Rex Ran code and verified through T-Rex

Important Files Changed

Filename Overview
src/features/workspaces/content/workspace-content-reader.ts Centralizes path resolution, live document reads, extracted file reads, cursors, and relation metadata.
src/features/workspaces/extraction/workspace-page-projection.ts Changes extracted page reads to sequentially consume bounded R2 objects.
src/features/workspaces/kernel/workspace-kernel.ts Makes the kernel the canonical seam for path resolution, item facts, relations, projections, and document checkpoints.
src/features/workspaces/operations/create-items.ts Refactors batch item creation through kernel path resolution, but breaks relations to items created earlier in the same request.
src/features/workspaces/operations/relations.ts Simplifies relation target resolution to consume kernel path resolutions; contributes to batch-created relation regression.
src/features/workspaces/operations/workspace-tool-schemas.ts Updates tool schemas for the new read contract and reduced item creation surface.

Fix All in Cursor

Reviews (1): Last reviewed commit: "docs(workspaces): shape document AI edit..." | Re-trigger Greptile

Comment thread src/features/workspaces/operations/create-items.ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d1d6686a53

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/features/workspaces/extraction/workspace-page-projection.ts Outdated
Comment thread src/features/workspaces/operations/create-items.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/features/workspaces/realtime/messages.ts (1)

20-46: 🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift

Normalize pre-refactor events before replay.

Persisted created/deleted events lack itemFacts; replaying them into the new page reducer can call .map on undefined. Migrate or normalize historical events, or force a fresh snapshot when an old payload is encountered.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/features/workspaces/realtime/messages.ts` around lines 20 - 46, Update
the realtime event replay path for historical workspace item created/deleted
events so payloads missing itemFacts are migrated or normalized before reaching
the page reducer. Ensure the reducer always receives an itemFacts array, or
trigger a fresh snapshot when normalization is impossible; preserve current
handling for events that already include itemFacts. Reference the
created/deleted event handling and the page-reducer replay entry point.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/features/workspaces/content/workspace-content-reader.ts`:
- Around line 249-265: The typed content readers must preserve Markdown
whitespace exactly. In createDocumentChunk, remove trimEnd() from the source
slice while keeping cursor advancement based on the original end boundary; in
workspace-page-projection.ts lines 189-198, return page Markdown without trim()
and avoid trimming during assembly.

In `@src/features/workspaces/documents/document-session.ts`:
- Around line 179-187: Update readMarkdown to serialize the current Tiptap
document into a local Markdown value before awaiting crypto.subtle.digest, then
return that captured value with the corresponding revision. Keep the
state-vector digest flow unchanged while ensuring both fields represent the same
document snapshot.

In `@src/features/workspaces/model/workspace-page.ts`:
- Around line 47-61: Update upsertWorkspaceItemFactsInPage to return the
existing page unchanged when the incoming revision is lower than page.revision,
before merging itemFacts. Preserve the current merge behavior and
maximum-revision handling for revisions equal to or newer than the page
revision.

In `@src/features/workspaces/operations/workspace-operation-observability.ts`:
- Around line 57-70: Update summarizeWorkspaceReadResult in
src/features/workspaces/operations/workspace-operation-observability.ts:57-70 to
count only ready results as succeeded and represent pending results explicitly
in the summary. In
src/features/workspaces/components/ai-chat/ai-chat-tool-receipts.ts:256-260,
update the read-result handling to detect pending results and avoid returning
completed("Read 0 items").

---

Outside diff comments:
In `@src/features/workspaces/realtime/messages.ts`:
- Around line 20-46: Update the realtime event replay path for historical
workspace item created/deleted events so payloads missing itemFacts are migrated
or normalized before reaching the page reducer. Ensure the reducer always
receives an itemFacts array, or trigger a fresh snapshot when normalization is
impossible; preserve current handling for events that already include itemFacts.
Reference the created/deleted event handling and the page-reducer replay entry
point.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9fcccb10-69b0-4628-9933-29327ffff603

📥 Commits

Reviewing files that changed from the base of the PR and between c84d411 and d1d6686.

📒 Files selected for processing (46)
  • docs/project/document-ai-editing-refactor.md
  • src/features/workspaces/ai/ai-thread-runtime.ts
  • src/features/workspaces/cache-workspace.ts
  • src/features/workspaces/components/WorkspaceCreateMenu.tsx
  • src/features/workspaces/components/ai-chat/ai-chat-tool-receipts.ts
  • src/features/workspaces/content/workspace-content-contract.test.ts
  • src/features/workspaces/content/workspace-content-contract.ts
  • src/features/workspaces/content/workspace-content-cursor.ts
  • src/features/workspaces/content/workspace-content-reader.test.ts
  • src/features/workspaces/content/workspace-content-reader.ts
  • src/features/workspaces/contracts.ts
  • src/features/workspaces/defaults.ts
  • src/features/workspaces/document-session-access.ts
  • src/features/workspaces/documents/document-item-content.ts
  • src/features/workspaces/documents/document-session.ts
  • src/features/workspaces/extraction/workspace-page-projection.test.ts
  • src/features/workspaces/extraction/workspace-page-projection.ts
  • src/features/workspaces/kernel/workspace-kernel-access.ts
  • src/features/workspaces/kernel/workspace-kernel-events.test.ts
  • src/features/workspaces/kernel/workspace-kernel-file-commands.ts
  • src/features/workspaces/kernel/workspace-kernel-files.ts
  • src/features/workspaces/kernel/workspace-kernel-item-commands.ts
  • src/features/workspaces/kernel/workspace-kernel-relations.ts
  • src/features/workspaces/kernel/workspace-kernel-store.ts
  • src/features/workspaces/kernel/workspace-kernel-types.ts
  • src/features/workspaces/kernel/workspace-kernel.ts
  • src/features/workspaces/model/item-display.ts
  • src/features/workspaces/model/object-registry.ts
  • src/features/workspaces/model/workspace-item-colors.ts
  • src/features/workspaces/model/workspace-page.test.ts
  • src/features/workspaces/model/workspace-page.ts
  • src/features/workspaces/operations/create-items.ts
  • src/features/workspaces/operations/delete-items.ts
  • src/features/workspaces/operations/edit-item.ts
  • src/features/workspaces/operations/link-items.ts
  • src/features/workspaces/operations/list-items.ts
  • src/features/workspaces/operations/move-items.ts
  • src/features/workspaces/operations/read-items.ts
  • src/features/workspaces/operations/relations.ts
  • src/features/workspaces/operations/rename-item.ts
  • src/features/workspaces/operations/workspace-operation-context.ts
  • src/features/workspaces/operations/workspace-operation-observability.ts
  • src/features/workspaces/operations/workspace-tool-definitions.ts
  • src/features/workspaces/operations/workspace-tool-schemas.ts
  • src/features/workspaces/realtime/messages.ts
  • src/features/workspaces/use-create-workspace.ts
💤 Files with no reviewable changes (3)
  • src/features/workspaces/defaults.ts
  • src/features/workspaces/model/workspace-item-colors.ts
  • src/features/workspaces/kernel/workspace-kernel-store.ts

Comment thread src/features/workspaces/content/workspace-content-reader.ts Outdated
Comment thread src/features/workspaces/documents/document-session.ts Outdated
Comment thread src/features/workspaces/model/workspace-page.ts

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed against the latest diff

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread src/features/workspaces/extraction/workspace-page-projection.ts Outdated
Comment thread src/features/workspaces/contracts.ts Outdated
Comment thread src/features/workspaces/documents/document-session.ts Outdated
Comment thread src/features/workspaces/model/workspace-page.ts
Comment thread src/features/workspaces/content/workspace-content-reader.ts Outdated
Comment thread src/features/workspaces/documents/document-session.ts Outdated
Comment thread src/features/workspaces/kernel/workspace-kernel.ts Outdated
Comment thread src/features/workspaces/components/ai-chat/ai-chat-tool-receipts.ts
Comment thread src/features/workspaces/content/workspace-content-reader.ts Outdated
Comment thread src/features/workspaces/contracts.ts Outdated
urjitc added 3 commits July 17, 2026 23:44
Consume page bodies without retaining live R2 responses.
Preserve exact Markdown and keep old manifests readable under
the runtime byte budget.

Move document chunking behind DocumentSession with a
revision-keyed snapshot cache. Make projection updates
idempotent across workflow retries.

Tests: pnpm test; pnpm test:workers; pnpm exec vp check
Validate realtime messages before cache updates and collapse
reconnect, revision-gap, and invalid-message recovery into one
canonical refetch path.

Ignore stale events, query facts only for selected items, and
report pending extraction separately from successful reads.

Tests: pnpm test; pnpm test:workers; pnpm exec vp check
Run an explicit Durable Object SQLite migration before current
item schemas load. Remove legacy relations and projections, then
soft-retire flashcard and quiz rows without a runtime shim.

Tests: pnpm test; pnpm test:workers; pnpm exec vp check

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/features/workspaces/extraction/workspace-page-projection.ts (2)

342-350: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Keep whitespace, but do not treat whitespace-only extraction as usable.

Returning raw Markdown is correct, but writeWorkspacePageProjection subsequently checks page.markdown.length > 0. A page containing only spaces/newlines can therefore publish an otherwise unusable projection. Use page.markdown.trim().length > 0 solely for the usability check while preserving the stored value.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/features/workspaces/extraction/workspace-page-projection.ts` around lines
342 - 350, Update writeWorkspacePageProjection’s Markdown usability check to use
page.markdown.trim().length > 0, so whitespace-only extraction is rejected.
Preserve normalizeProjectionPage’s raw Markdown return value and retain the
original whitespace when storing usable page content.

11-11: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Do not downgrade the persisted projection schema version.

Existing version-2 manifests now fail the exact schema check at Lines 249-250. Keep version 2 while making pages optional, or explicitly support both versions during migration.

-const projectionSchemaVersion = 1;
+const projectionSchemaVersion = 2;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/features/workspaces/extraction/workspace-page-projection.ts` at line 11,
Update projectionSchemaVersion to preserve version 2 rather than downgrading
persisted manifests. Keep the pages field optional while retaining version-2
compatibility, or explicitly accept both schema versions in the validation and
migration logic.
🧹 Nitpick comments (1)
src/features/workspaces/kernel/workspace-kernel-item-commands.ts (1)

388-404: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Remove unreachable dead code.

Because the method immediately throws an error if type !== "document" at line 378, the else block here is completely unreachable.

♻️ Proposed refactor
-		if (type === "document") {
-			persistDocumentItemContentUpdate({
-				content: input.content,
-				itemId: input.itemId,
-				metadataJson: item.metadata_json,
-				sql: this.sql,
-				updatedAt: now,
-			});
-		} else {
-			touchWorkspaceItemUpdatedAt({
-				itemId: input.itemId,
-				sql: this.sql,
-				updatedAt: now,
-			});
-		}
+		persistDocumentItemContentUpdate({
+			content: input.content,
+			itemId: input.itemId,
+			metadataJson: item.metadata_json,
+			sql: this.sql,
+			updatedAt: now,
+		});
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/features/workspaces/kernel/workspace-kernel-item-commands.ts` around
lines 388 - 404, Remove the unreachable else branch calling
touchWorkspaceItemUpdatedAt from the update method, since the earlier type
validation guarantees type is "document". Keep the
persistDocumentItemContentUpdate call and its existing arguments unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/features/workspaces/documents/document-markdown-chunk.ts`:
- Around line 37-43: Adjust the chunk-boundary calculation around hardEnd in the
document markdown chunking logic to back off one UTF-16 code unit when it falls
between a high and low surrogate, ensuring content never splits a surrogate
pair. Add a boundary test covering mixed ASCII and emoji text while preserving
the existing newline and minimum-chunk behavior.

In `@src/features/workspaces/kernel/workspace-kernel-item-commands.ts`:
- Around line 81-96: Update the prior-result lookup in getPriorResult to run
whenever clientMutationId is provided, including requests without input.id.
Modify findCreatedItemEvent to identify the created item from the event payload
and return its itemId, then use that returned ID to fetch the item while
preserving the existing hydration and result structure.

In `@src/features/workspaces/realtime/use-workspace-presence.ts`:
- Around line 130-133: Update the message-handling branch around
parseServerMessage so a null or unrecognized message is ignored and returned
without invoking onDesyncRef.current. Preserve desync handling for actual
synchronization failures detected elsewhere in the workspace presence flow.

---

Outside diff comments:
In `@src/features/workspaces/extraction/workspace-page-projection.ts`:
- Around line 342-350: Update writeWorkspacePageProjection’s Markdown usability
check to use page.markdown.trim().length > 0, so whitespace-only extraction is
rejected. Preserve normalizeProjectionPage’s raw Markdown return value and
retain the original whitespace when storing usable page content.
- Line 11: Update projectionSchemaVersion to preserve version 2 rather than
downgrading persisted manifests. Keep the pages field optional while retaining
version-2 compatibility, or explicitly accept both schema versions in the
validation and migration logic.

---

Nitpick comments:
In `@src/features/workspaces/kernel/workspace-kernel-item-commands.ts`:
- Around line 388-404: Remove the unreachable else branch calling
touchWorkspaceItemUpdatedAt from the update method, since the earlier type
validation guarantees type is "document". Keep the
persistDocumentItemContentUpdate call and its existing arguments unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5df82d2f-dbd7-4965-8f9e-f071c948175f

📥 Commits

Reviewing files that changed from the base of the PR and between d1d6686 and d27e494.

📒 Files selected for processing (30)
  • src/features/workspaces/components/WorkspaceLayout.tsx
  • src/features/workspaces/components/ai-chat/ai-chat-tool-receipts.test.ts
  • src/features/workspaces/components/ai-chat/ai-chat-tool-receipts.ts
  • src/features/workspaces/content/workspace-content-contract.ts
  • src/features/workspaces/content/workspace-content-reader.test.ts
  • src/features/workspaces/content/workspace-content-reader.ts
  • src/features/workspaces/document-session-access.ts
  • src/features/workspaces/documents/document-markdown-chunk.test.ts
  • src/features/workspaces/documents/document-markdown-chunk.ts
  • src/features/workspaces/documents/document-session.ts
  • src/features/workspaces/extraction/liteparse-projection.ts
  • src/features/workspaces/extraction/request-workspace-file-extraction.ts
  • src/features/workspaces/extraction/workspace-file-extraction-workflow.ts
  • src/features/workspaces/extraction/workspace-page-projection.test.ts
  • src/features/workspaces/extraction/workspace-page-projection.ts
  • src/features/workspaces/kernel/workspace-kernel-events.test.ts
  • src/features/workspaces/kernel/workspace-kernel-events.ts
  • src/features/workspaces/kernel/workspace-kernel-file-commands.ts
  • src/features/workspaces/kernel/workspace-kernel-item-commands.ts
  • src/features/workspaces/kernel/workspace-kernel-list.ts
  • src/features/workspaces/kernel/workspace-kernel-rows.ts
  • src/features/workspaces/kernel/workspace-kernel-store.ts
  • src/features/workspaces/kernel/workspace-kernel-types.ts
  • src/features/workspaces/kernel/workspace-kernel.ts
  • src/features/workspaces/model/workspace-page.ts
  • src/features/workspaces/operations/create-items.ts
  • src/features/workspaces/operations/workspace-operation-observability.test.ts
  • src/features/workspaces/operations/workspace-operation-observability.ts
  • src/features/workspaces/realtime/messages.ts
  • src/features/workspaces/realtime/use-workspace-presence.ts
💤 Files with no reviewable changes (1)
  • src/features/workspaces/kernel/workspace-kernel-types.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/features/workspaces/kernel/workspace-kernel-file-commands.ts
  • src/features/workspaces/operations/create-items.ts
  • src/features/workspaces/model/workspace-page.ts
  • src/features/workspaces/content/workspace-content-contract.ts

Comment thread src/features/workspaces/documents/document-markdown-chunk.ts Outdated
Comment thread src/features/workspaces/kernel/workspace-kernel-item-commands.ts Outdated
Comment thread src/features/workspaces/realtime/use-workspace-presence.ts

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 1 file (changes from recent commits).

Requires human review: Auto-approval blocked by 3 unresolved issues from previous reviews.

Re-trigger cubic

urjitc added 2 commits July 18, 2026 00:14
Keep flashcards, quizzes, and audio recording as future workspace capabilities.

Remove the speculative retirement migration.
Use explicit menu groups instead of generic registry filters.
Use the generated DocumentSession stub instead of a hand-written client mirror.

Keep the narrow read seam at its actual test boundary.
Hide kernel list selection and formatting behind one complete operation.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 14 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread src/features/workspaces/model/item-display.ts
Comment thread src/features/workspaces/model/object-registry.ts Outdated
Keep document chunks on valid UTF-16 boundaries and ignore unknown realtime messages.

Require stable item IDs for idempotent create commands.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 6 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread src/features/workspaces/kernel/workspace-kernel-item-commands.ts
urjitc added 5 commits July 18, 2026 00:46
Use one Base64URL codec and SHA-256 helper.

Share it across upload tokens, content cursors, extraction identities, and document revisions.
Define item schemas, names, labels, colors, and storage metadata in one server-safe registry.

Keep React icons in the UI adapter.
Keep realtime event payloads immutable.

Store idempotency identity in a dedicated receipt table keyed by client mutation ID.
Reuse the canonical create command input so kernel clients cannot omit stable item IDs.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 24 files (changes from recent commits).

Requires human review: Requires human sign-off for contract change making item creation require stable IDs, and for merging reconnect and desync recovery handlers, which alters client cache invalidation behavior.

Re-trigger cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 1 file (changes from recent commits).

Requires human review: Changes workspace_read_items tool input/output contract (new required mode field, output shape) and makes item creation id required. Contract changes need human verification for backward compatibility and consumer updates.

Re-trigger cubic

Comment thread src/features/workspaces/content/workspace-content-reader.ts
Comment thread src/features/workspaces/extraction/workspace-page-projection.ts
Comment thread src/features/workspaces/operations/create-items.ts
@urjitc
urjitc merged commit 8531209 into main Jul 18, 2026
11 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Dev Board Jul 18, 2026
@urjitc
urjitc deleted the codex/workspace-architecture-greenfield branch July 18, 2026 05:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant