Skip to content

feat(notch): coexist with other notch apps (yield notch when idle) - #283

Open
Kelei0215 wants to merge 2 commits into
erha19:mainfrom
Kelei0215:feat/notch-coexist
Open

feat(notch): coexist with other notch apps (yield notch when idle)#283
Kelei0215 wants to merge 2 commits into
erha19:mainfrom
Kelei0215:feat/notch-coexist

Conversation

@Kelei0215

Copy link
Copy Markdown

Problem

Ping Island 的 docked 刘海窗口层级是 .mainMenu + 3,且空闲时一悬停就自动展开
(mouseMovedhoverTimer.hover open)。当同时装了第二个刘海工具
(如 NotchNest)时,两者抢同一块刘海:Ping Island 闭合时仍视觉遮挡对方,
光标一进刘海就抢走 hover/click。

范围说明:双屏用户可把 Ping Island 的刘海目标切到扩展屏(既有 Display 设置)回避冲突;
本开关给单屏用户(或不能/不愿挪到扩展屏)兜底——没有第二块屏可挪时,
让 Ping Island 空闲时主动让出刘海,只在 Agent 需要 attention 时接管。

Approach

新增一个设置开关 "Coexist with other notch apps"(默认 ,行为不变)。
开启后,Ping Island 空闲时让出刘海,只在真实 attention 时接管:

  • 抑制 hover-wake:不再起悬停自动展开定时器
  • 抑制闭合态刘海点击展开
  • 闭合态 orderOrder 撤掉窗口,不再视觉遮挡下层刘海应用

真实 attention(审批 / 追问 / 通知)照常接管刘海,处理完再隐藏。

这与现有 "attention-first" 哲学一脉相承——是输入层对现有"视觉空闲收缩"的对应。

Why not merge features

有意不加音乐/剪贴板等功能——那些属于通用刘海工具;此 PR 目标是与之干净共存,而非替代。

Files

  • Settings.swift: 新增 coexistWithOtherNotchApps 开关(key + @published + 默认值 + AppSettings 门面)
  • NotchViewModel.swift: 门控 hover-wake / click-open / shouldHideWindowPresentation
  • SettingsWindowView.swift: 开关 UI

Test plan

  • 默认关:行为与之前完全一致
  • 开启后悬停刘海:Ping Island 不展开,另一个刘海应用正常展开
  • 开启后触发审批/追问:Ping Island 仍接管刘海
  • 处理完:窗口再次隐藏,刘海交回另一个应用

Xcode 26.2 / Swift 6.2 编译通过(CODE_SIGN_IDENTITY=-)。

@erha19 erha19 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

[HIGH] PingIsland/Core/NotchViewModel.swift:587-647
The new coexistence guard only blocks the direct click-open branch at line 589, but a normal click inside detachmentTriggerScreenRect still starts closed-state detachment tracking at lines 587-588 and then reopens the notch on mouseUp at lines 643-647. Because detachmentTriggerScreenRect == closedScreenRect, closed-notch clicks still reopen Ping Island in coexistence mode, which breaks the promised “停止点击展开 / 交给其他刘海工具”. Please gate the closed-state detachment tap path as well, or disable closed detachment tracking while coexistence mode is active and the docked window is yielded.

[MEDIUM] PingIsland/Core/NotchViewModel.swift:377-403, PingIsland/UI/Window/NotchWindowController.swift:59-137
shouldHideWindowPresentation now depends on AppSettings.coexistWithOtherNotchApps, but NotchViewModel never subscribes to $coexistWithOtherNotchApps, and the window controller only refreshes presentation when one of the view-model publishers fires. Toggling the new setting while the notch is closed will therefore not immediately orderOut or restore the docked window until some unrelated state change happens. That means the advertised “开启后空闲时让出刘海” behavior is not reliably applied at toggle time. Please add a settings subscription that triggers a presentation refresh and cover it with a regression test.

@erha19

erha19 commented Aug 21, 2026

Copy link
Copy Markdown
Owner

补充一个与当前 main 集成相关的问题:本分支早于最近的 Settings 本地化改动。SettingsToggleLine 会把 title/subtitle 当作本地化 key,但新增的“与其他刘海应用共存”和说明文案没有加入 PingIsland/Resources/en.lproj/Localizable.stringszh-Hans.lproj/Localizable.strings。合并后 English 设置页会回退显示中文,请一并补齐两个 locale 的条目。

另外建议为这次新行为补回归测试,至少覆盖:共存开启时关闭态 click/long-press 不打开或分离、attention 仍能打开、运行中开关会立即 orderOut/orderFront。现有 NotchViewModelTests 在 PR 头能通过,但没有覆盖这些新路径,因此没有捕获上面两处行为问题。

Fred X and others added 2 commits August 21, 2026 12:03
Add a Settings toggle (default off) that lets Ping Island yield the
notch to other notch utilities (e.g. NotchNest) while idle, so two
notch apps can coexist instead of fighting over hover/click:

- Suppress hover-wake: do not start the auto-expand hover timer while
  coexistence is on, so hovering the notch no longer greedily opens
  Ping Island.
- Suppress click-to-open on the closed notch while coexistence is on,
  so notch clicks reach the other app.
- Fully hide (orderOut) the docked notch window when closed, so it no
  longer visually occludes other notch apps sitting below it at
  level .mainMenu + 3.

Real attention events (approvals, follow-ups, notifications) still
take over the notch as usual; once handled the window hides again and
the notch returns to the other app.

Default is off, so existing behavior is unchanged.

Co-Authored-By: Claude <noreply@anthropic.com>
- Add en.lproj/zh-Hans.lproj Localizable.strings entries for the coexist
  toggle title and subtitle. SettingsToggleLine resolves these via
  appLocalized, so the English settings page no longer falls back to the
  raw Chinese key text.
- Add NotchViewModelTests covering: coexist hides the closed notch but
  still surfaces attention; default-off keeps existing presentation; and
  toggling at runtime flips shouldHideWindowPresentation immediately
  (which drives orderOut/orderFront in the controller).
- Guard performDeferredHoverOpenIfNeeded with the coexist flag too, so
  hover-open is suppressed at the function level rather than only at the
  hover-timer scheduling site — more robust and encodes the intent.

Co-Authored-By: Claude <noreply@anthropic.com>
@Kelei0215

Copy link
Copy Markdown
Author

目前根据建议和要求做了修改和完善,辛苦可以再 review 看看。诚实的说一下,这次 PR 提交,我仅仅作为工具问题发现者(单屏使用中的很小的问题,可能不影响大部分人),代码部分全部由 AI 辅助完成。

@erha19

erha19 commented Aug 24, 2026

Copy link
Copy Markdown
Owner

LGTM

@erha19

erha19 commented Aug 24, 2026

Copy link
Copy Markdown
Owner

@Kelei0215 有一些类型报错,麻烦处理一下,基本逻辑没问题

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