Skip to content

fix: migration flow issue#1338

Merged
zerob13 merged 6 commits intodevfrom
bugfix/migration-flow-issue
Mar 9, 2026
Merged

fix: migration flow issue#1338
zerob13 merged 6 commits intodevfrom
bugfix/migration-flow-issue

Conversation

@zerob13
Copy link
Collaborator

@zerob13 zerob13 commented Mar 9, 2026

Summary by CodeRabbit

  • New Features

    • New Agent architecture with improved session/agent flow.
    • Default model configuration and built-in DimCode Agent.
    • Optimistic message display when sending for snappier UI.
  • Bug Fixes

    • Improved window embedding behavior for more reliable multi-window handling.
  • Chores

    • Version bumped to v1.0.0-beta.1.
  • Documentation

    • Architecture and spec docs reorganized; UI placeholder text fixed across locales.

zerob13 added 4 commits March 9, 2026 20:41
- Update HooksNotificationsDeps type to use new agent methods
- Replace getConversation with getSession, remove resolveWorkspaceContext
- Update buildPayload to extract workdir from session.projectDir directly
- Refactor extractPromptPreview to handle JSON serialized content
- Adjust presenter initialization order for dependency injection
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 9, 2026

📝 Walkthrough

Walkthrough

This PR removes extensive P0 planning/spec docs, updates architecture docs to the new agent presenter layout, bumps package version to 1.0.0-beta.1, adjusts presenter wiring and HooksNotifications API, tweaks YoBrowserPresenter and session creation, injects optimistic messages, and normalizes i18n placeholders.

Changes

