Skip to content

feat(macOS): 按 IDEA 风格优化项目与分支切换弹窗 - #350

Merged
1lck merged 26 commits into
previewfrom
codex/macos-switcher-popover-ui
Aug 30, 2026
Merged

feat(macOS): 按 IDEA 风格优化项目与分支切换弹窗#350
1lck merged 26 commits into
previewfrom
codex/macos-switcher-popover-ui

Conversation

@xiaoyumuxi

@xiaoyumuxixiaoyumuxi commented Aug 30, 2026

Copy link
Copy Markdown
Collaborator

改动摘要

  • 压缩并左对齐项目与分支切换弹窗,同时保持“项目在前、分支在后”的顶部控件顺序
  • 取消切换弹窗的出现动画,统一首帧尺寸与圆角外观,避免打开时发生布局跳变
  • 按 IDEA 的层级方式整理最近、本地和远程分支,本地命名空间及远程仓库默认折叠
  • 在不修改 Git 核心逻辑的前提下,将提交与推送入口分离,并调整 Update/Push 对话框的普通 UI
  • 为最近分支增加 Rust Core 协议字段、共享 fixture 及 macOS/Windows 适配

影响范围

  • macOS SwiftUI 展示层
  • Rust Core 的 git.history 响应及共享协议 fixture
  • macOS/Windows Git history 适配层

本次修复

  • 恢复 Update 对话框中的 upstream、ahead/behind 信息
  • dirty working tree 时提示 Rebase 需要先提交或 stash
  • 移除没有实际行为的帮助按钮
  • Push 对话框明确区分 tracking branch 与 Core 自动选择默认 remote

验证

  • ./scripts/verify-service-boundaries.sh:通过
  • git diff --check:通过
  • Swift 聚焦测试 GitPushDialogPresentationTests:2 个测试通过
  • Swift 增量构建:通过

@xiaoyumuxi
xiaoyumuxi requested a review from 1lck as a code ownerAugust 30, 2026 07:42
@xiaoyumuxixiaoyumuxi changed the title feat(macos): align switcher popovers with IDEA workflowfeat(macOS): 按 IDEA 风格优化项目与分支切换弹窗Aug 30, 2026
@xiaoyumuxi

xiaoyumuxi commented Aug 30, 2026

Copy link
Copy Markdown
CollaboratorAuthor
imageimage
参考对比图

@xiaoyumuxi

xiaoyumuxi commented Aug 30, 2026

Copy link
Copy Markdown
CollaboratorAuthor

此外还将原来项目管理器的弹出动画跟 git 部分的动画全部删了,影响效率而且 IDEA 就是没有动画的,技术方面采用自定义的 SwiftUI 为了进行对标 IDEA
image
image
来进行视觉上的统一效果

@xiaoyumuxi

Copy link
Copy Markdown
CollaboratorAuthor

@lithe review

@github-actions

github-actionsBot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Lithe Review

结论: ❓ 审查未完成

审查状态:failure
请查看本次 Actions 日志与诊断附件后重新召唤。

1lck
1lck previously requested changes Aug 30, 2026

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

整体视觉方向和自定义弹层的接入方式可以理解,编译、macOS 全量测试和服务边界检查也都通过。不过当前新 UI 引入了一个会阻断首次发布分支的回归,以及三个对用户承诺了行为但没有真正实现的状态,因此这轮先 Request changes。

最需要先修的是无 upstream 分支的 Push:Core 已经支持自动选择远端并设置 upstream,UI 不应提前禁用。其余请将 Push tags / Don’t show 真正接入操作与持久化,或暂时移除;Recent 区域也需要真实的最近分支来源,不能直接取按 refname 排序的前两项。建议为首次 push 和这些对话框选项补最小的行为测试。

验证:./scripts/verify-service-boundaries.sh 通过;./scripts/test-macos.sh 通过(79 suites,692 tests);git diff --check 通过。

.tint(LitheTheme.accent)
.keyboardShortcut(.defaultAction)
.lithePointer()
.disabled(reference.upstreamShortName == nil)

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.

