Skip to content

feat(editor): complete Wiki Compose P2 entry points and chat seed (#950)#961

Merged
otomatty merged 3 commits into
developfrom
cursor/wiki-compose-p2-remaining-1d7d
May 25, 2026
Merged

feat(editor): complete Wiki Compose P2 entry points and chat seed (#950)#961
otomatty merged 3 commits into
developfrom
cursor/wiki-compose-p2-remaining-1d7d

Conversation

@otomatty

@otomatty otomatty commented May 24, 2026

Copy link
Copy Markdown
Owner

Summary

Completes the remaining issue #950 work on top of the merged P2 orchestrator/UI (#959, #960):

  • PageActionHub — registers wiki.compose and opens the split-screen Compose flow from the hub when wikiComposeHref is configured.
  • AI Chat entry — replaces the legacy pendingChatPageGeneration navigate state with navigateToWikiCompose() (create-page, create-multiple-pages, Promote to Wiki).
  • Chat seed — forwards outline + conversation (and optional schema) via location state → session metadata → graph chatSeed so brief_dialogue can bias Brief questions.

Test plan

  • vitest runnavigation, runAIChatAction, useWikiComposeSession, PageActionHub/registry
  • server/apiwikiComposeGraph.test.ts
  • Manual: PageActionHub → Wiki Compose on a note-native page with a title
  • Manual: AI Chat create-page → lands on /compose with Brief phase
  • Existing E2E e2e/wiki-compose.spec.ts happy path (unchanged)

Notes

  • Left pane remains Markdown preview during draft (MVP documented in EditorPane); full Tiptap reuse is a follow-up.
  • pendingChatPageGeneration had no consumer on NotePageView; this PR removes the dead navigation contract.

Closes #950

Open in Web Open in Cursor 

Summary by CodeRabbit

  • New Features

    • Added a Wiki Compose action in the editor, a Compose screen route, and navigation helpers that can seed the compose flow with chat context (outline, conversation text, optional schema/id).
    • Editor and page action wiring now expose the Compose entry point for note-native pages.
    • Compose sessions now accept and surface projected checkpoint data for UI resume/reload.
  • Tests

    • Added/updated tests for navigation, session projection/hydration, gating, and page-action availability.
  • Localization

    • Added UI strings for the new Wiki Compose action (en/ja).

Review Change Stack

- Register PageActionHub wiki.compose action with compose navigation
- Replace pendingChatPageGeneration with navigateToWikiCompose from AI chat
- Pass chat seed through session metadata and graph chatSeed state
- Wire wikiComposeHref into PageActionHub context from the page editor
@coderabbitai

coderabbitai Bot commented May 24, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR seeds Wiki Compose sessions with optional chat-context (outline, conversationText, optional schema/conversationId): adds backend types/state and LLM prompt wiring, a navigation helper that forwards seed via location.state, editor/PageActionHub wiring for a wiki.compose action, session hydration/projection APIs, and updated tests/i18n.

Changes

Wiki Compose Chat Seed Integration

Layer / File(s) Summary
Backend seed contract and prompt wiring
server/api/src/agents/graphs/wikiCompose/types.ts, server/api/src/agents/graphs/wikiCompose/state.ts, server/api/src/agents/graphs/wikiCompose/nodes/briefDialogue.ts
Adds ComposeChatSeed type and nullable chatSeed state channel; expands buildUserPrompt to accept a chat seed and append truncated outline, conversation excerpt, and user schema when present; briefDialogue now passes state.chatSeed into prompt building.
Wiki Compose navigation routing with seed support
src/lib/wikiCompose/navigation.ts, src/lib/wikiCompose/navigation.test.ts
New helper builds /notes/:noteId/:pageId/compose and navigateToWikiCompose which conditionally sets location.state[COMPOSE_SEED_STATE_KEY] to the seed; tests assert path and seeded/unstyled navigation.
Editor props & PageActionContext wiring
src/components/editor/TiptapEditor/types.ts, src/components/editor/TiptapEditor.tsx, src/components/editor/TiptapEditor/useTiptapEditorController.ts, src/components/note/PageEditorContent.tsx, src/components/editor/PageActionHub/types.ts
Threads wikiComposeHref through editor props and controller into PageActionContext so PageActionHub can surface the compose action when available.
PageActionHub wiki.compose action and registry
src/components/editor/PageActionHub/actions/WikiComposeAction.tsx, src/components/editor/PageActionHub/registry.ts, src/components/editor/PageActionHub/PageActionHub.test.tsx, src/components/editor/PageActionHub/registry.test.ts
Adds WikiComposeAction component, registers wiki.compose in PAGE_ACTIONS with an availability gate (editable, signed-in, non-empty trimmed title, href present), and updates tests and translation mocks.
Chat action flows migrated to Wiki Compose navigation
src/hooks/runAIChatAction.ts, src/hooks/runAIChatAction.test.ts, src/components/ai-chat/PromoteToWikiDialog.tsx
Replaces legacy inline pending navigation with navigateToWikiCompose, seeding compose with generated outline and conversationText; updates tests to expect /compose navigation and seed state.
Session creation, hydration & run input derivation
src/hooks/useWikiComposeSession.ts, src/pages/WikiComposePage.tsx, src/lib/wikiCompose/composeService.ts
Hook accepts optional composeSeed, persists it into new session.metadata.composeSeed, hydrates UI state from server projection, derives run input from initialInput or parsed session.metadata.composeSeed, and only streams run when session.status warrants; WikiComposePage reads seed from location.state and clears it after session advances.
Compose projection & API
server/api/src/routes/composeSessionProjection.ts, server/api/src/routes/composeSessions.ts, src/lib/wikiCompose/types.ts, src/lib/wikiCompose/composeService.ts
Adds ComposeSessionUiProjection, projects checkpoint state to a UI-friendly shape, loads graph state for projection, and GET session endpoint now returns { session, projection }; frontend service types updated to return optional projection.
Tests & localization
server/api/src/__tests__/routes/composeSessionProjection.test.ts, src/hooks/useWikiComposeSession.test.ts, src/lib/wikiCompose/navigation.test.ts, src/i18n/locales/en/editor.json, src/i18n/locales/ja/editor.json
New/updated tests for projection, navigation, session hydration, and runAIChatAction; adds en/ja i18n strings for wiki.compose and extends test translation mocks.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~40 minutes

Possibly related PRs

  • otomatty/zedi#959: Related Wiki Compose orchestrator work that defines briefDialogue and shared types; changes here extend that flow with chat-seed wiring.
  • otomatty/zedi#401: Overlapping tests and runAIChatAction navigation assertions around compose seed navigation/state.

Poem

A seed is tucked into the compose path,
Outline and chat steer the LLM’s craft,
From click to session, state flows neat and keen,
Pages hum as prompts are gently green,
— a rabbit nods, delighted by the scene. 🐇✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Linked Issues check ❓ Inconclusive The PR implements core requirements from #950: split-screen UI wiring via PageActionHub, chat seed forwarding, and AI Chat entry point replacement. However, some acceptance criteria remain incomplete or not validated in this PR. Verify that the split layout, variable brief questions, research interrupt UI, outline editing, section writing, session resume, and P1 subgraph integration are fully functional and covered by E2E tests as per #950 acceptance criteria.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: completing Wiki Compose P2 entry points and adding chat seed support, directly addressing issue #950.
Out of Scope Changes check ✅ Passed All changes are scoped to #950 objectives: entry point registration, chat seed plumbing, navigation refactoring, and test updates. No unrelated modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 cursor/wiki-compose-p2-remaining-1d7d

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

@otomatty otomatty marked this pull request as ready for review May 24, 2026 23:23
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request implements the 'Wiki Compose' feature, enabling a guided flow for co-authoring wiki pages with AI using context from chat sessions. It replaces the legacy 'pendingChatPageGeneration' logic with a structured 'chatSeed' passed through navigation state to a new split-screen Compose UI. Key changes include updates to the LangGraph state and nodes to handle chat context, the addition of a 'WikiComposeAction' to the Page Action Hub, and new navigation helpers. Feedback identifies a critical missing prop destructuring in 'PageEditorContent.tsx' that will cause a ReferenceError and an issue in 'useWikiComposeSession.ts' where internal state is not correctly hydrated when resuming existing sessions.

wikiContentForCollab={wikiContentForCollab ?? undefined}
onWikiContentApplied={onWikiContentApplied}
pageNoteId={pageNoteId}
wikiComposeHref={wikiComposeHref}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The variable wikiComposeHref is used here but it has not been destructured from the component's props or defined within the scope of PageEditorContent. This will likely result in a ReferenceError at runtime. Please ensure it is added to the props destructuring at the top of the component.

Comment thread src/hooks/useWikiComposeSession.ts Outdated
: undefined,
});
sessionRef.current = session;
update({ session, status: session.status, error: null });

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

