Skip to content

fix: macOS app foreground identity#1733

Merged
zerob13 merged 2 commits into
devfrom
fix-mac-menu
Jun 3, 2026
Merged

fix: macOS app foreground identity#1733
zerob13 merged 2 commits into
devfrom
fix-mac-menu

Conversation

@zhangmo8
Copy link
Copy Markdown
Collaborator

@zhangmo8 zhangmo8 commented Jun 3, 2026

Summary

Fix the macOS app identity path so DeepChat becomes the active foreground app instead of leaving the menu bar attached to the previously focused application.

What changed

  • set the app name during startup
  • add a shared macOS activation helper that forces regular activation policy and Dock identity
  • reuse that helper across startup, splash, main window, settings window, and Dock activation paths
  • add SDD notes for the issue scope and validation plan

Validation

  • pnpm run typecheck:node
  • pnpm run format
  • pnpm run i18n
  • pnpm run lint
  • pre-commit hook also ran pnpm run typecheck

Summary by CodeRabbit

  • New Features

    • macOS app now correctly displays "DeepChat" in the menu bar when active and appears in the Dock.
  • Documentation

    • Added implementation plan, specification, and task checklist for the macOS app name identity feature.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 3, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This PR implements macOS app name identity for DeepChat by setting the Electron application name to "DeepChat" at startup and wiring platform-specific activation helpers throughout the main-process startup and window presentation lifecycle to establish correct Dock identity and ensure app activation before windows take focus.

Changes

macOS App Name Identity Implementation

Layer / File(s) Summary
Feature Specification and Implementation Plan
docs/issues/mac-app-name-identity/spec.md, docs/issues/mac-app-name-identity/plan.md, docs/issues/mac-app-name-identity/tasks.md
Spec documents the macOS app identity goal, acceptance criteria, and non-goals (no icon/bundle/signing, no UI changes, Windows/Linux unchanged). Plan outlines implementation steps and validation checklist. Tasks markdown tracks completion status.
Core macOS Activation Helpers
src/main/lib/activateApp.ts
ensureRegularAppOnMac sets Electron activation policy to regular and shows the dock on macOS only; activateAppOnMac wraps that helper and calls app.focus({ steal: true }) to bring the app to foreground. Both guard on process.platform === 'darwin' to avoid side effects on other platforms.
Main Process Startup and App Naming
src/main/appMain.ts
startApp() now sets app name to "DeepChat" via app.setName() and calls ensureRegularAppOnMac() immediately (if ready) or via ready event. app.whenReady() initialization begins with an additional ensureRegularAppOnMac() call. When focusing an existing window, activateAppOnMac() is called after showing the target.
Window Lifecycle and Focus Integration
src/main/presenter/lifecyclePresenter/SplashWindowManager.ts, src/main/presenter/lifecyclePresenter/hooks/ready/eventListenerSetupHook.ts, src/main/presenter/windowPresenter/index.ts
activateAppOnMac() is wired into five focus/visibility transitions: splash window display, app activation events, window show() with focus, sendToDefaultWindow() target switch, createManagedWindow() ready-to-show, existing settings window display, and focusMainWindow().

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • ThinkInAIXYZ/deepchat#1370: Both PRs modify SplashWindowManager splash-window show flow, adding macOS activation calls to existing window presentation.
  • ThinkInAIXYZ/deepchat#675: Both PRs modify macOS window focus behavior in WindowPresenter by injecting calls at similar focus/visibility control points.

Suggested reviewers

  • zerob13

🐰 A rabbit hops by with pure delight,
"macOS now knows just who's in sight—
DeepChat stands tall in the Dock's embrace,
With identity worn on its beaming face!" 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

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.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
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.
Title check ✅ Passed The PR title 'fix: macOS app foreground identity' directly and clearly summarizes the main change—fixing the macOS app's foreground identity so the menu bar attaches to DeepChat correctly.

✏️ 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 fix-mac-menu

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.

Copy link
Copy Markdown
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)
src/main/appMain.ts (1)

174-174: 💤 Low value

Redundant call to ensureRegularAppOnMac.

This call duplicates the earlier invocation in lines 28-36, which already ensures the function runs when the app becomes ready. Since ensureRegularAppOnMac is idempotent, this redundancy is safe but unnecessary.

♻️ Remove redundant call
   app.whenReady().then(async () => {
-    ensureRegularAppOnMac()
     // Set app user model id for windows
🤖 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/main/appMain.ts` at line 174, Remove the redundant invocation of
ensureRegularAppOnMac by deleting the extra call currently located near the app
startup sequence; keep the original ensureRegularAppOnMac invocation that runs
when the app becomes ready (the earlier call that ensures idempotent behavior)
and remove the duplicate to avoid unnecessary repetition while preserving the
existing initialization flow.
🤖 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/main/appMain.ts`:
- Line 174: Remove the redundant invocation of ensureRegularAppOnMac by deleting
the extra call currently located near the app startup sequence; keep the
original ensureRegularAppOnMac invocation that runs when the app becomes ready
(the earlier call that ensures idempotent behavior) and remove the duplicate to
avoid unnecessary repetition while preserving the existing initialization flow.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a79aa7c2-5e41-4465-83c1-0d19fbccad18

📥 Commits

Reviewing files that changed from the base of the PR and between 9d5f0db and 04634c6.

📒 Files selected for processing (8)
  • docs/issues/mac-app-name-identity/plan.md
  • docs/issues/mac-app-name-identity/spec.md
  • docs/issues/mac-app-name-identity/tasks.md
  • src/main/appMain.ts
  • src/main/lib/activateApp.ts
  • src/main/presenter/lifecyclePresenter/SplashWindowManager.ts
  • src/main/presenter/lifecyclePresenter/hooks/ready/eventListenerSetupHook.ts
  • src/main/presenter/windowPresenter/index.ts

@zerob13 zerob13 changed the title Fix macOS app foreground identity fix: macOS app foreground identity Jun 3, 2026
@zerob13 zerob13 merged commit c59e32d into dev Jun 3, 2026
3 checks passed
@zhangmo8 zhangmo8 deleted the fix-mac-menu branch June 4, 2026 00:26
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.

2 participants