[P1] 不要阻断尚未配置 upstream 的首次 Push。这里把 upstreamShortName == nil 的本地分支直接禁用了,但现有 Rust Core 的 push 会在没有 tracking branch 时选择 origin(或首个 remote)并执行 git push --set-upstream;本 PR 之前顶部入口也会直接调用这条路径。现在用户新建本地分支后无法从顶部 Push 弹窗发布它。请保持按钮可用并展示首次发布的目标远端,或提供等价的 publish 流程。

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

新建分支自动继承 upstream 么?我想想,因为我觉得推送是比较谨慎的操作是需要不能自动继承的

.lithePointer()
.help("Review the branch that will be pushed")

Toggle("Push tags", isOn: $pushTags)

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.

[P2] Push tags 目前只是切换本地 @State。确认按钮仍只调用无参数的 onPush(),最终执行普通 model.pushBranch(reference),所以用户勾选后标签不会被推送。请把该选项贯通到 Git 操作契约/Core,或者在支持前移除这个复选框,避免产生错误确认。

.lithePointer()
Button("Merge") { resolve(.merge) }
.buttonStyle(.borderedProminent)
Toggle("Don't show", isOn: $doNotShowAgain)

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.

[P2] Don’t show 的值没有被读取、持久化,也不会影响下一次 pendingPullStrategy 的展示;勾选后按 OK,后续分叉仍会弹出同一窗口。请接入明确的默认策略设置和持久化逻辑,或先移除这个无效选项。


private var recentReferences: [GitReference] {
guard normalizedQuery.isEmpty else { return [] }
return Array(model.gitReferences.prefix(2))

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.

[P2] 这里展示的并不是最近分支。gitReferences 来自 Core 的 git for-each-ref --sort=refname,因此 prefix(2) 只会取按引用名排序的前两项,可能连当前分支都不包含,却被标成 Recent。需要记录/计算真实的 checkout recency(至少确保当前分支并按最近使用排序),否则请改成不会暗示时序的分组。

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

这个有道理确实应该修改

@1lck

1lck commented Aug 30, 2026

Copy link
Copy Markdown
Owner

已将修复推送到远程分支,commit 541d074e。本次恢复了 Update 对话框的 upstream 与 ahead/behind 信息,并在有未提交改动时提示 Rebase 需要先提交或 stash;移除了两个无实际行为的帮助按钮;Push 对话框明确区分 tracking branch 与 Core 自动选择的默认 remote。已通过服务边界检查、diff check、Swift 增量构建,以及 GitPushDialogPresentationTests(2 tests)。

@1lck

1lck commented Aug 30, 2026

Copy link
Copy Markdown
Owner

完整审查已完成,当前结论:代码层面可以进入合入确认,但我没有执行 merge。

已复核:

  • SwiftUI 项目/分支切换弹窗的状态管理、分组与搜索渲染、弹层定位
  • Update/Push 对话框展示内容与 Git Core 实际行为的一致性
  • recentReferences 跨 Rust Core、共享 fixture、macOS bridge/model、Windows adapter/types/tests 的协议链路
  • 服务边界、共享契约、Rust Core 注释与格式、Git graph、Windows boundary

本地验证:

  • macOS 全量测试:752 tests / 84 suites passed
  • Rust Core:287 unit tests + 5 git watch tests + doc tests passed
  • verify-service-boundaries / verify-shared-contracts / verify-rust-core-comments / verify-core / verify-git-graph / verify-windows-boundaries:passed
  • cargo fmt --check、git diff --check、Swift 增量构建:passed

剩余验证边界:Windows Bun 前端测试在当前 macOS worktree 无法完整运行,原因是 windows/tauri 依赖未安装;GitHub Actions 中 Windows 与 release package checks 仍处于 pending,合入前请等待它们完成。

@1lck
1lck dismissed their stale reviewAugust 30, 2026 15:14

修复已完成并通过完整验证,撤销此前基于旧提交的 changes requested 状态。

@1lck
1lck merged commit d0c26dc into previewAug 30, 2026
15 checks passed
Sign up for freeto 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

@xiaoyumuxi@1lck