Cohort / File(s) Summary
Documentation removal: P0 specs & plans
docs/specs/p0-implementation/**/spec.md, docs/specs/p0-implementation/**/plan.md, docs/specs/p0-implementation/**/tasks.md, docs/specs/p0-implementation/README.md, P0_DESIGN_DECISIONS.md, P0_IMPLEMENTATION_SUMMARY.md, GAP_ANALYSIS_SUMMARY.md
Deleted large set of P0 feature specifications, plans, tasks, and high-level design/implementation summaries (~thousands of lines).
Architecture docs update
docs/ARCHITECTURE.md, docs/FLOWS.md, docs/architecture/agent-system.md, docs/architecture/new-ui-implementation-plan.md
Rewrote agent-system to describe Renderer → NewAgentPresenter → DeepChatAgentPresenter two-layer architecture; added notes/links and metadata.
Presenter wiring & HooksNotifications API
src/main/presenter/hooksNotifications/index.ts, src/main/presenter/index.ts, src/main/presenter/newAgentPresenter/index.ts
Changed HooksNotifications types from getConversation/resolveWorkspaceContext → getSession/getMessage (+projectDir); updated extraction and payload logic; instantiated HooksNotificationsService twice (placeholder then real) and return session earlier in createSession.
Browser presenter behavior
src/main/presenter/browser/YoBrowserPresenter.ts, test/main/presenter/YoBrowserPresenter.test.ts
openWindow now selects/attaches embedded state to a target window; ensureEmbeddedState uses page.navigate and state.page.updatedAt; test helper auto-emits did-finish-load on listener registration.
Client session UX
src/renderer/src/stores/ui/session.ts
After createSession, inject optimistic user message when input.message present (uses MessageFile type).
i18n placeholder normalization
src/renderer/src/i18n/*/chat.json
src/renderer/src/i18n/en-US/chat.json, .../da-DK/..., .../fa-IR/..., .../fr-FR/..., .../he-IL/..., .../ja-JP/..., .../ko-KR/..., .../pt-BR/..., .../ru-RU/..., .../zh-CN/..., .../zh-HK/..., .../zh-TW/...
Escaped/normalized at-sign in input.placeholder strings to use {'@'} across locales.
Version bump
package.json
Version bumped from 1.0.01.0.0-beta.1.
Changelog addition
CHANGELOG.md
Added v1.0.0-beta.1 entry describing agent architecture, model config, removal of Chat mode, and built-in DimCode Agent.

Sequence Diagram(s)

sequenceDiagram
  participant Renderer
  participant Presenter
  participant HooksNotifications
  participant NewAgentPresenter
  participant DeepChatAgentPresenter

  Note over Presenter: Presenter startup
  Presenter->>HooksNotifications: instantiate with placeholder deps\n(getSession: async()=>null, getMessage: async()=>null)
  Renderer->>Presenter: UI events / requests
  Presenter->>NewAgentPresenter: create NewAgentPresenter
  NewAgentPresenter->>DeepChatAgentPresenter: init loop / session APIs
  Presenter->>HooksNotifications: re-instantiate with real deps\n(getSession: newAgentPresenter.getSession, getMessage: newAgentPresenter.getMessage)
  Renderer->>NewAgentPresenter: createSession(request)
  NewAgentPresenter-->>Renderer: return session (early)
  NewAgentPresenter->>DeepChatAgentPresenter: process initial message (background)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • fix: webhook hook #1335 — overlaps on hook wiring and deepchatAgentPresenter hook dispatch changes closely related to HooksNotifications updates.
  • Feat/new thread mock #1319 — foundational newAgentPresenter / deepchatAgentPresenter work matching architecture and session APIs modified here.
  • chore: yo browser less context #1284 — touches YoBrowserPresenter lifecycle/APIs and likely overlaps with the openWindow/ensureEmbeddedState edits.

Poem

🐰 Hop, I nibbled specs away,

New agent paths light up the day,
Beta tag upon my fur,
Optimistic hops occur,
At-signs tucked in tidy braces—huzzah!

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'fix: migration flow issue' is vague and does not clearly describe the main changes in this PR. The changeset includes version bumps, major documentation removals, architecture documentation updates, i18n placeholder fixes, and several functional code changes across multiple systems. Consider revising the title to be more specific about the primary change. For example: 'refactor: consolidate P0 documentation and update to v1.0.0-beta.1' or 'feat: implement new agent presenter architecture v1.0.0-beta.1' would better reflect the scope.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bugfix/migration-flow-issue

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 and usage tips.

@zerob13 zerob13 marked this pull request as ready for review March 9, 2026 15:09
@chatgpt-codex-connector
Copy link

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

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/main/presenter/index.ts (1)

206-237: ⚠️ Potential issue | 🔴 Critical

NewSessionHooksBridge retains reference to stale HooksNotificationsService instance.

The NewSessionHooksBridge is created at line 211 with the first hooksNotifications instance (which has placeholder dependencies returning null). When this.hooksNotifications is reassigned at lines 234-237 with real dependencies, the bridge still holds a reference to the old instance.

Events dispatched through newSessionHooksBridge (used by DeepChatAgentPresenter) will use the placeholder dependencies that always return null, causing session/message lookups to silently fail.

🐛 Proposed fix: Create bridge after final service instantiation or use a getter pattern

Option 1: Move bridge creation after final instantiation

    // Initialize new agent architecture presenters first (needed by hooksNotifications)
-   this.hooksNotifications = new HooksNotificationsService(this.configPresenter, {
-     getSession: async () => null,
-     getMessage: async () => null
-   })
-   const newSessionHooksBridge = new NewSessionHooksBridge(this.hooksNotifications)

    // Initialize new agent architecture presenters
    const deepchatAgentPresenter = new DeepChatAgentPresenter(
      this.llmproviderPresenter as unknown as ILlmProviderPresenter,
      this.configPresenter,
      this.sqlitePresenter as unknown as import('./sqlitePresenter').SQLitePresenter,
      this.toolPresenter,
-     newSessionHooksBridge
+     null // temporarily, will be set after hooksNotifications is ready
    )
    this.newAgentPresenter = new NewAgentPresenter(
      deepchatAgentPresenter,
      this.llmproviderPresenter as unknown as ILlmProviderPresenter,
      this.configPresenter,
      this.sqlitePresenter as unknown as import('./sqlitePresenter').SQLitePresenter,
      this.skillPresenter
    )
    // ... projectPresenter init ...

    // Update hooksNotifications with actual dependencies now that newAgentPresenter is ready
    this.hooksNotifications = new HooksNotificationsService(this.configPresenter, {
      getSession: this.newAgentPresenter.getSession.bind(this.newAgentPresenter),
      getMessage: this.newAgentPresenter.getMessage.bind(this.newAgentPresenter)
    })
+   const newSessionHooksBridge = new NewSessionHooksBridge(this.hooksNotifications)
+   deepchatAgentPresenter.setHooksBridge(newSessionHooksBridge)

Option 2: Use a dispatcher object with mutable reference

+   // Create a dispatcher that delegates to current hooksNotifications
+   const hooksDispatcher = {
+     dispatchEvent: (event: HookEventName, context: HookDispatchContext) => {
+       this.hooksNotifications.dispatchEvent(event, context)
+     }
+   }
-   const newSessionHooksBridge = new NewSessionHooksBridge(this.hooksNotifications)
+   const newSessionHooksBridge = new NewSessionHooksBridge(hooksDispatcher)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/presenter/index.ts` around lines 206 - 237, NewSessionHooksBridge is
constructed with an early HooksNotificationsService that has stubbed getters, so
move creation or switch to an indirection so the bridge sees the final service:
after you finish instantiating this.hooksNotifications with real dependencies
(the reassignment that binds this.newAgentPresenter.getSession/getMessage),
create the NewSessionHooksBridge and pass it into DeepChatAgentPresenter and
NewAgentPresenter (or alternatively make NewSessionHooksBridge accept a mutable
provider/getter that looks up this.hooksNotifications at call time), ensuring
DeepChatAgentPresenter uses the bridge tied to the final
HooksNotificationsService.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/main/presenter/browser/YoBrowserPresenter.ts`:
- Around line 585-590: Replace the direct fire-and-forget call to
state.page.contents.loadURL in YoBrowserPresenter (around the block using
state.page.contents.loadURL) with the same guarded navigation flow used by
BrowserTab.ts's page.navigate (or call that method directly): ensure you set
page.status to Loading, call the waitForLoad timeout/handling logic, capture and
set Ready or Error and extract the page title after load, handle and log errors,
and only update state.updatedAt after the load completion/status update so
downstream code won't race on an in-progress load.

In `@src/renderer/src/i18n/da-DK/chat.json`:
- Line 22: The placeholder value currently uses the literal "{'@'}" which will
display those braces instead of the @ character; update the "placeholder" entry
in the chat locale (the "placeholder" key in chat.json) to use a bare "@"
character (i.e., replace "{'@'}" with "@") so the UI renders the mention
character correctly.

In `@src/renderer/src/i18n/en-US/chat.json`:
- Line 3: The placeholder string currently contains the literal sequence "{'@'}"
which renders verbatim; update the "placeholder" value in chat.json to use the
plain @ character (e.g., "Ask DeepChat anything, @ to mention files, / for
commands") so TipTap's Placeholder extension shows @ correctly; locate the
"placeholder" key in the chat.json locale entry and replace the curly-braced
token with a simple @ character (also apply the same change to other locale
files with the same pattern).

In `@src/renderer/src/i18n/fa-IR/chat.json`:
- Line 3: The placeholder translation currently contains the literal
interpolation syntax "{'@'}" which is rendered verbatim by the TipTap
placeholder (see ChatInputBox.vue which uses t('chat.input.placeholder') and CSS
content: attr(data-placeholder)); update the translation value for the key
chat.input.placeholder to use a plain "@" character (replace "{'@'}" with "@")
so the placeholder displays the @ symbol correctly when rendered by the
Placeholder extension.

In `@src/renderer/src/i18n/fr-FR/chat.json`:
- Line 3: The "placeholder" value in chat.json contains the literal sequence
"{'@'}" which renders as text instead of the intended @ character; update the
"placeholder" string used by the i18n key "placeholder" (in the chat.json locale
entry) to use a bare "@" character (replace "{'@'}" with "@") so the UI displays
the mention symbol correctly.

In `@src/renderer/src/i18n/ru-RU/chat.json`:
- Line 3: The placeholder string for the "placeholder" key in chat.json uses the
literal "{'@'}" which renders as those characters instead of the @ symbol;
update the value for "placeholder" in src/renderer/src/i18n/ru-RU/chat.json (the
"placeholder" entry) to use a bare "@" character where needed (remove the braces
and quotes around @) so the UI shows the actual @ symbol.

---

Outside diff comments:
In `@src/main/presenter/index.ts`:
- Around line 206-237: NewSessionHooksBridge is constructed with an early
HooksNotificationsService that has stubbed getters, so move creation or switch
to an indirection so the bridge sees the final service: after you finish
instantiating this.hooksNotifications with real dependencies (the reassignment
that binds this.newAgentPresenter.getSession/getMessage), create the
NewSessionHooksBridge and pass it into DeepChatAgentPresenter and
NewAgentPresenter (or alternatively make NewSessionHooksBridge accept a mutable
provider/getter that looks up this.hooksNotifications at call time), ensuring
DeepChatAgentPresenter uses the bridge tied to the final
HooksNotificationsService.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 060aa211-fe94-425e-930d-94508ea33e6f

📥 Commits

Reviewing files that changed from the base of the PR and between 33efa3d and f463516.

📒 Files selected for processing (48)
  • CHANGELOG.md
  • GAP_ANALYSIS_SUMMARY.md
  • P0_DESIGN_DECISIONS.md
  • P0_IMPLEMENTATION_SUMMARY.md
  • docs/ARCHITECTURE.md
  • docs/FLOWS.md
  • docs/architecture/agent-system.md
  • docs/architecture/new-ui-implementation-plan.md
  • docs/specs/p0-implementation/README.md
  • docs/specs/p0-implementation/feature-01-generating-session-ids/plan.md
  • docs/specs/p0-implementation/feature-01-generating-session-ids/spec.md
  • docs/specs/p0-implementation/feature-01-generating-session-ids/tasks.md
  • docs/specs/p0-implementation/feature-02-input-disable-stop/plan.md
  • docs/specs/p0-implementation/feature-02-input-disable-stop/spec.md
  • docs/specs/p0-implementation/feature-02-input-disable-stop/tasks.md
  • docs/specs/p0-implementation/feature-03-cancel-generating/plan.md
  • docs/specs/p0-implementation/feature-03-cancel-generating/spec.md
  • docs/specs/p0-implementation/feature-03-cancel-generating/tasks.md
  • docs/specs/p0-implementation/feature-04-permission-approval/plan.md
  • docs/specs/p0-implementation/feature-04-permission-approval/spec.md
  • docs/specs/p0-implementation/feature-04-permission-approval/tasks.md
  • docs/specs/p0-implementation/feature-05-session-list-refresh/plan.md
  • docs/specs/p0-implementation/feature-05-session-list-refresh/spec.md
  • docs/specs/p0-implementation/feature-05-session-list-refresh/tasks.md
  • docs/specs/p0-implementation/feature-06-optimistic-messages/plan.md
  • docs/specs/p0-implementation/feature-06-optimistic-messages/spec.md
  • docs/specs/p0-implementation/feature-06-optimistic-messages/tasks.md
  • docs/specs/p0-implementation/feature-07-cache-versioning/plan.md
  • docs/specs/p0-implementation/feature-07-cache-versioning/spec.md
  • docs/specs/p0-implementation/feature-07-cache-versioning/tasks.md
  • package.json
  • src/main/presenter/browser/YoBrowserPresenter.ts
  • src/main/presenter/hooksNotifications/index.ts
  • src/main/presenter/index.ts
  • src/main/presenter/newAgentPresenter/index.ts
  • src/renderer/src/i18n/da-DK/chat.json
  • src/renderer/src/i18n/en-US/chat.json
  • src/renderer/src/i18n/fa-IR/chat.json
  • src/renderer/src/i18n/fr-FR/chat.json
  • src/renderer/src/i18n/he-IL/chat.json
  • src/renderer/src/i18n/ja-JP/chat.json
  • src/renderer/src/i18n/ko-KR/chat.json
  • src/renderer/src/i18n/pt-BR/chat.json
  • src/renderer/src/i18n/ru-RU/chat.json
  • src/renderer/src/i18n/zh-CN/chat.json
  • src/renderer/src/i18n/zh-HK/chat.json
  • src/renderer/src/i18n/zh-TW/chat.json
  • src/renderer/src/stores/ui/session.ts
💤 Files with no reviewable changes (25)
  • docs/specs/p0-implementation/feature-04-permission-approval/tasks.md
  • docs/specs/p0-implementation/feature-02-input-disable-stop/plan.md
  • docs/specs/p0-implementation/feature-06-optimistic-messages/spec.md
  • docs/specs/p0-implementation/feature-05-session-list-refresh/spec.md
  • docs/specs/p0-implementation/feature-06-optimistic-messages/tasks.md
  • docs/specs/p0-implementation/feature-01-generating-session-ids/spec.md
  • docs/specs/p0-implementation/feature-06-optimistic-messages/plan.md
  • docs/specs/p0-implementation/feature-03-cancel-generating/tasks.md
  • docs/specs/p0-implementation/feature-05-session-list-refresh/tasks.md
  • P0_IMPLEMENTATION_SUMMARY.md
  • docs/specs/p0-implementation/feature-01-generating-session-ids/plan.md
  • docs/specs/p0-implementation/feature-04-permission-approval/spec.md
  • docs/specs/p0-implementation/feature-02-input-disable-stop/tasks.md
  • docs/specs/p0-implementation/feature-07-cache-versioning/spec.md
  • docs/specs/p0-implementation/feature-04-permission-approval/plan.md
  • docs/specs/p0-implementation/feature-07-cache-versioning/tasks.md
  • docs/specs/p0-implementation/feature-05-session-list-refresh/plan.md
  • docs/specs/p0-implementation/README.md
  • docs/specs/p0-implementation/feature-02-input-disable-stop/spec.md
  • docs/specs/p0-implementation/feature-03-cancel-generating/spec.md
  • GAP_ANALYSIS_SUMMARY.md
  • docs/specs/p0-implementation/feature-07-cache-versioning/plan.md
  • docs/specs/p0-implementation/feature-03-cancel-generating/plan.md
  • docs/specs/p0-implementation/feature-01-generating-session-ids/tasks.md
  • P0_DESIGN_DECISIONS.md

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
test/main/presenter/YoBrowserPresenter.test.ts (1)

21-27: Consider adding a clarifying comment for the auto-emit behavior.

The implementation correctly simulates the async load completion by using queueMicrotask, which aligns with the production code's Promise-based did-finish-load listener registration pattern. However, this "magic" auto-emit behavior could be surprising to future maintainers.

📝 Suggested documentation
   once = vi.fn((event: string, listener: (...args: any[]) => void) => {
     super.once(event, listener)
+    // Auto-emit did-finish-load to prevent tests from hanging when awaiting
+    // presenter methods that wait for page load completion
     if (event === 'did-finish-load') {
       queueMicrotask(() => this.emit('did-finish-load'))
     }
     return this
   })
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/main/presenter/YoBrowserPresenter.test.ts` around lines 21 - 27, Add a
short clarifying comment inside the overridden once implementation (the mocked
once function that checks for event === 'did-finish-load' and uses
queueMicrotask to emit) explaining that the queueMicrotask auto-emit simulates
the asynchronous load-complete behavior from production code (where
did-finish-load is listened for via a Promise), so future maintainers understand
this “magic” emit is intentional and required for the test timing semantics.
Mention the relation to the production listener pattern and why queueMicrotask
is used instead of an immediate emit.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@test/main/presenter/YoBrowserPresenter.test.ts`:
- Around line 21-27: Add a short clarifying comment inside the overridden once
implementation (the mocked once function that checks for event ===
'did-finish-load' and uses queueMicrotask to emit) explaining that the
queueMicrotask auto-emit simulates the asynchronous load-complete behavior from
production code (where did-finish-load is listened for via a Promise), so future
maintainers understand this “magic” emit is intentional and required for the
test timing semantics. Mention the relation to the production listener pattern
and why queueMicrotask is used instead of an immediate emit.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3cede3c9-c4c1-4aed-85c2-9216b0f6a7d8

📥 Commits

Reviewing files that changed from the base of the PR and between f463516 and 24444bb.

📒 Files selected for processing (2)
  • src/main/presenter/browser/YoBrowserPresenter.ts
  • test/main/presenter/YoBrowserPresenter.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/presenter/browser/YoBrowserPresenter.ts

@zerob13 zerob13 merged commit a44ead3 into dev Mar 9, 2026
2 checks passed
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.

1 participant