When resuming an existing session via getSession, the hook's internal state (such as phase, briefQuestions, outlineProposal, etc.) is not hydrated from the session's persisted state. Since streamRun is skipped for non-pending sessions, the UI will remain in the initial state upon page refresh. You should extract the state from the session object and update the hook's state accordingly, similar to how reduceResumeOutput is used in the submission handlers.

@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: 6e11568099

ℹ️ 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 on lines +84 to +88
if (!composeSeed || !location.state) return;
navigate(location.pathname + location.search + location.hash, {
replace: true,
state: null,
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep compose seed until run is durably initialized

Clearing location.state immediately drops the only seed source before we know the first POST /run actually persisted chatSeed into graph state. If the page is reloaded (or the initial run fails before consuming input), the URL now points to /compose/:sessionId with no state, and useWikiComposeSession will restart a pending/failed session without initialInput, so Brief loses the chat-derived outline/conversation context. This is user-visible in flaky-network or interrupted-first-run scenarios and makes chat→compose behavior non-deterministic.

Useful? React with 👍 / 👎.

@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: 5

🧹 Nitpick comments (3)
src/components/editor/PageActionHub/actions/WikiComposeAction.tsx (1)

15-16: ⚡ Quick win

Make the exported component JSDoc bilingual for consistency.

Line 15 has an English-only JSDoc on an exported component; add a Japanese line to match the repository’s bilingual documentation convention.

Proposed fix
-/** Detail view for the wiki.compose hub action. */
+/**
+ * `wiki.compose` アクションの詳細ビュー。
+ * Detail view for the wiki.compose hub action.
+ */

As per coding guidelines, "Include both Japanese and English comments/documentation in code and documentation files to maintain project tone consistency".

🤖 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/components/editor/PageActionHub/actions/WikiComposeAction.tsx` around
lines 15 - 16, The exported component WikiComposeAction currently has an
English-only JSDoc; update its comment block above the declaration of
WikiComposeAction to include a Japanese translation line matching the repository
convention (add a brief Japanese sentence conveying "Detail view for the
wiki.compose hub action"), keeping both English and Japanese sentences in the
JSDoc for consistency with other exported components.
src/components/editor/PageActionHub/registry.test.ts (1)

75-92: ⚡ Quick win

Add explicit read-only and signed-out cases for wiki.compose gates.

This block currently verifies href/title gates, but not isReadOnly and isSignedIn. Adding both keeps tests aligned with the full gate contract and prevents silent regressions.

✅ Suggested test additions
   describe("wiki.compose availability gates", () => {
     const action = PAGE_ACTIONS.find((a) => a.id === "wiki.compose");
     if (!action) throw new Error("missing wiki.compose");
@@
     it("タイトルが空のときは不可 / blocked when title is empty", () => {
       expect(
         action.isAvailable(makeCtx({ pageTitle: "", wikiComposeHref: "/notes/n/p/compose" })),
       ).toBe(false);
     });
+
+    it("isReadOnly では不可 / blocked when read-only", () => {
+      expect(
+        action.isAvailable(makeCtx({ isReadOnly: true, wikiComposeHref: "/notes/n/p/compose" })),
+      ).toBe(false);
+    });
+
+    it("isSignedIn=false では不可 / blocked when signed out", () => {
+      expect(
+        action.isAvailable(makeCtx({ isSignedIn: false, wikiComposeHref: "/notes/n/p/compose" })),
+      ).toBe(false);
+    });
   });
🤖 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/components/editor/PageActionHub/registry.test.ts` around lines 75 - 92,
Test coverage for the "wiki.compose" action is missing checks for read-only and
signed-out gates; update the tests around PAGE_ACTIONS.find(a => a.id ===
"wiki.compose") and action.isAvailable by adding two cases using makeCtx: one
where isReadOnly: true with a valid wikiComposeHref and non-empty pageTitle
should assert false, and another where isSignedIn: false (or equivalent unsigned
context) with valid href/title should assert false, ensuring the
action.isAvailable behavior respects isReadOnly and isSignedIn gates.
server/api/src/agents/graphs/wikiCompose/nodes/briefDialogue.ts (1)

77-77: ⚡ Quick win

Use the shared ComposeChatSeed type instead of an inline shape.

Typing chatSeed with the canonical interface avoids drift if fields evolve.

Suggested diff
-import type { BriefQuestion } from "../types.js";
+import type { BriefQuestion, ComposeChatSeed } from "../types.js";
...
 function buildUserPrompt(
   title: string,
   body: string,
-  chatSeed?: { outline: string; conversationText: string; userSchema?: string } | null,
+  chatSeed?: ComposeChatSeed | null,
 ): string {
🤖 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 `@server/api/src/agents/graphs/wikiCompose/nodes/briefDialogue.ts` at line 77,
Replace the inline chatSeed shape with the shared ComposeChatSeed type: update
the function/type declaration that currently declares chatSeed?: { outline:
string; conversationText: string; userSchema?: string } | null to use chatSeed?:
ComposeChatSeed | null, add the import for ComposeChatSeed from its module, and
ensure any usages inside briefDialogue (and exported types) are updated to the
ComposeChatSeed fields where needed so the code compiles with the canonical
type.
🤖 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 `@server/api/src/agents/graphs/wikiCompose/state.ts`:
- Around line 99-102: The channel comment for chatSeed is missing a Japanese
translation; update the documentation block for the chatSeed channel (the
comment above the Chat → Compose seed description) to include a Japanese
sentence that mirrors the existing English text so both languages are present
(e.g., add a Japanese line explaining that chatSeed is the Chat → Compose seed
set on the first POST /run input when the user arrives from AI Chat / Promote to
Wiki), keeping the same comment style and placement around the chatSeed/channel
documentation.

In `@server/api/src/agents/graphs/wikiCompose/types.ts`:
- Around line 17-20: The docblock for the new ComposeChatSeed type is
English-only; add a concise Japanese translation to the comment so it is
bilingual per project guidelines. Update the comment above ComposeChatSeed to
include the same content in Japanese followed by the existing English text (or
vice versa), covering that it is an optional chat context seeded when entering
Compose from AI Chat and that it is passed on the first graph `input` and stored
on the session row metadata. Ensure the Japanese text is natural and matches the
technical meaning of the English comment.

In `@src/hooks/useWikiComposeSession.ts`:
- Around line 109-112: Update the JSDoc comments for the interface properties
initialInput and composeSeed in useWikiComposeSession.ts to include both
Japanese and English descriptions; for example, add a Japanese sentence before
or after each English sentence so each property has a JA line and an EN line
(e.g., "初回実行時のオプションの入力(例: Brief のチャットシード)。 / Optional initial body for the first
run (e.g. chat seed for Brief)." and similarly for composeSeed referencing
ComposeNavigationSeed), keeping the existing wording but adding the Japanese
translation and preserving the property names initialInput and composeSeed.

In `@src/lib/wikiCompose/navigation.ts`:
- Around line 14-31: The exported interface NavigateToWikiComposeParams lacks
TSDoc and bilingual (JP/EN) documentation; add a JSDoc/TSDoc block above the
interface that documents the interface purpose and each field (navigate, noteId,
pageId, seed) in both English and Japanese, matching style of nearby exported
docs (e.g., reference COMPOSE_SEED_STATE_KEY and ComposeNavigationSeed types),
include brief descriptions for optional seed and NavigateFunction usage, and
keep punctuation and tags consistent with other exported comments.

In `@src/pages/WikiComposePage.tsx`:
- Line 50: Update the two new inline comments in WikiComposePage.tsx (the
comment near "Capture chat seed once; clearing `location.state` must not drop it
before run." at the first location and the comment around line 82) to include
both Japanese and English text per repo convention; replace each English-only
comment with a bilingual version (Japanese sentence followed by English sentence
or vice versa) while keeping the original meaning and referencing the same
context so the comments remain adjacent to the same code (no code changes
needed).

---

Nitpick comments:
In `@server/api/src/agents/graphs/wikiCompose/nodes/briefDialogue.ts`:
- Line 77: Replace the inline chatSeed shape with the shared ComposeChatSeed
type: update the function/type declaration that currently declares chatSeed?: {
outline: string; conversationText: string; userSchema?: string } | null to use
chatSeed?: ComposeChatSeed | null, add the import for ComposeChatSeed from its
module, and ensure any usages inside briefDialogue (and exported types) are
updated to the ComposeChatSeed fields where needed so the code compiles with the
canonical type.

In `@src/components/editor/PageActionHub/actions/WikiComposeAction.tsx`:
- Around line 15-16: The exported component WikiComposeAction currently has an
English-only JSDoc; update its comment block above the declaration of
WikiComposeAction to include a Japanese translation line matching the repository
convention (add a brief Japanese sentence conveying "Detail view for the
wiki.compose hub action"), keeping both English and Japanese sentences in the
JSDoc for consistency with other exported components.

In `@src/components/editor/PageActionHub/registry.test.ts`:
- Around line 75-92: Test coverage for the "wiki.compose" action is missing
checks for read-only and signed-out gates; update the tests around
PAGE_ACTIONS.find(a => a.id === "wiki.compose") and action.isAvailable by adding
two cases using makeCtx: one where isReadOnly: true with a valid wikiComposeHref
and non-empty pageTitle should assert false, and another where isSignedIn: false
(or equivalent unsigned context) with valid href/title should assert false,
ensuring the action.isAvailable behavior respects isReadOnly and isSignedIn
gates.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f2b882d3-9fc4-476b-b2bb-73deb9a657ac

📥 Commits

Reviewing files that changed from the base of the PR and between bda5585 and 6e11568.

📒 Files selected for processing (21)
  • server/api/src/agents/graphs/wikiCompose/nodes/briefDialogue.ts
  • server/api/src/agents/graphs/wikiCompose/state.ts
  • server/api/src/agents/graphs/wikiCompose/types.ts
  • src/components/ai-chat/PromoteToWikiDialog.tsx
  • src/components/editor/PageActionHub/PageActionHub.test.tsx
  • src/components/editor/PageActionHub/actions/WikiComposeAction.tsx
  • src/components/editor/PageActionHub/registry.test.ts
  • src/components/editor/PageActionHub/registry.ts
  • src/components/editor/PageActionHub/types.ts
  • src/components/editor/TiptapEditor.tsx
  • src/components/editor/TiptapEditor/types.ts
  • src/components/editor/TiptapEditor/useTiptapEditorController.ts
  • src/components/note/PageEditorContent.tsx
  • src/hooks/runAIChatAction.test.ts
  • src/hooks/runAIChatAction.ts
  • src/hooks/useWikiComposeSession.ts
  • src/i18n/locales/en/editor.json
  • src/i18n/locales/ja/editor.json
  • src/lib/wikiCompose/navigation.test.ts
  • src/lib/wikiCompose/navigation.ts
  • src/pages/WikiComposePage.tsx

Comment thread server/api/src/agents/graphs/wikiCompose/state.ts
Comment thread server/api/src/agents/graphs/wikiCompose/types.ts
Comment thread src/hooks/useWikiComposeSession.ts Outdated
Comment thread src/lib/wikiCompose/navigation.ts Outdated
Comment thread src/pages/WikiComposePage.tsx Outdated
…950)

- GET compose-sessions/:id returns checkpoint projection for interrupted rows
- useWikiComposeSession merges projection on reload without POST /run
- Clear location.state only after session leaves pending (Codex P2)
- Add JA+EN TSDoc on new chatSeed/navigation types

@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: 6

Caution

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

⚠️ Outside diff range comments (1)
src/hooks/useWikiComposeSession.ts (1)

310-323: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Move or update the stale JSDoc block above hydrateFromProjection.

The first block documents PATCH /resume output, but it now sits above hydrateFromProjection (GET projection merge). This makes docs misleading at the call site.

🤖 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/hooks/useWikiComposeSession.ts` around lines 310 - 323, The JSDoc about
`PATCH /resume` is stale and currently sits above `hydrateFromProjection`, which
actually merges the `GET /compose-sessions/:id` projection; move the `PATCH
/resume` block away from above `hydrateFromProjection` (either to the `resume`
handler/function or a nearby `hydrateFromResume` helper) or update the comment
to describe the GET projection behavior; specifically edit the comment blocks
around the `hydrateFromProjection` function so its docstring accurately
describes merging the `GET /compose-sessions/:id` checkpoint projection (and
relocate the `PATCH /resume` description to the appropriate `resume`-related
symbol).
🤖 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 `@server/api/src/__tests__/routes/composeSessionProjection.test.ts`:
- Around line 1-3: The file-level docblock at the top of
composeSessionProjection.test.ts is English-only; update that comment to include
a Japanese translation alongside the existing English text (JA + EN) so the
file-level comment follows repo tone guidelines—edit the top comment block that
currently reads "`composeSessionProjection` unit tests (`#950`)." to add an
equivalent Japanese sentence immediately before or after the English line,
keeping the same docblock format.

In `@server/api/src/routes/composeSessionProjection.ts`:
- Around line 16-17: Update the new JSDoc comments to be bilingual by adding
Japanese translations alongside the existing English for the added documentation
blocks; specifically, augment the JSDoc for ComposeSessionUiProjection and the
other recently added comment blocks (the ones near the other interface/type
comments referenced in the review) so each description has both English and
Japanese lines, preserving the original English text and adding clear Japanese
equivalents for titles, summaries, and any parameter/property descriptions.
- Around line 122-124: The code always overwrites projection.phase with
phaseFromSessionRow(state.phase, "interrupted") even when projection.phase was
set earlier from the "__interrupt__" source; change the assignment to only set
projection.phase from state.phase when projection.phase is not already set by
the interrupt handling (e.g., wrap the existing line with a guard like if
(typeof state.phase === "string" && projection.phase == null) { projection.phase
= phaseFromSessionRow(state.phase, "interrupted"); } so interrupt-derived
projection.phase is preserved.

In `@server/api/src/routes/composeSessions.ts`:
- Around line 214-233: The GET projection path can throw UnsupportedBackendError
from assertSupportedBackendP0(row.backend) and cause a 500; wrap the backend
validation in a try/catch around the call to assertSupportedBackendP0 when
building the context for loadComposeSessionProjection, and if
UnsupportedBackendError is caught set backend to null (or a safe sentinel) and
log a warning, then proceed to call loadComposeSessionProjection so
stale/unsupported session rows return a projection instead of failing; reference
assertSupportedBackendP0, UnsupportedBackendError, and
loadComposeSessionProjection in the change.

In `@src/hooks/useWikiComposeSession.ts`:
- Around line 513-533: The code constructs runInput from a casted metadataSeed
without validating types, so update the runInput construction in
useWikiComposeSession.ts to first verify that metadataSeed.outline and
metadataSeed.conversationText are strings (e.g., typeof === 'string') before
building chatSeed, and likewise ensure metadataSeed.userSchema and
metadataSeed.conversationId are strings or set them to undefined; only build
runInput when validated values exist to prevent non-string values from being
passed to the /run payload (refer to metadataSeed and runInput identifiers).

In `@src/lib/wikiCompose/composeService.ts`:
- Around line 78-85: The exported docs for GetComposeSessionResult and
getSession are currently English-only; update their JSDoc comments to include
Japanese translations alongside the English lines (e.g., add a Japanese line
above or below the existing English sentence) so both the interface
GetComposeSessionResult and the function getSession have bilingual (JA + EN)
documentation per the project guideline.

---

Outside diff comments:
In `@src/hooks/useWikiComposeSession.ts`:
- Around line 310-323: The JSDoc about `PATCH /resume` is stale and currently
sits above `hydrateFromProjection`, which actually merges the `GET
/compose-sessions/:id` projection; move the `PATCH /resume` block away from
above `hydrateFromProjection` (either to the `resume` handler/function or a
nearby `hydrateFromResume` helper) or update the comment to describe the GET
projection behavior; specifically edit the comment blocks around the
`hydrateFromProjection` function so its docstring accurately describes merging
the `GET /compose-sessions/:id` checkpoint projection (and relocate the `PATCH
/resume` description to the appropriate `resume`-related symbol).
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4563062c-c943-4bcc-b227-27352a403152

📥 Commits

Reviewing files that changed from the base of the PR and between 6e11568 and af6299b.

📒 Files selected for processing (11)
  • server/api/src/__tests__/routes/composeSessionProjection.test.ts
  • server/api/src/agents/graphs/wikiCompose/state.ts
  • server/api/src/agents/graphs/wikiCompose/types.ts
  • server/api/src/routes/composeSessionProjection.ts
  • server/api/src/routes/composeSessions.ts
  • src/hooks/useWikiComposeSession.test.ts
  • src/hooks/useWikiComposeSession.ts
  • src/lib/wikiCompose/composeService.ts
  • src/lib/wikiCompose/navigation.ts
  • src/lib/wikiCompose/types.ts
  • src/pages/WikiComposePage.tsx

Comment thread server/api/src/__tests__/routes/composeSessionProjection.test.ts
Comment thread server/api/src/routes/composeSessionProjection.ts Outdated
Comment thread server/api/src/routes/composeSessionProjection.ts Outdated
Comment thread server/api/src/routes/composeSessions.ts Outdated
Comment thread src/hooks/useWikiComposeSession.ts Outdated
Comment thread src/lib/wikiCompose/composeService.ts Outdated
…950)

- Prefer interrupt-derived phase over row phase in projection
- GET session: skip projection when backend is unsupported (no 500)
- Validate metadata.composeSeed types before POST /run input
- Complete JA+EN docs on new compose navigation/projection APIs

@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.

🧹 Nitpick comments (1)
src/hooks/useWikiComposeSession.ts (1)

146-155: ⚡ Quick win

Move the activityId docblock back to the correct function and keep it JA+EN.

The activityId description currently sits above parseComposeSeedFromMetadata, so the docs are misleading and the block is English-only.

✏️ Suggested fix
-/**
- * Returns a unique id for an activity row. Uses crypto.randomUUID when
- * available (modern browsers); falls back to a coarse fallback for old
- * environments and SSR.
- */
 /**
  * `session.metadata.composeSeed` を型検証して graph input 用 seed にする。
  * Validate persisted `metadata.composeSeed` before sending `/run` input.
  */
 function parseComposeSeedFromMetadata(metadata: Record<string, unknown> | null | undefined):
@@
   return out;
 }
 
+/**
+ * 活動ログ行の一意 ID を返す。可能なら `crypto.randomUUID` を使う。
+ * Returns a unique id for an activity row. Uses crypto.randomUUID when available.
+ */
 function activityId(): string {
   if (typeof crypto !== "undefined" && "randomUUID" in crypto) return crypto.randomUUID();
   return `act-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
 }

As per coding guidelines: **/*.{ts,tsx,js,jsx,md} should include both Japanese and English comments/documentation in code and documentation files.

🤖 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/hooks/useWikiComposeSession.ts` around lines 146 - 155, The Javadoc for
activityId was accidentally placed above parseComposeSeedFromMetadata and is
English-only; move the activityId docblock so it immediately precedes the
activityId function/constant and restore the bilingual (JA + EN) description per
guidelines, leaving parseComposeSeedFromMetadata's own comment intact; search
for the symbol activityId and update the comment block content and placement
accordingly to include both Japanese and English descriptions.
🤖 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.

Nitpick comments:
In `@src/hooks/useWikiComposeSession.ts`:
- Around line 146-155: The Javadoc for activityId was accidentally placed above
parseComposeSeedFromMetadata and is English-only; move the activityId docblock
so it immediately precedes the activityId function/constant and restore the
bilingual (JA + EN) description per guidelines, leaving
parseComposeSeedFromMetadata's own comment intact; search for the symbol
activityId and update the comment block content and placement accordingly to
include both Japanese and English descriptions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6d6b7558-a491-48c5-9d5e-4c682dc3e842

📥 Commits

Reviewing files that changed from the base of the PR and between af6299b and 22663a6.

📒 Files selected for processing (7)
  • server/api/src/__tests__/routes/composeSessionProjection.test.ts
  • server/api/src/routes/composeSessionProjection.ts
  • server/api/src/routes/composeSessions.ts
  • src/hooks/useWikiComposeSession.test.ts
  • src/hooks/useWikiComposeSession.ts
  • src/lib/wikiCompose/composeService.ts
  • src/lib/wikiCompose/navigation.ts

@otomatty otomatty merged commit 2e5b7c2 into develop May 25, 2026
18 checks passed
@otomatty otomatty deleted the cursor/wiki-compose-p2-remaining-1d7d branch May 25, 2026 02:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(editor): Wiki Compose P2 — 分割画面 UI + wikiComposeGraph 全体

2 participants