diff --git a/.agents/notes/implemented/bug-fix/2026-11-20-primary-click-selection.md b/.agents/notes/implemented/bug-fix/2026-11-20-primary-click-selection.md new file mode 100644 index 000000000..906d24d46 --- /dev/null +++ b/.agents/notes/implemented/bug-fix/2026-11-20-primary-click-selection.md @@ -0,0 +1,44 @@ +# Agent 笔记:主修饰键追加选择保留原行并显示全部选中项 + +状态:已实现 + +## 先说结论 + +在项目文件树和 Git 分支列表中,先普通点击 A,再按 macOS Command 或 Windows Control 点击 B,A 和 B 都保留选中;再次修饰键点击某行只取消该行。Core 统一维护选择规则,界面显示所有已选行,指针移入的焦点不能提前覆盖原选择。 + +## 问题 + +Core 的第一次 toggle(增减一行选择)只把点击目标加入标记,丢掉普通点击已经选中的行。文件树的行描述只把当前行设为选中,没有呈现批量标记。指针按下带来的焦点又会在处理带修饰键的点击前更新当前行,导致即使 Core 修正,原行仍可能丢失。 + +相关代码源于 Viva 迁移提交 `0faecba491`(宿主 #1799)及 Core 选择规则提交 `62b8a08`(Core #31);这与旧客户端的 #1050 不同,当前问题可在共享 Viva 无头鼠标流程中复现。 + +## 决策 + +- 没有批量标记和范围锚点时,Core 先把可见的、非根的当前行纳入,再切换点击行。已有批量继续只切换一行;隐藏旧行不因首次点击被意外加入。 +- 文件树与 Git 分支列表有批量状态时只用批量标记呈现选中底色;取消选中的当前行不继续显示为已选。 +- 文件树记录已观察的焦点,指针焦点先交给点击处理,键盘焦点仍更新当前行。窗口失焦和恢复不清除批量。 +- macOS Command 和 Windows Control 由 Viva 已有的主修饰键定义提供,不新增系统按键适配。 + +## 考虑过的备选方案 + +- 只补选中底色:原始选择仍丢失,批量操作目标继续不符合预期。 +- 在每个界面各自补回旧选中项:会让文件树、Git 列表与其他 Core 消费者产生不同规则。 +- 把任何焦点都直接当作选中:指针按下会先替换旧行,无法正确追加选择。 + +## 后果 + +追加多选符合平台习惯,取消选择可见,Core fixture 约束所有消费者。代价是 Core 与宿主需要同步升级,并保留一个局部焦点身份以区分指针和键盘变化。 + +## 验证 + +- Core 共享 row-selection fixture 修改后先红后绿,覆盖首次追加保留、点击当前行取消、隐藏标记、范围选择和根保护。 +- `desktop/internal/workbench/filetree_test.go` 的真实驱动点击先复现旧选择丢失,修复后覆盖追加、取消、全部选中底色、普通点击清除及键盘焦点回归。 +- `desktop/internal/workbench/branch_delete_test.go` 混合批量从普通点击开始,再用平台主修饰键追加,验证实际删除集合。 +- 通过 `scripts/desktop/desktop-go.sh` 执行定向无头测试,`desktop/internal/workbench/branch_delete_visual_test.go` 生成中英文明暗主题的文件树多选截图。Windows 原生交互验证仍待目标平台执行。 + +## 适用范围 + +- `desktop/internal/workbench/filetree.go` +- `desktop/internal/workbench/filetree_view.go` +- `desktop/internal/workbench/gitlog_view.go` +- 外部 Lithe-core-rust 的 `rust/crates/row-selection/src/lib.rs` 与共享 fixture。 diff --git a/.agents/notes/implemented/feature/2026-11-20-git-force-delete-confirmation.md b/.agents/notes/implemented/feature/2026-11-20-git-force-delete-confirmation.md new file mode 100644 index 000000000..1919d4303 --- /dev/null +++ b/.agents/notes/implemented/feature/2026-11-20-git-force-delete-confirmation.md @@ -0,0 +1,46 @@ +# Agent 笔记:未合并分支的强制删除必须二次确认 + +状态:已实现 + +## 先说结论 + +普通删除继续保护尚未合并的本地分支。用户先点击“强制删除…”查看警告,再点击独立弹窗中的“确认强制删除”才执行;取消、关闭和初始焦点下的 Enter 都保留分支。Rust Core 负责合并检查和提交身份校验,桌面端只呈现结构化结果与确认步骤。 + +## 问题 + +备份分支可能保留已改写的旧提交,普通删除会返回“尚未完全合并”,用户却没有可继续的入口。原有确认文案声称未合并分支也会删除,与 Core 的保护行为不符。 + +## 决策 + +- 普通删除失败后,只对 Core 明确报告尚未合并的分支提供强制入口,不匹配英文诊断。批量操作只把这些失败项带入二次确认,成功项与其他错误不重试。 +- 混合批量结果保留原始选择的每项状态,失败分支名标红并可悬停查看原因。成功项不再重试,其他失败不进入强制确认;强制阶段的结果更新原列表,不能掩盖先前的远程失败。 +- 独立确认弹窗展示目标列表与提交可能失去分支引用的警告,初始焦点为取消。“强制删除…”只打开弹窗,不发送写请求。 +- 提交身份以完整对象 ID(Git 为提交计算的标识)固定。Core 在第一次拒绝时返回身份,强制请求必须携带该身份;分支变化后旧确认失效,用户重新开始删除。 +- 强制仅跳过合并检查。当前分支和任何工作树中已检出的分支仍不能删除;实际删除继续使用带预期对象 ID 的原子引用操作,拒绝并发更新。 +- 确认绑定原仓库。关闭或替换弹窗、切换仓库后,旧操作结果不得改变新弹窗。 + +正确示例:普通删除备份分支被拒绝后,查看警告并再次确认,按已审阅提交删除。不要在捕获任意 Git 失败后自动加 force 重试,这会跳过用户确认并误解释工作树占用等其他错误。 + +## 考虑过的备选方案 + +- 所有本地删除直接强制执行:放弃普通删除的合并保护,也无法体现本次明确要求的二次确认。 +- 在失败通知里点击一次就强制删除:用户还未单独确认数据后果,因此未采用。 +- 桌面端识别 `not fully merged` 文本:诊断可能翻译或变化,因此采用 Core 稳定错误码与结构化参数。 + +## 后果 + +用户能明确删除保留旧历史的备份分支,同时普通删除与工作树保护不变。操作多一步确认,Core 和宿主需同步升级;旧 Core 只返回通用失败时不提供强制入口。 + +## 验证 + +- Core 的真实 Git 回归覆盖普通拒绝、显式 force、缺少或非法预期身份、身份变化、当前分支、工作树占用与恢复目标。 +- `desktop/internal/workbench/branch_delete_test.go` 覆盖二次确认前不删除、Enter 默认取消、确认成功、批量只重试未合并项、确认后目标变化、已删除项同名重建不受重试影响,以及远程失败与未合并混合的逐项结果。 +- `desktop/internal/workbench/branch_delete_visual_test.go` 采集未合并提示和独立确认的中英文、明暗主题截图。 +- 用 `scripts/desktop/desktop-go.sh` 链接本地 Core 执行上述定向测试;原生平台交互仍需独立验收。 + +## 适用范围 + +- `desktop/internal/core/gitbranch.go` +- `desktop/internal/workbench/branch_delete.go` +- `shared/i18n/features/branch-delete.json` +- 外部 Lithe-core-rust 仓库的 `rust/crates/git/src/branches.rs` 与 `rust/contracts/rust-core-api.md`。 diff --git a/desktop/internal/core/errors.go b/desktop/internal/core/errors.go index 84930c874..84ebab0d0 100644 --- a/desktop/internal/core/errors.go +++ b/desktop/internal/core/errors.go @@ -28,6 +28,10 @@ const ( CodeProcessFailed ErrorCode = "process_failed" // CodeGitBranchExists means a reviewed checkout would conflict with a local reference. CodeGitBranchExists ErrorCode = "git_branch_exists" + // CodeGitBranchNotMerged means ordinary deletion needs an explicit forced confirmation. + CodeGitBranchNotMerged ErrorCode = "git_branch_not_merged" + // CodeGitBranchChanged means the branch moved after its deletion was reviewed. + CodeGitBranchChanged ErrorCode = "git_branch_changed" // CodeGitCheckoutChanged means a reviewed checkout no longer matches the repository. CodeGitCheckoutChanged ErrorCode = "git_checkout_changed" // CodeGitAuthenticationFailed means a git.write operation failed because the remote diff --git a/desktop/internal/core/gitbranch.go b/desktop/internal/core/gitbranch.go index 6b658e084..8f4a490b1 100644 --- a/desktop/internal/core/gitbranch.go +++ b/desktop/internal/core/gitbranch.go @@ -1,6 +1,10 @@ package core -import "context" +import ( + "context" + "encoding/json" + "errors" +) // gitReferenceRequest is the complete identity of a reference the kernel acts on. The kernel // checks all three fields against the repository before it runs Git. @@ -149,18 +153,49 @@ type GitBranchDeletion struct { DeletedTarget string `json:"deletedTarget"` } -// GitDeleteBranch deletes the local branch from the repository at root, even when its commits -// are not merged anywhere, and returns what it was. The current branch is refused with -// CodeInvalidRequest. +// GitBranchDeleteReview is Core's snapshot of a branch refused by ordinary deletion. +type GitBranchDeleteReview struct { + Name string `json:"name"` + ExpectedTarget string `json:"expectedTarget"` +} + +// BranchDeleteReview decodes Core's structured unmerged-branch diagnostic. Other failures +// never offer force; no localized Git output is interpreted here. +func BranchDeleteReview(err error) (GitBranchDeleteReview, bool) { + var failure *Error + var review GitBranchDeleteReview + if !errors.As(err, &failure) || failure.Code != CodeGitBranchNotMerged { + return review, false + } + if json.Unmarshal([]byte(failure.Details), &review) != nil { + return GitBranchDeleteReview{}, false + } + return review, review.Name != "" && review.ExpectedTarget != "" +} + +// GitDeleteBranch safely deletes a merged local branch and returns what it was. An unmerged +// branch returns CodeGitBranchNotMerged and a BranchDeleteReview for a separately confirmed +// force retry. Current and worktree-occupied branches remain protected. // // GitDeleteBranch starts git and blocks; call it from a background goroutine. func (c *Client) GitDeleteBranch(ctx context.Context, root string, branch GitReference) (GitBranchDeletion, error) { - response, err := c.gitWriteAnswer(ctx, gitWriteRequest{Root: root, Operation: "deleteBranch", GitReference: branch.request()}) + return c.deleteBranch(ctx, gitWriteRequest{Root: root, Operation: "deleteBranch", GitReference: branch.request()}) +} + +// GitForceDeleteBranch deletes only the reviewed branch tip, bypassing the merge check after +// explicit destructive confirmation. A changed target or checked-out branch is refused. +// It starts Git and blocks; call it from a background goroutine. +func (c *Client) GitForceDeleteBranch(ctx context.Context, root string, branch GitReference, expectedTarget string) (GitBranchDeletion, error) { + return c.deleteBranch(ctx, gitWriteRequest{Root: root, Operation: "deleteBranch", GitReference: branch.request(), Force: true, ExpectedTarget: expectedTarget}) +} + +func (c *Client) deleteBranch(ctx context.Context, request gitWriteRequest) (GitBranchDeletion, error) { + response, err := c.gitWriteAnswer(ctx, request) if err != nil { return GitBranchDeletion{}, err } if response.BranchDeletion == nil { - return GitBranchDeletion{Name: branch.ShortName}, nil + return GitBranchDeletion{Name: request.GitReference.ShortName}, nil } return *response.BranchDeletion, nil } diff --git a/desktop/internal/core/gitbranch_test.go b/desktop/internal/core/gitbranch_test.go index 2754b4325..1f2244757 100644 --- a/desktop/internal/core/gitbranch_test.go +++ b/desktop/internal/core/gitbranch_test.go @@ -1,9 +1,13 @@ package core import ( + "encoding/json" + "os" "path/filepath" "slices" "testing" + + "github.com/1lck/Lithe-IDEA/desktop/internal/contractfixture" ) // committedRepository is a repository on main with one commit of base.txt. @@ -80,6 +84,38 @@ func TestBranchCreateCheckoutRenameAndDelete(t *testing.T) { } } +func TestBranchForceDeleteReviewAndExpectedTarget(t *testing.T) { + repo := committedRepository(t) + client, ctx := NewClient(), testContext(t) + runGit(t, repo, "switch", "-c", "backup/unmerged") + runGit(t, repo, "commit", "--allow-empty", "-m", "unmerged") + target := runGit(t, repo, "rev-parse", "HEAD") + runGit(t, repo, "switch", "main") + _, err := client.GitDeleteBranch(ctx, repo, localBranch("backup/unmerged")) + requireCode(t, err, CodeGitBranchNotMerged) + review, ok := BranchDeleteReview(err) + if !ok || review.Name != "backup/unmerged" || review.ExpectedTarget != target { + t.Fatalf("review = %+v, %v", review, ok) + } + data, err := os.ReadFile(contractfixture.CoreFixture("git/branch-delete-v1.json")) + if err != nil { + t.Fatal(err) + } + var fixture struct { + UnmergedCode ErrorCode `json:"unmergedCode"` + } + if err := json.Unmarshal(data, &fixture); err != nil { + t.Fatal(err) + } + if fixture.UnmergedCode != CodeGitBranchNotMerged { + t.Fatal("branch deletion error code differs from Core's contract") + } + deleted, err := client.GitForceDeleteBranch(ctx, repo, localBranch(review.Name), review.ExpectedTarget) + if err != nil || deleted.DeletedTarget != target { + t.Fatalf("force deletion = %+v, %v", deleted, err) + } +} + func TestCheckoutPreflightAndModes(t *testing.T) { repo := committedRepository(t) client := NewClient() diff --git a/desktop/internal/core/gitcommit.go b/desktop/internal/core/gitcommit.go index a246a060d..44d944878 100644 --- a/desktop/internal/core/gitcommit.go +++ b/desktop/internal/core/gitcommit.go @@ -24,8 +24,10 @@ type gitWriteRequest struct { Revision string `json:"revision,omitempty"` // Checkout switches to a branch right after creating it. Checkout bool `json:"checkout,omitempty"` - // Force discards the local changes a checkout would otherwise refuse to overwrite. + // Force discards checkout/worktree changes, or skips only the branch merge check. Force bool `json:"force,omitempty"` + // ExpectedTarget binds a branch deletion to the exact commit the user reviewed. + ExpectedTarget string `json:"expectedTarget,omitempty"` // AutoStash stashes the local changes before a checkout and restores them after it. AutoStash bool `json:"autoStash,omitempty"` // FetchOptions are the structured choices of one fetch. diff --git a/desktop/internal/i18n/shared.generated.go b/desktop/internal/i18n/shared.generated.go index 9a5aadfca..aa347bd5a 100644 --- a/desktop/internal/i18n/shared.generated.go +++ b/desktop/internal/i18n/shared.generated.go @@ -53,13 +53,20 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.branch.createFromInAll": "Create from '{name}' in every repository.", "desktop.branch.created": "Created branch '{name}'", "desktop.branch.current": "Current branch", + "desktop.branch.deleteChanged": "The branch changed after confirmation. Start deletion again to review its current state.", "desktop.branch.deleteFailed": "Failed to delete branch: {reason}", "desktop.branch.deleteManyFailed": "Could not delete {failed} of {total} branches. {name}: {reason}", - "desktop.branch.deleteManyLocal": "Local branches are deleted even if they are not merged; commits only on them will no longer be on any branch.", + "desktop.branch.deleteManyLocal": "Only merged local branches are deleted. Unmerged branches require a separate force-delete confirmation.", "desktop.branch.deleteManyRemote": "Remote branches are deleted from their remote for everyone who uses it.", "desktop.branch.deleteManyTitle": "Delete {count} branches?", - "desktop.branch.deletePrompt": "Delete the local branch '{name}'? It is deleted even if it is not merged, and commits only on it will no longer be on any branch.", + "desktop.branch.deletePrompt": "Delete the local branch '{name}'? If it is not fully merged, it will be kept until you separately confirm force deletion.", "desktop.branch.deleteRemotePrompt": "Delete the remote branch '{name}'? It is deleted from the remote for everyone who uses it, and its remote-tracking branch is removed here.", + "desktop.branch.deleteRepositoryChanged": "The selected repository changed. Start branch deletion again.", + "desktop.branch.deleteResultDeleted": "Deleted", + "desktop.branch.deleteResultFailed": "Failed", + "desktop.branch.deleteResultSummary": "Deleted: {deleted}. Kept: {kept}. Failed branch names are red; hover for the reason.", + "desktop.branch.deleteResultTitle": "Branch deletion results", + "desktop.branch.deleteResultUnmerged": "Not fully merged", "desktop.branch.deleteSelected": "Delete Selected Branches ({count})", "desktop.branch.deleteSkipped": "Left out of the selection: {count}. Tags, HEAD and the current branch are not deleted here.", "desktop.branch.deleteTitle": "Delete branch?", @@ -69,6 +76,9 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.branch.detached": "Checked out '{revision}' in detached HEAD state", "desktop.branch.detachedNote": "The repository will be opened in detached HEAD state.", "desktop.branch.forceCheckout": "Force Checkout", + "desktop.branch.forceDelete": "Force Delete", + "desktop.branch.forceDeletePrompt": "These local branches contain unmerged commits. Deleting them may leave commits without a branch reference and make them difficult to recover. Only the branches listed below will be deleted. Continue?", + "desktop.branch.forceDeleteTitle": "Force delete these branches?", "desktop.branch.keepButton": "Don't Roll Back", "desktop.branch.loadFailed": "Failed to load branches: {reason}", "desktop.branch.loading": "Loading branches…", @@ -85,6 +95,7 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.branch.renamed": "Renamed the branch to '{name}'", "desktop.branch.repositoryPanel": "{repository} on {branch}", "desktop.branch.repositorySeparator": ", ", + "desktop.branch.reviewForceDelete": "Force Delete…", "desktop.branch.revision": "Tag or revision", "desktop.branch.revisionPrompt": "Enter a tag name, branch name, commit hash, or other Git revision.", "desktop.branch.revisionTitle": "Checkout Tag or Revision", @@ -98,6 +109,8 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.branch.search": "Search for branches and actions", "desktop.branch.smartCheckout": "Smart Checkout", "desktop.branch.tagsIn": "Tags in {repository}", + "desktop.branch.unmergedPrompt": "These local branches were kept because they are not fully merged. Review the warning before force deleting them.", + "desktop.branch.unmergedTitle": "Branches not fully merged", "desktop.build.ambiguousConnectionDebugAdapter": "Several enabled debug adapters of type “{type}” can attach to this run ({adapters}). Disable all but one in Settings > Plugins.", "desktop.build.argumentsRequired": "This task asks for arguments, which this window cannot collect yet.", "desktop.build.cancelled": "Build cancelled", @@ -3317,13 +3330,20 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.branch.createFromInAll": "在所有仓库中从“{name}”创建。", "desktop.branch.created": "已创建分支“{name}”", "desktop.branch.current": "当前分支", + "desktop.branch.deleteChanged": "分支在确认后已发生变化,请重新开始删除并确认当前状态。", "desktop.branch.deleteFailed": "删除分支失败:{reason}", "desktop.branch.deleteManyFailed": "{total} 个分支中有 {failed} 个删除失败。{name}:{reason}", - "desktop.branch.deleteManyLocal": "本地分支即使尚未合并也会删除,只在这些分支上的提交将不再属于任何分支。", + "desktop.branch.deleteManyLocal": "仅删除已合并的本地分支。尚未合并的分支需要另行确认强制删除。", "desktop.branch.deleteManyRemote": "远程分支会从远程仓库中删除,所有使用这个仓库的人都将看不到它们。", "desktop.branch.deleteManyTitle": "删除 {count} 个分支?", - "desktop.branch.deletePrompt": "删除本地分支“{name}”?即使它尚未合并也会删除,只在这个分支上的提交将不再属于任何分支。", + "desktop.branch.deletePrompt": "删除本地分支“{name}”?尚未完全合并时会保留分支,需要另行确认后才能强制删除。", "desktop.branch.deleteRemotePrompt": "删除远程分支“{name}”?它会从远程仓库中删除,所有使用这个仓库的人都将看不到它,本地对应的远程跟踪分支也会一并移除。", + "desktop.branch.deleteRepositoryChanged": "所选仓库已变化,请重新开始删除分支。", + "desktop.branch.deleteResultDeleted": "已删除", + "desktop.branch.deleteResultFailed": "删除失败", + "desktop.branch.deleteResultSummary": "已删除 {deleted} 个,保留 {kept} 个。删除失败的分支名以红色显示,悬停可查看原因。", + "desktop.branch.deleteResultTitle": "分支删除结果", + "desktop.branch.deleteResultUnmerged": "尚未完全合并", "desktop.branch.deleteSelected": "删除所选分支({count})", "desktop.branch.deleteSkipped": "所选项中有 {count} 项不会删除:标签、HEAD 和当前分支不在这里删除。", "desktop.branch.deleteTitle": "删除分支?", @@ -3333,6 +3353,9 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.branch.detached": "已检出“{revision}”,处于 detached HEAD 状态", "desktop.branch.detachedNote": "仓库将以 detached HEAD 状态打开。", "desktop.branch.forceCheckout": "强制检出", + "desktop.branch.forceDelete": "确认强制删除", + "desktop.branch.forceDeletePrompt": "这些本地分支包含尚未合并的提交。删除后,部分提交可能失去分支引用而难以恢复。仅删除下方列出的分支。是否继续?", + "desktop.branch.forceDeleteTitle": "确认强制删除这些分支?", "desktop.branch.keepButton": "不回滚", "desktop.branch.loadFailed": "加载分支失败:{reason}", "desktop.branch.loading": "正在加载分支…", @@ -3349,6 +3372,7 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.branch.renamed": "分支已重命名为“{name}”", "desktop.branch.repositoryPanel": "{repository},位于 {branch}", "desktop.branch.repositorySeparator": "、", + "desktop.branch.reviewForceDelete": "强制删除…", "desktop.branch.revision": "标签或修订版本", "desktop.branch.revisionPrompt": "输入标签名、分支名、提交 Hash 或其他 Git 修订版本。", "desktop.branch.revisionTitle": "检出标签或修订版本", @@ -3362,6 +3386,8 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.branch.search": "搜索分支和操作", "desktop.branch.smartCheckout": "智能检出", "desktop.branch.tagsIn": "{repository} 中的标签", + "desktop.branch.unmergedPrompt": "以下本地分支尚未完全合并,已保留。强制删除前,请先查看警告并再次确认。", + "desktop.branch.unmergedTitle": "分支尚未完全合并", "desktop.build.ambiguousConnectionDebugAdapter": "有多个已启用的“{type}”类型调试适配器都能连接这个运行({adapters})。请在 设置 > 插件 中只保留一个。", "desktop.build.argumentsRequired": "此任务需要额外参数,当前窗口尚不能收集。", "desktop.build.cancelled": "构建已取消", diff --git a/desktop/internal/workbench/app.go b/desktop/internal/workbench/app.go index 006c5ecfe..6f0e8c0bb 100644 --- a/desktop/internal/workbench/app.go +++ b/desktop/internal/workbench/app.go @@ -202,6 +202,7 @@ type Kernel interface { GitFetchSettingsOf(ctx context.Context, root string) (core.GitFetchSettings, error) GitPull(ctx context.Context, root string, strategy core.GitPullStrategy) error GitDeleteBranch(ctx context.Context, root string, branch core.GitReference) (core.GitBranchDeletion, error) + GitForceDeleteBranch(ctx context.Context, root string, branch core.GitReference, expectedTarget string) (core.GitBranchDeletion, error) GitDeleteRemoteBranch(ctx context.Context, root string, reference core.GitReference) error GitCreateTag(ctx context.Context, root, name, revision, message string) error GitRebasePreview(ctx context.Context, root, base string) (core.RebasePreview, error) diff --git a/desktop/internal/workbench/branch.go b/desktop/internal/workbench/branch.go index 7bb344839..1e8fea05f 100644 --- a/desktop/internal/workbench/branch.go +++ b/desktop/internal/workbench/branch.go @@ -18,6 +18,8 @@ type branchState struct { search, name, revision ui.Field // tagMessage is the annotation typed in the new tag dialog. tagMessage ui.Field + // deleteGen isolates completions from a dismissed or replaced deletion dialog. + deleteGen int branchSession } @@ -37,6 +39,12 @@ const ( branchDialogConflict // branchDialogDelete confirms deleting local and remote branches (branch_delete.go). branchDialogDelete + // branchDialogDeleteUnmerged offers review after Core refused ordinary deletion. + branchDialogDeleteUnmerged + // branchDialogForceDelete requires a second explicit destructive confirmation. + branchDialogForceDelete + // branchDialogDeleteResult keeps every batch outcome visible until dismissed. + branchDialogDeleteResult // branchDialogTag asks for the name, target and message of a new tag. branchDialogTag // branchDialogTagDelete confirms deleting a tag. @@ -96,6 +104,14 @@ type branchSession struct { // them; deleteSkipped counts the marked references it leaves out (branch_delete.go). deleting []core.GitReference deleteSkipped int + // deleteRoot binds both confirmation steps to the repository originally selected. + deleteRoot string + // deleteUnmerged are only the branches Core refused as unmerged, with their reviewed tips. + deleteUnmerged []branchDeletion + deleteError string + deleteList ui.ListState + deleteResults []branchDeletion + deleteResultList ui.ListState // common are the branches every repository of a project folder with several has // (branch_common.go). @@ -358,6 +374,13 @@ func (a *App) beginRevision() { // cancelBranchDialog closes the open dialog without doing what it asked. func (a *App) cancelBranchDialog() { + if a.branch.dialog == branchDialogDelete || a.branch.dialog == branchDialogDeleteUnmerged || a.branch.dialog == branchDialogForceDelete || a.branch.dialog == branchDialogDeleteResult { + a.branch.deleteGen++ + a.branch.busy = false + a.branch.deleteUnmerged = nil + a.branch.deleteError = "" + a.branch.deleteResults = nil + } a.branch.dialog, a.branch.across = branchDialogNone, false } diff --git a/desktop/internal/workbench/branch_delete.go b/desktop/internal/workbench/branch_delete.go index 0861fa2af..73b720658 100644 --- a/desktop/internal/workbench/branch_delete.go +++ b/desktop/internal/workbench/branch_delete.go @@ -2,6 +2,7 @@ package workbench import ( "context" + "errors" "slices" "strconv" @@ -36,6 +37,11 @@ func (a *App) beginDeleteBranches(branches []core.GitReference, skipped int) { b := &a.branch b.dialog, b.target = branchDialogDelete, branches[0] b.deleting, b.deleteSkipped = slices.Clone(branches), skipped + b.deleteGen++ + b.deleteRoot = a.branchRoot(a.project) + b.deleteUnmerged, b.deleteError = nil, "" + b.deleteList = ui.ListState{} + b.deleteResults, b.deleteResultList = nil, ui.ListState{} } // logChosenBranches reports whether several rows of the log's branches pane are marked and, when @@ -62,22 +68,32 @@ func (a *App) logChosenBranches(p *project) (branches []core.GitReference, skipp // branchDeletion is how deleting one branch of the dialog ended. type branchDeletion struct { branch core.GitReference - // target is the commit a deleted local branch pointed at; empty for a remote branch. + // target is a deleted local tip, or the unmerged tip Core returned for confirmation. target string err error } // confirmDelete deletes the branches the delete dialog lists, one after another. A single branch -// that fails keeps the dialog open with Git's reason, as the other branch writes do. Several are -// all attempted; the dialog closes and one notice says how many were deleted, or how many failed -// and why the first did. +// that fails keeps the dialog open with Git's reason. Batches retain each outcome, marking only +// failures red; only unmerged local branches enter the separate force confirmation. func (a *App) confirmDelete(p *project) { b := &a.branch - if b.busy || len(b.deleting) == 0 { + force := b.dialog == branchDialogForceDelete + if b.busy || len(b.deleting) == 0 || b.dialog != branchDialogDelete && !force { + return + } + if force && len(b.deleteUnmerged) != len(b.deleting) { + return + } + if b.deleteRoot != a.branchRoot(p) { + a.operationRejected("git_branch_delete", "repository_changed") + a.notifyError(i18n.Shared(a.language(), "desktop.branch.deleteRepositoryChanged")) + a.cancelBranchDialog() return } branches := slices.Clone(b.deleting) - root := a.branchRoot(p) + reviews := slices.Clone(b.deleteUnmerged) + root, gen := b.deleteRoot, b.deleteGen remote := slices.ContainsFunc(branches, func(r core.GitReference) bool { return r.Kind == "remote" }) timeout := branchOperationTimeout if remote { @@ -86,24 +102,70 @@ func (a *App) confirmDelete(p *project) { } action := "git.branch.delete" switch { + case force: + action = "git.branch.forceDelete" case len(branches) > 1: action = "git.branch.deleteMany" case remote: action = "git.branch.deleteRemote" } a.performed(action, surfaceButton) + b.busy, b.deleteError = true, "" + if b.fromPopup { + a.showGitConsole("") + } + kernel := a.kernel results := make([]branchDeletion, len(branches)) - a.runBranchWriteWithin(p, timeout, "git_branch_delete", a.text.Branch.DeleteFailed, - func(ctx context.Context, kernel Kernel, root string) error { - for i, r := range branches { + a.background(p, timeout, func(ctx context.Context) func(*App) { + for i, r := range branches { + if force { + deleted, err := kernel.GitForceDeleteBranch(ctx, root, r, reviews[i].target) + results[i] = branchDeletion{branch: r, target: deleted.DeletedTarget, err: err} + } else { results[i] = deleteOneBranch(ctx, kernel, root, r) } - if len(results) == 1 { - return results[0].err + } + var status core.GitStatus + var refreshErr error + var generation uint64 + changed := slices.ContainsFunc(results, func(d branchDeletion) bool { return d.err == nil }) + if changed { + generation = p.gitStatusGeneration.Add(1) + status, refreshErr = kernel.GitStatus(core.WithQueryCategory(core.AutomaticRefresh(ctx), core.GitQueryReload), root) + } + return func(a *App) { + for _, d := range results { + if d.err != nil { + a.operationFailed("git_branch_delete", d.err) + } + } + if refreshErr != nil { + a.operationFailed("git_branch_delete_refresh", refreshErr) } - return nil - }, - func(a *App, status core.GitStatus) { a.reportDeletions(p, root, results) }) + b := &a.branch + // A late result cannot replace a new dialog or the active repository's view. + if b.deleteGen != gen { + return + } + b.busy = false + if root != a.branchRoot(p) { + a.cancelBranchDialog() + return + } + if changed && refreshErr == nil && root == p.git.repositoryRoot(p.root) { + if a.setGit(p, gitState{loaded: true, status: status}, generation) { + a.gitStatusPublished(p) + } + } + a.reportDeletions(p, root, results) + if refreshErr != nil { + a.notifyError(a.text.Branch.DeleteFailed(refreshErr.Error())) + } + if changed && p.log.started { + a.loadLog(p) + } + } + }) } // deleteOneBranch deletes the local or remote branch r in the repository at root. @@ -118,29 +180,62 @@ func deleteOneBranch(ctx context.Context, kernel Kernel, root string, r core.Git return branchDeletion{branch: r, target: deleted.DeletedTarget, err: err} } -// reportDeletions forgets the deleted branches in the log of root and says how deleting ended. -// A single branch reached here only when it was deleted. Once a branch is deleted, the marks of -// the branches pane go, so that what stays marked is not deleted by the next press of Delete. +// reportDeletions forgets deleted references and offers a separate confirmation only for Core's +// unmerged failures. Marks clear after any successful deletion, so a later Delete cannot reuse them. func (a *App) reportDeletions(p *project, root string, results []branchDeletion) { lang := a.language() - var failed []branchDeletion + b := &a.branch for _, d := range results { + i := slices.IndexFunc(b.deleteResults, func(previous branchDeletion) bool { return previous.branch.FullName == d.branch.FullName }) + if i < 0 { + b.deleteResults = append(b.deleteResults, d) + } else { + b.deleteResults[i] = d + } + } + var failed, unmerged []branchDeletion + for _, d := range b.deleteResults { if d.err != nil { failed = append(failed, d) - a.operationFailed("git_branch_delete", d.err) + if review, ok := core.BranchDeleteReview(d.err); ok { + d.target = review.ExpectedTarget + unmerged = append(unmerged, d) + } continue } - a.dropLogReference(p, root, d.branch.FullName) } - if len(failed) < len(results) && root == p.logRepositoryRoot() { + for _, d := range results { + if d.err == nil { + a.dropLogReference(p, root, d.branch.FullName) + } + } + if slices.ContainsFunc(results, func(d branchDeletion) bool { return d.err == nil }) && root == p.logRepositoryRoot() { a.logView.forgetLogRefMarks() } + b.dialog, b.deleteError, b.deleteUnmerged = branchDialogNone, "", nil + if len(unmerged) > 0 { + b.dialog, b.deleteUnmerged = branchDialogDeleteUnmerged, unmerged + b.deleting, b.deleteSkipped = nil, 0 + for _, d := range unmerged { + b.deleting = append(b.deleting, d.branch) + } + b.target = b.deleting[0] + b.deleteList = ui.ListState{} + return + } else if len(b.deleteResults) == 1 && len(failed) == 1 { + b.dialog = branchDialogDelete + b.deleteError = a.branchDeletionReason(failed[0].err) + } else if len(failed) > 0 { + b.dialog = branchDialogDeleteResult + } switch { + case len(b.deleteResults) == 1 && len(failed) == 1: + a.notifyError(a.text.Branch.DeleteFailed(b.deleteError)) case len(failed) > 0: first := failed[0] a.notifyError(i18n.SharedFormat(lang, "desktop.branch.deleteManyFailed", map[string]string{ - "failed": strconv.Itoa(len(failed)), "total": strconv.Itoa(len(results)), - "name": first.branch.ShortName, "reason": first.err.Error()})) + "failed": strconv.Itoa(len(failed)), "total": strconv.Itoa(len(b.deleteResults)), + "name": first.branch.ShortName, "reason": a.branchDeletionReason(first.err)})) case len(results) > 1: a.notifySuccess(i18n.SharedFormat(lang, "desktop.branch.deletedMany", map[string]string{"count": strconv.Itoa(len(results))})) case results[0].branch.Kind == "remote": @@ -154,6 +249,15 @@ func (a *App) reportDeletions(p *project, root string, results []branchDeletion) } } +// branchDeletionReason localizes a stale confirmation and preserves other upstream diagnostics. +func (a *App) branchDeletionReason(err error) string { + var failure *core.Error + if errors.As(err, &failure) && failure.Code == core.CodeGitBranchChanged { + return i18n.Shared(a.language(), "desktop.branch.deleteChanged") + } + return err.Error() +} + // drawBranchDeleteDialog declares the dialog that confirms deleting the branches of the session: // one branch is named in the prompt, several are listed with whether each is local or remote. The // focus starts on Cancel, the first control, so Enter does not delete by accident. @@ -170,12 +274,14 @@ func (a *App) drawBranchDeleteDialog(c ui.C, p *project) { default: prompt = t.DeletePrompt(b.target.ShortName) } - var body func() - if many || b.deleteSkipped > 0 { - body = func() { a.drawBranchDeleteList(c, many) } + body := func() { + a.drawBranchDeleteList(c, many) + if b.deleteError != "" { + ui.Paragraph(c, b.deleteError, 4).Color(a.theme.Danger) + } } a.branchDialogOf(c, title, prompt, body, func() { - if ui.Button(c, t.Cancel).Outline().Clicked() { + if ui.Button(c, t.Cancel).Outline().Disabled(b.busy).AutoFocus().Clicked() { c.After(a.cancelBranchDialog) } if ui.Button(c, t.DeleteButton).Destructive().Disabled(b.busy).Clicked() { @@ -184,30 +290,114 @@ func (a *App) drawBranchDeleteDialog(c ui.C, p *project) { }) } +// drawBranchForceDeleteDialog separates the failed safe deletion from the destructive +// confirmation. A new modal identity resets focus to Cancel before force can run. +func (a *App) drawBranchForceDeleteDialog(c ui.C, p *project) { + b, lang := &a.branch, a.language() + c = c.Part(strconv.Itoa(int(b.dialog))) + confirming := b.dialog == branchDialogForceDelete + title := i18n.Shared(lang, "desktop.branch.unmergedTitle") + prompt := i18n.Shared(lang, "desktop.branch.unmergedPrompt") + button := i18n.Shared(lang, "desktop.branch.reviewForceDelete") + result := b.dialog == branchDialogDeleteResult + if result { + title = i18n.Shared(lang, "desktop.branch.deleteResultTitle") + prompt = "" + } + if confirming { + title = i18n.Shared(lang, "desktop.branch.forceDeleteTitle") + prompt = i18n.Shared(lang, "desktop.branch.forceDeletePrompt") + button = i18n.Shared(lang, "desktop.branch.forceDelete") + } + a.branchDialogOf(c, title, prompt, func() { + if confirming { + a.drawBranchDeleteRows(c) + } else { + a.drawBranchDeletionResults(c) + } + }, func() { + label := a.text.Branch.Cancel + if result { + label = i18n.Shared(lang, "ui.close") + } + if ui.Button(c, label).Outline().Disabled(b.busy).AutoFocus().Clicked() { + c.After(a.cancelBranchDialog) + } + if !result && ui.Button(c, button).Destructive().Disabled(b.busy).Clicked() { + c.After(func() { + if confirming { + a.confirmDelete(p) + } else { + a.performed("git.branch.reviewForceDelete", surfaceButton) + b.dialog = branchDialogForceDelete + } + }) + } + }) +} + +// drawBranchDeleteRows virtualizes the selection in either confirmation dialog. +func (a *App) drawBranchDeleteRows(c ui.C) { + b, g := &a.branch, a.text.Git + height := min(branchBlockingHeight, float32(len(b.deleting))*28) + ui.List(c, &b.deleteList, len(b.deleting), func(row ui.ListRow) { + r := b.deleting[row.Index] + kind := g.LocalGroup + if r.Kind == "remote" { + kind = g.RemoteGroup + } + row.Element.FillWidth().Height(28).Gap(8).Items(ui.Center).Children(func() { + name := ui.Text(row.C, r.ShortName).Grow(1).Shrink(1).MinWidth(0).Ellipsis() + if b.dialog == branchDialogForceDelete { + name.Color(a.theme.Danger) + } + ui.Text(row.C, kind).Shrink(0).FontSize(a.theme.Metrics.FontSizeS).Color(a.colors.Subtle) + }) + }).Scrollbars().FillWidth().Height(height) +} + +// drawBranchDeletionResults retains the original selection's outcomes. Failed names are red and +// each status exposes its own reason, including failures outside the force-delete selection. +func (a *App) drawBranchDeletionResults(c ui.C) { + b, lang := &a.branch, a.language() + deleted := 0 + for _, d := range b.deleteResults { + if d.err == nil { + deleted++ + } + } + ui.Paragraph(c, i18n.SharedFormat(lang, "desktop.branch.deleteResultSummary", map[string]string{ + "deleted": strconv.Itoa(deleted), "kept": strconv.Itoa(len(b.deleteResults) - deleted)}), 3) + height := min(branchBlockingHeight, float32(len(b.deleteResults))*28) + ui.List(c, &b.deleteResultList, len(b.deleteResults), func(row ui.ListRow) { + d := b.deleteResults[row.Index] + status, reason := i18n.Shared(lang, "desktop.branch.deleteResultDeleted"), "" + color := a.colors.Text + if d.err != nil { + color = a.theme.Danger + status, reason = i18n.Shared(lang, "desktop.branch.deleteResultFailed"), a.branchDeletionReason(d.err) + if _, ok := core.BranchDeleteReview(d.err); ok { + status = i18n.Shared(lang, "desktop.branch.deleteResultUnmerged") + } + } + row.Element.FillWidth().Height(28).Gap(8).Items(ui.Center).Hit(ui.ID(row.C), d.branch.ShortName).Tooltip(reason).Children(func() { + ui.Text(row.C, d.branch.ShortName).Color(color).Grow(1).Shrink(1).MinWidth(0).Ellipsis() + ui.Text(row.C, status).Color(color).FontSize(a.theme.Metrics.FontSizeS).Shrink(0) + }) + }).Scrollbars().FillWidth().Height(height) +} + // drawBranchDeleteList declares the body of the delete dialog: with many set, the branches it // deletes and what deleting local and remote branches does; then the marked references it leaves // out, if any. func (a *App) drawBranchDeleteList(c ui.C, many bool) { - b, g := &a.branch, a.text.Git + b := &a.branch lang := a.language() small := a.theme.Metrics.FontSizeS note := func(text string) { ui.Paragraph(c, text, 3).FontSize(small).Color(a.colors.Subtle) } ui.Column(c).FillWidth().Gap(8).Children(func() { if many { - ui.Scroll(c).Scrollbars().FillWidth().MaxHeight(branchBlockingHeight).Children(func() { - ui.Column(c).FillWidth().Gap(2).Children(func() { - for _, r := range b.deleting { - kind := g.LocalGroup - if r.Kind == "remote" { - kind = g.RemoteGroup - } - ui.Row(c.Key(r.FullName)).FillWidth().Gap(8).Children(func() { - ui.Text(c, r.ShortName).Grow(1).Shrink(1).MinWidth(0).FontSize(small).Color(a.colors.Text).Ellipsis() - ui.Text(c, kind).Shrink(0).FontSize(small).Color(a.colors.Subtle) - }) - } - }) - }) + a.drawBranchDeleteRows(c) if slices.ContainsFunc(b.deleting, func(r core.GitReference) bool { return r.Kind == "local" }) { note(i18n.Shared(lang, "desktop.branch.deleteManyLocal")) } diff --git a/desktop/internal/workbench/branch_delete_test.go b/desktop/internal/workbench/branch_delete_test.go index f3c1f5ae3..f15fd03e6 100644 --- a/desktop/internal/workbench/branch_delete_test.go +++ b/desktop/internal/workbench/branch_delete_test.go @@ -234,7 +234,7 @@ func TestLogDeleteButtonReportsTheBranchesItCouldNotDelete(t *testing.T) { t.Fatalf("dialog %v with %d branches, %d left out; want the delete confirmation of one and origin/gone", b.dialog, len(b.deleting), b.deleteSkipped) } h.click(center(h.popupHit(h.app.text.Branch.DeleteButton))) - h.await("the deletion attempted", func() bool { return !b.busy && b.dialog == branchDialogNone }) + h.await("the deletion attempted", func() bool { return !b.busy && b.dialog == branchDialogDeleteResult }) h.settleChain() if got := gitRun(t, dir, "branch", "--list", "one"); got != "" { t.Fatalf("one is still there: %q", got) @@ -247,4 +247,162 @@ func TestLogDeleteButtonReportsTheBranchesItCouldNotDelete(t *testing.T) { if _, ok := p.log.findReference("refs/heads/one"); ok { t.Fatal("the log still lists one") } + if !h.shows("origin/gone") || !h.shows(i18n.Shared(h.app.language(), "desktop.branch.deleteResultFailed")) { + t.Fatal("the result does not identify the failed remote branch") + } +} + +// makeUnmergedBranch creates real unique history and returns its tip without retaining a checkout. +func makeUnmergedBranch(t *testing.T, dir, name string) string { + t.Helper() + gitRun(t, dir, "switch", "-c", name) + gitRun(t, dir, "commit", "--allow-empty", "-m", "unique branch commit") + target := gitRun(t, dir, "rev-parse", "HEAD") + gitRun(t, dir, "switch", "main") + return target +} + +func TestLogForceDeleteRequiresSecondConfirmation(t *testing.T) { + h, p, dir, _ := branchDeleteFixture(t) + name := "backup/before-strip-trailers" + makeUnmergedBranch(t, dir, name) + h.app.loadLog(p) + h.settleChain() + lang := h.app.language() + start := func() { + h.logRefMenu(name) + h.click(center(h.popupHit(h.app.text.Branch.Delete))) + h.click(center(h.popupHit(h.app.text.Branch.DeleteButton))) + h.await("ordinary deletion refused", func() bool { return !h.app.branch.busy }) + h.settleChain() + if h.app.branch.dialog != branchDialogDeleteUnmerged { + t.Fatalf("dialog = %v, want unmerged warning", h.app.branch.dialog) + } + h.click(center(h.popupHit(i18n.Shared(lang, "desktop.branch.reviewForceDelete")))) + if h.app.branch.dialog != branchDialogForceDelete || h.app.branch.busy { + t.Fatal("review did not open a separate idle confirmation") + } + if got := h.focusedName(); got != h.app.text.Branch.Cancel { + t.Fatalf("initial focus = %q, want Cancel", got) + } + if !h.showsWrapped(i18n.Shared(lang, "desktop.branch.forceDeletePrompt")) { + t.Fatal("confirmation omits the unmerged-commit warning") + } + if got := gitRun(t, dir, "branch", "--list", name); got == "" { + t.Fatal("branch was deleted before the second confirmation") + } + } + start() + // The new modal starts on Cancel. Enter must never approve destructive force deletion. + if err := h.driver.Key(gfx.KeyEnter, 0); err != nil { + t.Fatal(err) + } + h.settleChain() + if h.app.branch.dialog != branchDialogNone || gitRun(t, dir, "branch", "--list", name) == "" { + t.Fatal("Enter did not cancel safely") + } + start() + if err := h.driver.Key(gfx.KeyEscape, 0); err != nil { + t.Fatal(err) + } + h.settleChain() + if h.app.branch.dialog != branchDialogNone || gitRun(t, dir, "branch", "--list", name) == "" { + t.Fatal("Escape did not cancel safely") + } + start() + h.click(center(h.popupHit(i18n.Shared(lang, "desktop.branch.forceDelete")))) + h.await("forced deletion completed", func() bool { return !h.app.branch.busy }) + h.settleChain() + if h.app.branch.dialog != branchDialogNone || gitRun(t, dir, "branch", "--list", name) != "" { + t.Fatal("confirmed force deletion did not remove the branch") + } +} + +func TestLogForceDeleteBatchOnlyRetriesUnmergedAndRejectsChangedTip(t *testing.T) { + h, p, dir, _ := branchDeleteFixture(t) + name := "backup/unmerged" + old := makeUnmergedBranch(t, dir, name) + gitRun(t, dir, "branch", "merged") + h.app.loadLog(p) + h.settleChain() + h.markLogRefs("merged", name) + h.clickNamed(h.app.text.Git.DeleteBranch) + h.click(center(h.popupHit(h.app.text.Branch.DeleteButton))) + h.await("batch deletion completed", func() bool { return !h.app.branch.busy }) + h.settleChain() + b := &h.app.branch + if b.dialog != branchDialogDeleteUnmerged || len(b.deleting) != 1 || b.deleting[0].ShortName != name { + t.Fatalf("force retry selection = %+v, dialog = %v", b.deleting, b.dialog) + } + if gitRun(t, dir, "branch", "--list", "merged") != "" { + t.Fatal("ordinary deletion left the merged branch") + } + h.click(center(h.popupHit(i18n.Shared(h.app.language(), "desktop.branch.reviewForceDelete")))) + // An external writer moves the target after review, with no timing-based synchronization. + current := gitRun(t, dir, "rev-parse", "main") + gitRun(t, dir, "update-ref", "refs/heads/"+name, current, old) + h.click(center(h.popupHit(i18n.Shared(h.app.language(), "desktop.branch.forceDelete")))) + h.await("stale confirmation refused", func() bool { return !b.busy }) + h.settleChain() + if got := gitRun(t, dir, "rev-parse", "refs/heads/"+name); got != current { + t.Fatalf("changed branch was deleted or moved: %s", got) + } + if b.dialog != branchDialogDeleteResult || len(b.deleteUnmerged) != 0 || !strings.Contains(lastNotice(h), i18n.Shared(h.app.language(), "desktop.branch.deleteChanged")) { + t.Fatal("stale force confirmation was retained or change was not explained") + } +} + +func TestLogForceDeleteMixedBatchRetainsEveryOutcome(t *testing.T) { + h, _, dir, other := branchDeleteFixture(t) + name := "backup/unmerged" + makeUnmergedBranch(t, dir, name) + makeUnmergedBranch(t, dir, "backup/busy") + gitRun(t, dir, "branch", "merged") + h.publishBranch(t, dir, other, "gone") + bare := gitRun(t, dir, "remote", "get-url", "origin") + if err := os.Rename(bare, bare+".moved"); err != nil { + t.Fatal(err) + } + h.clickLogRef("merged") + h.markLogRefs(name, "backup/busy", "origin/gone") + if names, _, several := h.markedLogNames(); !several || len(names) != 4 { + t.Fatalf("plain click followed by primary clicks selected %v", names) + } + h.clickNamed(h.app.text.Git.DeleteBranch) + h.click(center(h.popupHit(h.app.text.Branch.DeleteButton))) + b := &h.app.branch + h.await("mixed batch attempted", func() bool { return !b.busy }) + h.settleChain() + if b.dialog != branchDialogDeleteUnmerged || len(b.deleting) != 2 || len(b.deleteResults) != 4 { + t.Fatalf("mixed result lost a branch or included a non-unmerged force target: %+v", b) + } + if b.deleteResults[slices.IndexFunc(b.deleteResults, func(d branchDeletion) bool { return d.branch.ShortName == "merged" })].err != nil { + t.Fatal("merged branch did not succeed") + } + for _, key := range []string{"deleteResultDeleted", "deleteResultFailed", "deleteResultUnmerged"} { + if !h.shows(i18n.Shared(h.app.language(), "desktop.branch."+key)) { + t.Fatalf("mixed result does not show %s", key) + } + } + // A branch created again under a successful name must not be retried by force. + gitRun(t, dir, "branch", "merged") + h.click(center(h.popupHit(i18n.Shared(h.app.language(), "desktop.branch.reviewForceDelete")))) + // Another worktree checks out a reviewed branch before force executes. Only that branch + // fails; the remaining unmerged branch still deletes and earlier remote failure stays visible. + gitRun(t, dir, "worktree", "add", t.TempDir(), "backup/busy") + h.click(center(h.popupHit(i18n.Shared(h.app.language(), "desktop.branch.forceDelete")))) + h.await("only unmerged branch force deleted", func() bool { return !b.busy }) + h.settleChain() + if b.dialog != branchDialogDeleteResult || gitRun(t, dir, "branch", "--list", name) != "" || gitRun(t, dir, "branch", "--list", "merged") == "" { + t.Fatal("force retry removed a successful branch again or kept the confirmed branch") + } + if gitRun(t, dir, "show-ref", "--verify", "refs/remotes/origin/gone") == "" { + t.Fatal("unreachable remote branch was removed locally") + } + if gitRun(t, dir, "branch", "--list", "backup/busy") == "" { + t.Fatal("force deleted a branch checked out in another worktree") + } + if len(b.deleteUnmerged) != 0 || len(b.deleteResults) != 4 { + t.Fatal("force completion lost original outcomes or retained stale reviews") + } } diff --git a/desktop/internal/workbench/branch_delete_visual_test.go b/desktop/internal/workbench/branch_delete_visual_test.go index 50ba725b1..94eae2bac 100644 --- a/desktop/internal/workbench/branch_delete_visual_test.go +++ b/desktop/internal/workbench/branch_delete_visual_test.go @@ -11,6 +11,7 @@ import ( "github.com/1lck/Lithe-IDEA/desktop/internal/i18n" "github.com/1lck/Lithe-IDEA/desktop/internal/store" "github.com/vivaui/viva/app" + "github.com/vivaui/viva/gfx" "github.com/vivaui/viva/headless" ) @@ -26,9 +27,10 @@ func TestVisualBranchDelete(t *testing.T) { t.Fatal(err) } for _, look := range []struct{ theme, language string }{{"dark", "zh-Hans"}, {"light", "en"}} { - for _, scene := range []string{"remote-dialog", "marked-menu", "marked-dialog"} { + for _, scene := range []string{"remote-dialog", "marked-menu", "marked-dialog", "unmerged-warning", "force-confirmation", "mixed-result", "tree-selection"} { t.Run(scene+"-"+look.theme, func(t *testing.T) { dir := newTestRepository(t) + writeTreeFiles(t, dir, "selection-a.txt", "selection-b.txt") gitRun(t, dir, "commit", "-am", "second") gitRun(t, dir, "remote", "add", "origin", t.TempDir()) for _, name := range []string{"main", "feature"} { @@ -37,6 +39,9 @@ func TestVisualBranchDelete(t *testing.T) { gitRun(t, dir, "branch", "--set-upstream-to=origin/main", "main") gitRun(t, dir, "branch", "one") gitRun(t, dir, "branch", "two") + if scene == "unmerged-warning" || scene == "force-confirmation" || scene == "mixed-result" { + makeUnmergedBranch(t, dir, "backup/before-strip-trailers") + } prefs := store.At(t.TempDir()) if err := prefs.Save(settingsFile, settings{Theme: themeChoice(look.theme), Language: look.language, DisableAutoSave: true}); err != nil { t.Fatal(err) @@ -52,9 +57,55 @@ func TestVisualBranchDelete(t *testing.T) { return session.Driver(), session.Close, nil }) h.openLog(t, dir) - if scene == "remote-dialog" { + if scene == "tree-selection" { + p := h.app.project + h.app.reduceChrome(core.SetChromeOpen(itemProject, true)) + h.settleChain() + h.await("tree files loaded", func() bool { return p.tree.root != nil && p.tree.root.listed }) + h.settleChain() + // Real pointer clicks: plain click followed by the platform's primary modifier. + var files []string + for _, n := range p.tree.rows { + if n.path != "" && !n.dir { + files = append(files, n.path) + } + } + if len(files) < 2 { + t.Fatal("tree fixture has fewer than two files") + } + h.click(center(h.treeRowHit(files[0]).Bounds)) + h.settleChain() + key := gfx.KeyControlLeft + if primaryModifier() == gfx.ModifierMeta { + key = gfx.KeyMetaLeft + } + if err := h.driver.KeyDown(key, ""); err != nil { + t.Fatal(err) + } + h.click(center(h.treeRowHit(files[1]).Bounds)) + if err := h.driver.KeyUp(key, ""); err != nil { + t.Fatal(err) + } + } else if scene == "mixed-result" { + h.markLogRefs("one", "backup/before-strip-trailers", "origin/feature") + h.clickNamed(h.app.text.Git.DeleteBranch) + h.click(center(h.popupHit(h.app.text.Branch.DeleteButton))) + h.await("mixed deletion result", func() bool { return !h.app.branch.busy }) + } else if scene == "remote-dialog" { h.logRefMenu("origin/feature") h.click(center(h.popupHit(h.app.text.Branch.Delete))) + } else if scene == "unmerged-warning" || scene == "force-confirmation" { + h.logRefMenu("backup/before-strip-trailers") + h.click(center(h.popupHit(h.app.text.Branch.Delete))) + h.click(center(h.popupHit(h.app.text.Branch.DeleteButton))) + h.await("unmerged warning", func() bool { return !h.app.branch.busy }) + h.settleChain() + if h.app.branch.dialog != branchDialogDeleteUnmerged { + t.Fatal("Core did not refuse the unmerged branch") + } + if scene == "force-confirmation" { + h.click(center(h.popupHit(i18n.Shared(h.app.language(), "desktop.branch.reviewForceDelete")))) + } } else { h.markLogRefs("one", "two", "origin/feature", "main", "HEAD") label := i18n.SharedFormat(h.app.language(), "desktop.branch.deleteSelected", map[string]string{"count": "3"}) diff --git a/desktop/internal/workbench/branch_view.go b/desktop/internal/workbench/branch_view.go index 43efefc0a..6f361bb48 100644 --- a/desktop/internal/workbench/branch_view.go +++ b/desktop/internal/workbench/branch_view.go @@ -567,6 +567,8 @@ func (a *App) drawBranchDialog(c ui.C, p *project) { a.drawBranchConflictDialog(c, p) case branchDialogDelete: a.drawBranchDeleteDialog(c, p) + case branchDialogDeleteUnmerged, branchDialogForceDelete, branchDialogDeleteResult: + a.drawBranchForceDeleteDialog(c, p) case branchDialogTag: a.drawTagDialog(c, p) case branchDialogTagDelete: diff --git a/desktop/internal/workbench/filetree.go b/desktop/internal/workbench/filetree.go index f350d882f..956cadcda 100644 --- a/desktop/internal/workbench/filetree.go +++ b/desktop/internal/workbench/filetree.go @@ -41,6 +41,9 @@ type fileTree struct { byPath map[string]*treeNode // selected is the node whose row is highlighted, which the arrow keys move. selected *treeNode + // focused remembers focus already observed so pointer focus cannot replace the selection + // before Core applies the click's modifiers. + focused gfx.ID // marked are the paths a Ctrl or Shift click selected for a batch; anchor is the path a // Shift click extends from, and targets what a batch acts on, as Core last said // (filetree_batch.go). diff --git a/desktop/internal/workbench/filetree_test.go b/desktop/internal/workbench/filetree_test.go index 0548c51ab..6d36330ef 100644 --- a/desktop/internal/workbench/filetree_test.go +++ b/desktop/internal/workbench/filetree_test.go @@ -574,11 +574,52 @@ func TestProjectTreeBatchSelectionFollowsCore(t *testing.T) { h.app.treeModifiedClick(p, p.tree.find("b.txt"), ui.Primary) stubTreeTrash(t) h.app.removeTreeItems(p, paths(p.tree.batchTargets()), false) + h.settleChain() if len(p.tree.marked) != 0 || len(p.tree.targets) != 0 { t.Fatalf("the end of a batch left marks %v targets %v", p.tree.marked, p.tree.targets) } } +func TestProjectTreePrimaryClickPreservesAndTogglesSelection(t *testing.T) { + root := t.TempDir() + writeTreeFiles(t, root, "a.txt", "b.txt", "c.txt") + h := newHarness(t, &testKernel{Client: core.NewClient()}) + p := h.openTree(t, root) + h.click(center(h.treeRowHit("a.txt").Bounds)) + h.settleChain() + key := gfx.KeyControlLeft + if primaryModifier() == gfx.ModifierMeta { + key = gfx.KeyMetaLeft + } + if err := h.driver.KeyDown(key, ""); err != nil { + t.Fatal(err) + } + t.Cleanup(func() { _ = h.driver.KeyUp(key, "") }) + h.click(center(h.treeRowHit("b.txt").Bounds)) + h.settleChain() + if !p.tree.marked["a.txt"] || !p.tree.marked["b.txt"] { + t.Fatalf("primary click lost the previous selection: %v", p.tree.marked) + } + for i, n := range p.tree.rows { + if (n.path == "a.txt" || n.path == "b.txt") && !p.tree.describe(i).Selected { + t.Fatalf("marked row %s is not painted selected", n.path) + } + } + h.click(center(h.treeRowHit("a.txt").Bounds)) + h.settleChain() + if p.tree.marked["a.txt"] || !p.tree.marked["b.txt"] { + t.Fatalf("primary click did not toggle one row: %v", p.tree.marked) + } + if err := h.driver.KeyUp(key, ""); err != nil { + t.Fatal(err) + } + h.click(center(h.treeRowHit("c.txt").Bounds)) + h.settleChain() + if len(p.tree.marked) != 0 || p.tree.selected != p.tree.find("c.txt") { + t.Fatalf("plain click left selection: %v", p.tree.marked) + } +} + // TestProjectTreeShowsUnixNamesWithBackslashes is #2009: on macOS and Linux a backslash is part // of a file name, as in the folder `D:\logs` that Spring Boot creates for a Windows-style // `logging.file.path`. Core used to report it as `D:/logs`, two levels deep, so the rows of the diff --git a/desktop/internal/workbench/filetree_view.go b/desktop/internal/workbench/filetree_view.go index 4b2ae0e06..41bb117bd 100644 --- a/desktop/internal/workbench/filetree_view.go +++ b/desktop/internal/workbench/filetree_view.go @@ -31,7 +31,11 @@ func (t *fileTree) label(i int) string { return t.rows[i].name } func (t *fileTree) describe(i int) ui.TreeNode { n := t.rows[i] - return ui.TreeNode{Depth: n.depth, Branch: n.dir && !n.empty, Expanded: n.dir && n.expanded, Selected: n == t.selected} + selected := t.marked[n.path] + if len(t.marked) == 0 && t.anchor == "" { + selected = n == t.selected + } + return ui.TreeNode{Depth: n.depth, Branch: n.dir && !n.empty, Expanded: n.dir && n.expanded, Selected: selected} } // projectTree declares the body of the Project tool window: the rows of the project's @@ -133,11 +137,14 @@ func (a *App) projectTree(c ui.C, p *project) { // scrolls a row to show to the middle of the view when it is out of view. The selection // follows the keyboard: the row the arrow keys moved the focus to is the selected one. func (a *App) syncTreeSelection(canvas *gfx.Canvas, t *fileTree) { - if focused := canvas.Focused(); !focused.IsZero() { - for i, n := range t.rows { - if t.view.RowID(i) == focused { - t.selected = n - break + if focused := canvas.Focused(); focused != t.focused { + t.focused = focused + if _, pointer := canvas.PointerOn(focused); !pointer { + for i, n := range t.rows { + if t.view.RowID(i) == focused { + t.selected = n + break + } } } } diff --git a/desktop/internal/workbench/gitlog_view.go b/desktop/internal/workbench/gitlog_view.go index 0c45f2225..817aa0801 100644 --- a/desktop/internal/workbench/gitlog_view.go +++ b/desktop/internal/workbench/gitlog_view.go @@ -318,7 +318,11 @@ func (a *App) appendLogNodes(rows []logRefRow, p *project, prefix, foreign strin // only fold or switch repository. func (v *logView) refNode(i int) ui.TreeNode { r := v.refItems[i] - selected := (r.kind == logRefHead || r.kind == logRefReference) && (v.refSel == r.key || v.refMarks[r.key]) + selected := v.refMarks[r.key] + if len(v.refMarks) == 0 && v.refAnchor == "" { + selected = v.refSel == r.key + } + selected = selected && (r.kind == logRefHead || r.kind == logRefReference) return ui.TreeNode{Depth: r.depth, Branch: r.kind == logRefSection || r.kind == logRefFolder || r.kind == logRefRepository, Expanded: r.open, Selected: selected} } diff --git a/scripts/desktop/build-desktop-core.sh b/scripts/desktop/build-desktop-core.sh index 86f7bb372..6fa7101d0 100755 --- a/scripts/desktop/build-desktop-core.sh +++ b/scripts/desktop/build-desktop-core.sh @@ -292,7 +292,8 @@ PINNED_CORE_REPOSITORY="https://github.com/Lithe-IDEA/Lithe-core-rust.git" # CLI launch policy, isolated document command policy and opt-in shell registration from Core #129. # Lithe-core-rust main at d630938 (#130 squash-merged): companion marketplace recommendations # contract, resolveSource.recommendationsURL, and plugins.marketplace.recommendForWorkspace (#2228). -PINNED_CORE_REVISION="d6309386cbc164ed82eb8728cf6b7d90db12fc61" +# Core #132, merged into main: reviewed-tip force deletion and first-primary-click selection. +PINNED_CORE_REVISION="4ef9d9e0ad1c28d195242d9e8986da151bcc50c2" PROFILE="debug" while [[ $# -gt 0 ]]; do case "$1" in diff --git a/shared/i18n/features/branch-delete.json b/shared/i18n/features/branch-delete.json index 05896d101..9f6b90507 100644 --- a/shared/i18n/features/branch-delete.json +++ b/shared/i18n/features/branch-delete.json @@ -87,6 +87,101 @@ "parameters": { "count": "string" } + }, + { + "id": "desktop.branch.deleteRepositoryChanged", + "description": "Branch deletion: deleteRepositoryChanged", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.branch.deleteChanged", + "description": "Branch deletion: deleteChanged", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.branch.unmergedTitle", + "description": "Branch deletion: unmergedTitle", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.branch.unmergedPrompt", + "description": "Branch deletion: unmergedPrompt", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.branch.reviewForceDelete", + "description": "Branch deletion: reviewForceDelete", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.branch.forceDeleteTitle", + "description": "Branch deletion: forceDeleteTitle", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.branch.forceDeletePrompt", + "description": "Branch deletion: forceDeletePrompt", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.branch.forceDelete", + "description": "Branch deletion: forceDelete", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.branch.deleteResultTitle", + "description": "Branch deletion outcome: deleteResultTitle", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.branch.deleteResultSummary", + "description": "Branch deletion outcome: deleteResultSummary", + "platforms": [ + "desktop" + ], + "parameters": { + "deleted": "string", + "kept": "string" + } + }, + { + "id": "desktop.branch.deleteResultDeleted", + "description": "Branch deletion outcome: deleteResultDeleted", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.branch.deleteResultFailed", + "description": "Branch deletion outcome: deleteResultFailed", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.branch.deleteResultUnmerged", + "description": "Branch deletion outcome: deleteResultUnmerged", + "platforms": [ + "desktop" + ] } ], "locales": { @@ -94,23 +189,49 @@ "desktop.branch.deleteRemotePrompt": "Delete the remote branch '{name}'? It is deleted from the remote for everyone who uses it, and its remote-tracking branch is removed here.", "desktop.branch.deletedRemote": "Deleted remote branch '{name}'", "desktop.branch.deleteManyTitle": "Delete {count} branches?", - "desktop.branch.deleteManyLocal": "Local branches are deleted even if they are not merged; commits only on them will no longer be on any branch.", + "desktop.branch.deleteManyLocal": "Only merged local branches are deleted. Unmerged branches require a separate force-delete confirmation.", "desktop.branch.deleteManyRemote": "Remote branches are deleted from their remote for everyone who uses it.", "desktop.branch.deleteSkipped": "Left out of the selection: {count}. Tags, HEAD and the current branch are not deleted here.", "desktop.branch.deletedMany": "Deleted {count} branches", "desktop.branch.deleteManyFailed": "Could not delete {failed} of {total} branches. {name}: {reason}", - "desktop.branch.deleteSelected": "Delete Selected Branches ({count})" + "desktop.branch.deleteSelected": "Delete Selected Branches ({count})", + "desktop.branch.deleteRepositoryChanged": "The selected repository changed. Start branch deletion again.", + "desktop.branch.deleteChanged": "The branch changed after confirmation. Start deletion again to review its current state.", + "desktop.branch.unmergedTitle": "Branches not fully merged", + "desktop.branch.unmergedPrompt": "These local branches were kept because they are not fully merged. Review the warning before force deleting them.", + "desktop.branch.reviewForceDelete": "Force Delete…", + "desktop.branch.forceDeleteTitle": "Force delete these branches?", + "desktop.branch.forceDeletePrompt": "These local branches contain unmerged commits. Deleting them may leave commits without a branch reference and make them difficult to recover. Only the branches listed below will be deleted. Continue?", + "desktop.branch.forceDelete": "Force Delete", + "desktop.branch.deleteResultTitle": "Branch deletion results", + "desktop.branch.deleteResultSummary": "Deleted: {deleted}. Kept: {kept}. Failed branch names are red; hover for the reason.", + "desktop.branch.deleteResultDeleted": "Deleted", + "desktop.branch.deleteResultFailed": "Failed", + "desktop.branch.deleteResultUnmerged": "Not fully merged" }, "zh-CN": { "desktop.branch.deleteRemotePrompt": "删除远程分支“{name}”?它会从远程仓库中删除,所有使用这个仓库的人都将看不到它,本地对应的远程跟踪分支也会一并移除。", "desktop.branch.deletedRemote": "已删除远程分支“{name}”", "desktop.branch.deleteManyTitle": "删除 {count} 个分支?", - "desktop.branch.deleteManyLocal": "本地分支即使尚未合并也会删除,只在这些分支上的提交将不再属于任何分支。", + "desktop.branch.deleteManyLocal": "仅删除已合并的本地分支。尚未合并的分支需要另行确认强制删除。", "desktop.branch.deleteManyRemote": "远程分支会从远程仓库中删除,所有使用这个仓库的人都将看不到它们。", "desktop.branch.deleteSkipped": "所选项中有 {count} 项不会删除:标签、HEAD 和当前分支不在这里删除。", "desktop.branch.deletedMany": "已删除 {count} 个分支", "desktop.branch.deleteManyFailed": "{total} 个分支中有 {failed} 个删除失败。{name}:{reason}", - "desktop.branch.deleteSelected": "删除所选分支({count})" + "desktop.branch.deleteSelected": "删除所选分支({count})", + "desktop.branch.deleteRepositoryChanged": "所选仓库已变化,请重新开始删除分支。", + "desktop.branch.deleteChanged": "分支在确认后已发生变化,请重新开始删除并确认当前状态。", + "desktop.branch.unmergedTitle": "分支尚未完全合并", + "desktop.branch.unmergedPrompt": "以下本地分支尚未完全合并,已保留。强制删除前,请先查看警告并再次确认。", + "desktop.branch.reviewForceDelete": "强制删除…", + "desktop.branch.forceDeleteTitle": "确认强制删除这些分支?", + "desktop.branch.forceDeletePrompt": "这些本地分支包含尚未合并的提交。删除后,部分提交可能失去分支引用而难以恢复。仅删除下方列出的分支。是否继续?", + "desktop.branch.forceDelete": "确认强制删除", + "desktop.branch.deleteResultTitle": "分支删除结果", + "desktop.branch.deleteResultSummary": "已删除 {deleted} 个,保留 {kept} 个。删除失败的分支名以红色显示,悬停可查看原因。", + "desktop.branch.deleteResultDeleted": "已删除", + "desktop.branch.deleteResultFailed": "删除失败", + "desktop.branch.deleteResultUnmerged": "尚未完全合并" } } } diff --git a/shared/i18n/locales/en-US.json b/shared/i18n/locales/en-US.json index fdc3ea278..3014d5136 100644 --- a/shared/i18n/locales/en-US.json +++ b/shared/i18n/locales/en-US.json @@ -774,7 +774,7 @@ "desktop.branch.created": "Created branch '{name}'", "desktop.branch.current": "Current branch", "desktop.branch.deleteFailed": "Failed to delete branch: {reason}", - "desktop.branch.deletePrompt": "Delete the local branch '{name}'? It is deleted even if it is not merged, and commits only on it will no longer be on any branch.", + "desktop.branch.deletePrompt": "Delete the local branch '{name}'? If it is not fully merged, it will be kept until you separately confirm force deletion.", "desktop.branch.deleteTitle": "Delete branch?", "desktop.branch.deleted": "Deleted branch '{name}' (was {target})", "desktop.branch.detached": "Checked out '{revision}' in detached HEAD state", diff --git a/shared/i18n/locales/zh-CN.json b/shared/i18n/locales/zh-CN.json index cc56af167..9ffea3333 100644 --- a/shared/i18n/locales/zh-CN.json +++ b/shared/i18n/locales/zh-CN.json @@ -774,7 +774,7 @@ "desktop.branch.created": "已创建分支“{name}”", "desktop.branch.current": "当前分支", "desktop.branch.deleteFailed": "删除分支失败:{reason}", - "desktop.branch.deletePrompt": "删除本地分支“{name}”?即使它尚未合并也会删除,只在这个分支上的提交将不再属于任何分支。", + "desktop.branch.deletePrompt": "删除本地分支“{name}”?尚未完全合并时会保留分支,需要另行确认后才能强制删除。", "desktop.branch.deleteTitle": "删除分支?", "desktop.branch.deleted": "已删除分支“{name}”(原指向 {target})", "desktop.branch.detached": "已检出“{revision}”,处于 detached HEAD 状态", diff --git a/shared/platform-feature-matrix/features/git-branches-remotes.json b/shared/platform-feature-matrix/features/git-branches-remotes.json index aa963303e..5cc9477c0 100644 --- a/shared/platform-feature-matrix/features/git-branches-remotes.json +++ b/shared/platform-feature-matrix/features/git-branches-remotes.json @@ -20,7 +20,10 @@ "desktop/internal/workbench/gitlog.go", "desktop/internal/workbench/branch_delete.go", "desktop/internal/workbench/branch_delete_test.go", - "desktop/internal/core/gitbranch.go" + "desktop/internal/core/gitbranch.go", + "desktop/internal/workbench/branch_delete_visual_test.go", + "desktop/internal/core/gitbranch_test.go", + ".agents/notes/implemented/feature/2026-11-20-git-force-delete-confirmation.md" ] }, "windows": { @@ -40,11 +43,14 @@ "desktop/internal/workbench/gitlog.go", "desktop/internal/workbench/branch_delete.go", "desktop/internal/workbench/branch_delete_test.go", - "desktop/internal/core/gitbranch.go" + "desktop/internal/core/gitbranch.go", + "desktop/internal/workbench/branch_delete_visual_test.go", + "desktop/internal/core/gitbranch_test.go", + ".agents/notes/implemented/feature/2026-11-20-git-force-delete-confirmation.md" ] }, "owner": "Git", - "verification": "Git 菜单无头测试按 gfx.RoleMenuItem 筛选后再选择最深子菜单,覆盖 Linux/Windows 标题栏按钮处于更高层的情况;保留远程目录和分支行内容及排序的完整断言。macOS 引用列表和最近引用须保留 Core 的 peelsToCommit:提交标签可删除,指向树或 blob 的标签不可删除;历史与引用解码均覆盖,未知的合成分支引用不得假定提交资格。创建、切换、合并分支并查看标签和远程,确认冲突与认证失败可恢复。 macOS 悬停分支弹窗内被截断的行,确认沿原行位置展开完整分支名与 upstream,延续选中底色和行高;完整可见的行不展开,离开或打开动作菜单后展开层消失。滚动列表且鼠标位置不动时,高亮跟随当前鼠标下的行,离开的行清除 hover,不出现多行残留选中底色;已打开动作菜单的行仍保持高亮。顶部项目及分支按钮保持箭头光标,顶部当前分支不显示帮助浮层。 macOS 检查右侧真实上游列靠右显示、末尾省略且选中后沿用行文字颜色及普通字重;悬停直接显示沿原行展开的非激活子窗口,保留原行位置、选择底色、普通字重与高度,转交点击及滚轮,父弹窗关闭时清理,显示完整名称,不额外插入分组前缀,领先/落后提交数与 Git 一致(大于 99 显示 99+),无上游时不猜测远端。确认搜索框固定,其下操作项和全部分支分组共用一个滚动区,缩小弹窗时操作项也能滚出视口;拖动分支弹窗右边缘调整宽度、右上角/右下角无需先点击即分别使用东北—西南/西北—东南的斜向调整光标并调整宽高,固定另一侧边界,连续事件合并且不逐事件同步重绘,检查鼠标光标、内容刷新保留尺寸、关闭重开及重启后按项目恢复,切换项目互不覆盖,并检查屏幕边界及最小尺寸,普通菜单不出现拖动入口。 macOS 分支弹窗或 Git 已保存更改列表打开且鼠标悬停在被截断的行上时,反复切换到其他应用再切回、让窗口失焦/激活,应用不崩溃(issue #1277),悬停展开层仍只有一个且在布局完成后刷新;长分支列表快速滚动保持流畅,行内容、选中底色与展开层不丢失。 两端在仅抓取 preview、其他分支已有 remote/merge 配置和远端引用的仓库中确认上游名称与领先/落后计数仍可见,Recent 与 Local 一致,查询不修改 fetch 配置;同名远端但未设置跟踪时仍不显示上游。 Windows Git Log 普通 Fetch 和 Fetch 选项执行后保持当前页签,底部状态栏显示等待或真实阶段进度;连接等待、认证、多个远程切换不沿用旧百分比,成功、失败、取消和预检查失败均收起;Console 仍保留命令与输出。核对中英文、明暗主题与窄窗口。 Windows Git Log 普通 Checkout 不再二次确认,仍阻止覆盖本地修改;Update Selected 按跟踪分支配置启用,不依赖缓存 behind。当前分支后台 Merge,未检出分支原地快进,其他 worktree 内仅快进;不打开 Pull 弹窗,分叉/脏工作区保留本地内容并报告失败,仓库或工作区切换后迟到结果不得刷新或解锁新请求。 Windows Update Selected 在 Fetch 等待期间及预检后切换目标 worktree 的分支,或分离 HEAD,应返回 state-changed,不执行新分支的 Pull;Core 在执行前校验完整 expectedBranch,省略时保留兼容行为。 带 expectedBranch 的后台更新整合已 Fetch 的固定 upstream 提交,不再次执行 pull/fetch;验证 Merge、仅快进和 Rebase 策略,普通 Pull 省略字段时保持原行为。 Windows 顶部、Commit 和 Project 文件树由同一个仓库状态表生成展示;关闭 Commit 后外部 pull、checkout 和暂存仍刷新分支名、领先/落后及文件状态,已同步分支的 incoming 箭头消失。覆盖多仓库选择、根目录文件路径、快速切仓库/工作区与旧请求迟到,查询失败保留成功快照,草稿不丢失;元数据监听覆盖已发现仓库并在卸载时全部释放。真实 Windows 交互验收 pending。 两端 Fetch 后从其他分支及已处于目标本地分支时 Checkout Remote,确认 HEAD、本地分支和文件内容更新到所选已 Fetch 节点,重复操作成功且不生成合并提交。缺少本地分支时创建并配置跟踪;本地独有提交在切换或自动 stash 前被拒绝,Force 不丢弃提交;阻塞的工作区、暂存区、未跟踪文件和其他工作树占用保持原状态。Smart Checkout 更新后恢复本地修改,失败后界面刷新真实仓库状态;普通本地 Checkout 与 Checkout and Rebase 保持原行为。 Windows Git Log 的本地及远程 Checkout 成功后不再弹出成功提示(与 IDEA 一致,分支标签直接切换),失败时仍显示错误原因。 Windows Git Log 与分支切换器 Checkout 失败(例如目标分支已被其他 worktree 占用)时,右下角显示需手动关闭的 IDEA BalloonError 红色错误气泡,标题为“无法签出 {分支}”/“Could not checkout {branch}”,正文为去掉 fatal:/error: 前缀的 Git 输出;中英文、明暗主题下核对图标与换行。 macOS 分支弹窗和 Git Log 分支右键菜单中,有上游的未检出本地分支启用“更新”,原地快进且不切换 HEAD;本地有上游没有的提交时提示分叉、不强制更新;被其他 worktree 检出时提示到该 worktree 更新且不执行 Fetch;无上游的分支保持禁用;当前分支仍走原有拉取流程。在中文 Git 输出环境下核对提示。 macOS 分支弹窗按 Community 的 8pt 四边和角落沿边 16pt 规则命中;四边仅调整对应轴,四角同时调整两轴,反向边固定。水平/垂直使用 AppKit 双向光标,对角线直接使用 SDK JavaRuntimeSupport 的 javaResizeNE/NW/SE/SW,与 JBR 映射同源;检查原始图像、尺寸和热点一致。检查中央的搜索输入、滚动与分支点击不被边缘层拦截,移回中央释放调整光标,拖动中合并更新、松开才保存,内容刷新保持释放位置。 Windows Git Log 右键分支选择“新建分支”,弹窗对齐 IDEA 的 Create Branch from 对话框:标题为“从 {引用} 创建分支”,单行“分支名称”输入、创建/取消按钮,无 Checkout 与 Overwrite 选项,创建后固定检出新分支;初始名称本地分支沿用原名、远程分支去掉远程前缀,打开即全选,按一次退格即可清空;输入时空格转为连字符并丢弃非法字符且光标位置保持。打开及输入期间不做重名检测,点击创建后若名称为空,或与现有本地分支、远程分支、本地分支目录或 HEAD 冲突,才在输入框下方显示错误并禁用创建,此后错误随输入实时更新;创建按钮在前、取消按钮在后,创建为实心主色;Git 失败时错误显示在弹窗内且可重试,成功后不弹出提示,直接刷新历史。核对中英文与明暗主题。 Windows Git Log 右键本地分支选择“删除分支”不再弹出确认框,直接删除并在右下角弹出 IDEA 样式的通知(信息图标、粗体“已删除分支:”加分支名、下一行蓝色“恢复”文字链接、右上角关闭按钮,约 15 秒内有效,核对明暗主题与长分支名换行);点击后在原提交上重建该分支且不切换,原上游仍存在时恢复跟踪;分支重建成功但上游跟踪恢复失败时提示“分支已恢复,但上游跟踪恢复失败”,不得误报为整体失败,仍刷新历史。工作区切换后迟到的恢复不得刷新新工作区。分支未完全合并、被其他工作树占用等 Core 拒绝删除的情况显示 Git 给出的原因,不弹出恢复提示。远程分支和标签的删除保持原有确认。 Windows 所有右键菜单的弹出位置对齐 IDEA(Swing JPopupMenu):菜单左上角落在点击点,靠下或靠右放不下时整体平移回窗口内,不翻到光标上方或左侧;子菜单首行与父行对齐,右侧放不下时翻到左侧,纵向只平移。覆盖 Git Log 分支树、提交表、侧边栏、标签页、终端、文件树及通知/扩展/GitHub 等自绘菜单,并检查窗口很矮时菜单可滚动。 分支跟踪名称不同的远端分支(例如从 origin/main 新建分支后手动设置 upstream)时:Windows 推送弹窗必须先让用户在“发布到同名分支”和“推送到 upstream”之间选择,选择后弹窗展示的目标分支和提交列表与最终远端一致;“提交并推送”在写入提交前一次性询问所有异名仓库,取消后不产生提交;普通同名推送不出现任何询问。macOS 每次推送(分支列表与顶部分支弹窗)都先打开推送弹窗,顶部显示“本地分支 → 远端/分支”,左侧列出将推送的提交、右侧显示所选提交的改动文件,点击“推送”前不写远端;异名上游时“推送”保持禁用,直到在“发布到同名分支”和“推送到 upstream”之间选择,选择后目的地与提交列表随之更新,远端 main 不变;弹窗打开后仓库又有新提交时推送被拒绝并给出原因。macOS “提交并推送”始终先出审阅单列出每个仓库的目的地,异名仓库在审阅单内选择,未选择时“继续”不可用,取消后不产生提交。核对中英文、明暗主题与窄窗口。 macOS 指针停在被截断的分支行上时,用触控板双指滚动,确认列表持续跟随手势(含抬指后的惯性滚动),展开层在滚动时隐藏且手势结束后不残留;手指只放在触控板上不滚动时展开层保持显示。滚动中途手指停顿超过 1 秒再继续移动,确认列表仍跟随手势;原行滚出列表后手势不中断;滚动结束后点击同一位置,确认没有隐藏层拦截后续操作。 macOS 触控板滚动隐藏名称展开层后,立即在原位置左键/右键并拖动、松开,确认当前可见行收到完整操作,修饰键与点击次数不变,不触发滚走的旧行;滚动中按 Esc 关闭父弹窗后立即重开,确认隐藏层和回收任务已清理、无残留点击拦截。 新增(#1662 GIT-13/GIT-16):标签创建与删除统一走 Core 类型化 `git.write`,Windows 不再由宿主拼 `git tag`,标签目标必须是可解析的提交,删除产生 Core 的可恢复记录;显式 lightweight 标签不受 `tag.gpgSign` 影响,`signed` 生成签名标签,非法组合在启动 Git 前返回 `invalid_request`。新建分支名的 IDEA 清洗与冲突预检由 `git.branchNamePreview` 提供:两端输入时使用同一份 `typingCleanedName`、提交时使用 `cleanedName`,冲突码 `empty/head/clashesWithRemote/clashesWithDirectory/alreadyExists/clashesWithBranchPrefix` 与 IDEA 顺序一致;macOS 新建分支对话框显示 Core 清理后的名字和本地化冲突提示,Windows 对话框初始名来自 Core `initialName`。验证:在同一仓库分别用两端创建带空格、`..`、尾部 `.`、`.lock` 的分支名,确认最终分支名相同且冲突提示一致;在两端创建轻量/附注/签名标签并删除,确认轻量标签不受 `tag.gpgSign` 影响、删除后可恢复;用非提交对象作为标签目标时两端都在创建前得到稳定错误。 工作区与引用比较由 Core 合并未跟踪文件、去重并标注身份;两引用比较不包含工作区文件。共享 fixture、真实临时 Git 仓库及 macOS 服务回归覆盖,完整产品验收仍 pending。 Windows 的远程与标签列表改用 Core 结构化结果,附注标签的对象 ID 与解引用目标分别保留;同名分支不改变标签短名。真实仓库与类型适配回归覆盖,完整原生 UI 验收仍 pending。 分支 Update 与 Pull 的路由、本地改动/无上游/已最新拦截、分叉时是否询问以及默认策略统一由 Core `git.updatePlan` 决定:用户选择优先,其次 Git 的 `pull.rebase`/`pull.ff`,都没有时只允许 fast-forward;分叉历史两端都让用户选 Merge 或 Rebase(Windows 在 Pull 对话框里选),不再直接 merge;存在本地改动时两端都拒绝更新,前检失败时 macOS 不再继续执行。共享 fixture、Core 真实仓库配置回归及两端测试替身对拍覆盖,两端原生界面验收 pending。 Viva Git Log 菜单的 Fetch All、Fetch Options、Update Branch、Show Changes 已接入 Core git.write fetch/pull 与 pullPreflight:后台运行、状态行与取消、失败提示(认证失败给出配置凭据的指引)、完成后刷新日志与分支,分叉时询问合并或变基;真实本地 bare 仓库测试覆盖,原生界面验收 pending。Viva 状态行订阅 Core git.write 事件流中的 progressDetails,显示当前阶段名和该阶段百分比(进度条随阶段重置,不把单阶段百分比当整体进度),取消沿用同一按钮;Fetch Options 对话框打开时通过 git.executionInspect 只读取仓库 lithe.fetch.* 配置与应用默认值回显当前选项和实际标签行为,读取完成前不可提交,打开对话框不写任何文件;核对阶段进度、配置回显与不写文件的真实 bare 仓库测试覆盖,原生界面验收 pending。 两端 Git Log 本地分支右键“跟踪的分支”子菜单按 Core git.referenceTree 的远程分组逐级展开:每个远程以及分支名中每段“/”前缀各为一级子菜单,分支只显示最后一段,同级顺序与引用面板一致(分支在前、目录在后,自然排序);当前 upstream 仍以完整名称勾选显示在顶部并可停止跟踪;在任意层级选择分支后,upstream 设为该完整远程分支名。核对多个远程、多级目录(如 origin/codex/…)、目录很多时子菜单可滚动,以及窗口很矮时子菜单位置。 在 Git Log 选中分支/标签筛选历史后删除该分支或标签时,清除失效的日志筛选、分支面板选中状态与待比较引用;重命名当前筛选分支后将日志筛选同步更新为新分支名;外部删除当前筛选分支导致引用消失后,刷新日志自动回退为全部引用而不触发 `git.historyPage` `process_failed` 并清空分支树。无头回归 `TestLogNewAndDeleteBranchFromTheBranchesPane` 覆盖;原生三平台交互验收仍 pending。 两端在日志的分支面板右键远程分支选择“删除”,确认弹窗说明会从远程删除、所有人可见,删除后远程分支和本地远程跟踪分支都消失;用 macOS Cmd/Windows Ctrl 点选、Shift 区间选中多个本地与远程分支,选中行均显示选中底色,右键只出现“删除所选分支(N)”,工具栏删除按钮同样批量删除;HEAD、标签和当前分支被排除并在弹窗中说明数量,逐个尝试删除,部分失败时提示失败数和第一个失败原因,已删除的分支从列表移除且标记清空;普通点击清除标记,切换仓库或从别处切换所选引用后标记清空。", + "verification": "Git 菜单无头测试按 gfx.RoleMenuItem 筛选后再选择最深子菜单,覆盖 Linux/Windows 标题栏按钮处于更高层的情况;保留远程目录和分支行内容及排序的完整断言。macOS 引用列表和最近引用须保留 Core 的 peelsToCommit:提交标签可删除,指向树或 blob 的标签不可删除;历史与引用解码均覆盖,未知的合成分支引用不得假定提交资格。创建、切换、合并分支并查看标签和远程,确认冲突与认证失败可恢复。 macOS 悬停分支弹窗内被截断的行,确认沿原行位置展开完整分支名与 upstream,延续选中底色和行高;完整可见的行不展开,离开或打开动作菜单后展开层消失。滚动列表且鼠标位置不动时,高亮跟随当前鼠标下的行,离开的行清除 hover,不出现多行残留选中底色;已打开动作菜单的行仍保持高亮。顶部项目及分支按钮保持箭头光标,顶部当前分支不显示帮助浮层。 macOS 检查右侧真实上游列靠右显示、末尾省略且选中后沿用行文字颜色及普通字重;悬停直接显示沿原行展开的非激活子窗口,保留原行位置、选择底色、普通字重与高度,转交点击及滚轮,父弹窗关闭时清理,显示完整名称,不额外插入分组前缀,领先/落后提交数与 Git 一致(大于 99 显示 99+),无上游时不猜测远端。确认搜索框固定,其下操作项和全部分支分组共用一个滚动区,缩小弹窗时操作项也能滚出视口;拖动分支弹窗右边缘调整宽度、右上角/右下角无需先点击即分别使用东北—西南/西北—东南的斜向调整光标并调整宽高,固定另一侧边界,连续事件合并且不逐事件同步重绘,检查鼠标光标、内容刷新保留尺寸、关闭重开及重启后按项目恢复,切换项目互不覆盖,并检查屏幕边界及最小尺寸,普通菜单不出现拖动入口。 macOS 分支弹窗或 Git 已保存更改列表打开且鼠标悬停在被截断的行上时,反复切换到其他应用再切回、让窗口失焦/激活,应用不崩溃(issue #1277),悬停展开层仍只有一个且在布局完成后刷新;长分支列表快速滚动保持流畅,行内容、选中底色与展开层不丢失。 两端在仅抓取 preview、其他分支已有 remote/merge 配置和远端引用的仓库中确认上游名称与领先/落后计数仍可见,Recent 与 Local 一致,查询不修改 fetch 配置;同名远端但未设置跟踪时仍不显示上游。 Windows Git Log 普通 Fetch 和 Fetch 选项执行后保持当前页签,底部状态栏显示等待或真实阶段进度;连接等待、认证、多个远程切换不沿用旧百分比,成功、失败、取消和预检查失败均收起;Console 仍保留命令与输出。核对中英文、明暗主题与窄窗口。 Windows Git Log 普通 Checkout 不再二次确认,仍阻止覆盖本地修改;Update Selected 按跟踪分支配置启用,不依赖缓存 behind。当前分支后台 Merge,未检出分支原地快进,其他 worktree 内仅快进;不打开 Pull 弹窗,分叉/脏工作区保留本地内容并报告失败,仓库或工作区切换后迟到结果不得刷新或解锁新请求。 Windows Update Selected 在 Fetch 等待期间及预检后切换目标 worktree 的分支,或分离 HEAD,应返回 state-changed,不执行新分支的 Pull;Core 在执行前校验完整 expectedBranch,省略时保留兼容行为。 带 expectedBranch 的后台更新整合已 Fetch 的固定 upstream 提交,不再次执行 pull/fetch;验证 Merge、仅快进和 Rebase 策略,普通 Pull 省略字段时保持原行为。 Windows 顶部、Commit 和 Project 文件树由同一个仓库状态表生成展示;关闭 Commit 后外部 pull、checkout 和暂存仍刷新分支名、领先/落后及文件状态,已同步分支的 incoming 箭头消失。覆盖多仓库选择、根目录文件路径、快速切仓库/工作区与旧请求迟到,查询失败保留成功快照,草稿不丢失;元数据监听覆盖已发现仓库并在卸载时全部释放。真实 Windows 交互验收 pending。 两端 Fetch 后从其他分支及已处于目标本地分支时 Checkout Remote,确认 HEAD、本地分支和文件内容更新到所选已 Fetch 节点,重复操作成功且不生成合并提交。缺少本地分支时创建并配置跟踪;本地独有提交在切换或自动 stash 前被拒绝,Force 不丢弃提交;阻塞的工作区、暂存区、未跟踪文件和其他工作树占用保持原状态。Smart Checkout 更新后恢复本地修改,失败后界面刷新真实仓库状态;普通本地 Checkout 与 Checkout and Rebase 保持原行为。 Windows Git Log 的本地及远程 Checkout 成功后不再弹出成功提示(与 IDEA 一致,分支标签直接切换),失败时仍显示错误原因。 Windows Git Log 与分支切换器 Checkout 失败(例如目标分支已被其他 worktree 占用)时,右下角显示需手动关闭的 IDEA BalloonError 红色错误气泡,标题为“无法签出 {分支}”/“Could not checkout {branch}”,正文为去掉 fatal:/error: 前缀的 Git 输出;中英文、明暗主题下核对图标与换行。 macOS 分支弹窗和 Git Log 分支右键菜单中,有上游的未检出本地分支启用“更新”,原地快进且不切换 HEAD;本地有上游没有的提交时提示分叉、不强制更新;被其他 worktree 检出时提示到该 worktree 更新且不执行 Fetch;无上游的分支保持禁用;当前分支仍走原有拉取流程。在中文 Git 输出环境下核对提示。 macOS 分支弹窗按 Community 的 8pt 四边和角落沿边 16pt 规则命中;四边仅调整对应轴,四角同时调整两轴,反向边固定。水平/垂直使用 AppKit 双向光标,对角线直接使用 SDK JavaRuntimeSupport 的 javaResizeNE/NW/SE/SW,与 JBR 映射同源;检查原始图像、尺寸和热点一致。检查中央的搜索输入、滚动与分支点击不被边缘层拦截,移回中央释放调整光标,拖动中合并更新、松开才保存,内容刷新保持释放位置。 Windows Git Log 右键分支选择“新建分支”,弹窗对齐 IDEA 的 Create Branch from 对话框:标题为“从 {引用} 创建分支”,单行“分支名称”输入、创建/取消按钮,无 Checkout 与 Overwrite 选项,创建后固定检出新分支;初始名称本地分支沿用原名、远程分支去掉远程前缀,打开即全选,按一次退格即可清空;输入时空格转为连字符并丢弃非法字符且光标位置保持。打开及输入期间不做重名检测,点击创建后若名称为空,或与现有本地分支、远程分支、本地分支目录或 HEAD 冲突,才在输入框下方显示错误并禁用创建,此后错误随输入实时更新;创建按钮在前、取消按钮在后,创建为实心主色;Git 失败时错误显示在弹窗内且可重试,成功后不弹出提示,直接刷新历史。核对中英文与明暗主题。 Windows Git Log 右键本地分支选择“删除分支”不再弹出确认框,直接删除并在右下角弹出 IDEA 样式的通知(信息图标、粗体“已删除分支:”加分支名、下一行蓝色“恢复”文字链接、右上角关闭按钮,约 15 秒内有效,核对明暗主题与长分支名换行);点击后在原提交上重建该分支且不切换,原上游仍存在时恢复跟踪;分支重建成功但上游跟踪恢复失败时提示“分支已恢复,但上游跟踪恢复失败”,不得误报为整体失败,仍刷新历史。工作区切换后迟到的恢复不得刷新新工作区。分支未完全合并、被其他工作树占用等 Core 拒绝删除的情况显示 Git 给出的原因,不弹出恢复提示。远程分支和标签的删除保持原有确认。 Windows 所有右键菜单的弹出位置对齐 IDEA(Swing JPopupMenu):菜单左上角落在点击点,靠下或靠右放不下时整体平移回窗口内,不翻到光标上方或左侧;子菜单首行与父行对齐,右侧放不下时翻到左侧,纵向只平移。覆盖 Git Log 分支树、提交表、侧边栏、标签页、终端、文件树及通知/扩展/GitHub 等自绘菜单,并检查窗口很矮时菜单可滚动。 分支跟踪名称不同的远端分支(例如从 origin/main 新建分支后手动设置 upstream)时:Windows 推送弹窗必须先让用户在“发布到同名分支”和“推送到 upstream”之间选择,选择后弹窗展示的目标分支和提交列表与最终远端一致;“提交并推送”在写入提交前一次性询问所有异名仓库,取消后不产生提交;普通同名推送不出现任何询问。macOS 每次推送(分支列表与顶部分支弹窗)都先打开推送弹窗,顶部显示“本地分支 → 远端/分支”,左侧列出将推送的提交、右侧显示所选提交的改动文件,点击“推送”前不写远端;异名上游时“推送”保持禁用,直到在“发布到同名分支”和“推送到 upstream”之间选择,选择后目的地与提交列表随之更新,远端 main 不变;弹窗打开后仓库又有新提交时推送被拒绝并给出原因。macOS “提交并推送”始终先出审阅单列出每个仓库的目的地,异名仓库在审阅单内选择,未选择时“继续”不可用,取消后不产生提交。核对中英文、明暗主题与窄窗口。 macOS 指针停在被截断的分支行上时,用触控板双指滚动,确认列表持续跟随手势(含抬指后的惯性滚动),展开层在滚动时隐藏且手势结束后不残留;手指只放在触控板上不滚动时展开层保持显示。滚动中途手指停顿超过 1 秒再继续移动,确认列表仍跟随手势;原行滚出列表后手势不中断;滚动结束后点击同一位置,确认没有隐藏层拦截后续操作。 macOS 触控板滚动隐藏名称展开层后,立即在原位置左键/右键并拖动、松开,确认当前可见行收到完整操作,修饰键与点击次数不变,不触发滚走的旧行;滚动中按 Esc 关闭父弹窗后立即重开,确认隐藏层和回收任务已清理、无残留点击拦截。 新增(#1662 GIT-13/GIT-16):标签创建与删除统一走 Core 类型化 `git.write`,Windows 不再由宿主拼 `git tag`,标签目标必须是可解析的提交,删除产生 Core 的可恢复记录;显式 lightweight 标签不受 `tag.gpgSign` 影响,`signed` 生成签名标签,非法组合在启动 Git 前返回 `invalid_request`。新建分支名的 IDEA 清洗与冲突预检由 `git.branchNamePreview` 提供:两端输入时使用同一份 `typingCleanedName`、提交时使用 `cleanedName`,冲突码 `empty/head/clashesWithRemote/clashesWithDirectory/alreadyExists/clashesWithBranchPrefix` 与 IDEA 顺序一致;macOS 新建分支对话框显示 Core 清理后的名字和本地化冲突提示,Windows 对话框初始名来自 Core `initialName`。验证:在同一仓库分别用两端创建带空格、`..`、尾部 `.`、`.lock` 的分支名,确认最终分支名相同且冲突提示一致;在两端创建轻量/附注/签名标签并删除,确认轻量标签不受 `tag.gpgSign` 影响、删除后可恢复;用非提交对象作为标签目标时两端都在创建前得到稳定错误。 工作区与引用比较由 Core 合并未跟踪文件、去重并标注身份;两引用比较不包含工作区文件。共享 fixture、真实临时 Git 仓库及 macOS 服务回归覆盖,完整产品验收仍 pending。 Windows 的远程与标签列表改用 Core 结构化结果,附注标签的对象 ID 与解引用目标分别保留;同名分支不改变标签短名。真实仓库与类型适配回归覆盖,完整原生 UI 验收仍 pending。 分支 Update 与 Pull 的路由、本地改动/无上游/已最新拦截、分叉时是否询问以及默认策略统一由 Core `git.updatePlan` 决定:用户选择优先,其次 Git 的 `pull.rebase`/`pull.ff`,都没有时只允许 fast-forward;分叉历史两端都让用户选 Merge 或 Rebase(Windows 在 Pull 对话框里选),不再直接 merge;存在本地改动时两端都拒绝更新,前检失败时 macOS 不再继续执行。共享 fixture、Core 真实仓库配置回归及两端测试替身对拍覆盖,两端原生界面验收 pending。 Viva Git Log 菜单的 Fetch All、Fetch Options、Update Branch、Show Changes 已接入 Core git.write fetch/pull 与 pullPreflight:后台运行、状态行与取消、失败提示(认证失败给出配置凭据的指引)、完成后刷新日志与分支,分叉时询问合并或变基;真实本地 bare 仓库测试覆盖,原生界面验收 pending。Viva 状态行订阅 Core git.write 事件流中的 progressDetails,显示当前阶段名和该阶段百分比(进度条随阶段重置,不把单阶段百分比当整体进度),取消沿用同一按钮;Fetch Options 对话框打开时通过 git.executionInspect 只读取仓库 lithe.fetch.* 配置与应用默认值回显当前选项和实际标签行为,读取完成前不可提交,打开对话框不写任何文件;核对阶段进度、配置回显与不写文件的真实 bare 仓库测试覆盖,原生界面验收 pending。 两端 Git Log 本地分支右键“跟踪的分支”子菜单按 Core git.referenceTree 的远程分组逐级展开:每个远程以及分支名中每段“/”前缀各为一级子菜单,分支只显示最后一段,同级顺序与引用面板一致(分支在前、目录在后,自然排序);当前 upstream 仍以完整名称勾选显示在顶部并可停止跟踪;在任意层级选择分支后,upstream 设为该完整远程分支名。核对多个远程、多级目录(如 origin/codex/…)、目录很多时子菜单可滚动,以及窗口很矮时子菜单位置。 在 Git Log 选中分支/标签筛选历史后删除该分支或标签时,清除失效的日志筛选、分支面板选中状态与待比较引用;重命名当前筛选分支后将日志筛选同步更新为新分支名;外部删除当前筛选分支导致引用消失后,刷新日志自动回退为全部引用而不触发 `git.historyPage` `process_failed` 并清空分支树。无头回归 `TestLogNewAndDeleteBranchFromTheBranchesPane` 覆盖;原生三平台交互验收仍 pending。 两端在日志的分支面板右键远程分支选择“删除”,确认弹窗说明会从远程删除、所有人可见,删除后远程分支和本地远程跟踪分支都消失;用 macOS Cmd/Windows Ctrl 点选、Shift 区间选中多个本地与远程分支,选中行均显示选中底色,右键只出现“删除所选分支(N)”,工具栏删除按钮同样批量删除;HEAD、标签和当前分支被排除并在弹窗中说明数量,逐个尝试删除,部分失败时提示失败数和第一个失败原因,已删除的分支从列表移除且标记清空;普通点击清除标记,切换仓库或从别处切换所选引用后标记清空。 本地分支普通删除保持合并检查;Core 返回结构化未合并原因后,仅列出失败的未合并分支,点击“强制删除…”只打开独立的二次确认,显示未合并提交可能失去引用的警告;默认焦点为取消,Enter、Esc 和关闭均不执行强制删除。仅点击“确认强制删除”才携带已审阅的完整提交 ID 强制删除;确认期间分支变更时拒绝,当前分支和其他 worktree 占用仍受保护。批量删除中已成功的分支不重复处理,远程和其他原因的失败不进入强制重试;核对中英文、明暗主题、列表滚动、切换仓库与迟到结果。真实 Git 和 Viva 无头回归覆盖;原生 macOS/Windows 交互验收 pending。 混合批量结果保留每个原始分支:成功项正常显示,未合并和其他失败项名称标红,悬停显示各自原因;强制确认只列未合并项,结束后仍保留远程等失败。先普通点击 A 后 Cmd/Ctrl 点击 B 必须保留两项,再次修饰键点击可取消单项。", "notes": "Viva 客户端尚未逐项盘点;legacy 是迁移前基线,不代表当前实现。", "legacy": { "revision": "5a54c41aa37a4e6e6b68918a4b05765b9dd07a36", diff --git a/shared/platform-feature-matrix/features/workspace-tree-batch-files.json b/shared/platform-feature-matrix/features/workspace-tree-batch-files.json index 434f2dce9..b7ac4752c 100644 --- a/shared/platform-feature-matrix/features/workspace-tree-batch-files.json +++ b/shared/platform-feature-matrix/features/workspace-tree-batch-files.json @@ -9,7 +9,10 @@ "evidence": [ "desktop/internal/workbench/filetree_menu.go", "desktop/internal/workbench/filetree.go", - "desktop/internal/workbench/filetree_batch.go" + "desktop/internal/workbench/filetree_batch.go", + "desktop/internal/workbench/filetree_view.go", + "desktop/internal/workbench/filetree_test.go", + "desktop/internal/workbench/branch_delete_visual_test.go" ] }, "windows": { @@ -21,11 +24,14 @@ "desktop/internal/workbench/filetree_batch.go", "desktop/internal/workbench/filetree_duplicate.go", "desktop/internal/workbench/hide_console_windows.go", - "desktop/internal/workbench/filetree_trash_windows_test.go" + "desktop/internal/workbench/filetree_trash_windows_test.go", + "desktop/internal/workbench/filetree_view.go", + "desktop/internal/workbench/filetree_test.go", + "desktop/internal/workbench/branch_delete_visual_test.go" ] }, "owner": "Workspace", - "verification": "macOS:单击目录名称只选中本行,箭头展开/折叠,子项不继承高亮;⌘ 点击增减独立选择,Shift 正反向选择,Control 点击右键、右键未选中子项只作用于该行;⌘A 仍选择焦点项同级。拖动已选项携带整组,拖动未选项只携带该项,目录整体移动,父子去重;同窗口项目目录接收拖放,项目根不能移动,同目录无操作,同名整批拒绝,目录移入自身/后代和符号链接越界拒绝;中途失败报告已完成数量、保留剩余源项,切换工作区停止后续项。确认未保存文件保护、成功移动后打开文档路径/历史/目录标记更新;外部拖放仍提供文件 URL。大目录分别测量选择、展开和滚动,懒加载行应能滚动到末尾,折叠与定位保持正确。保留复制/粘贴/副本/废纸篓、快捷键焦点和双击可执行文件回归。Windows 尚无该多选入口;macOS 实机事件、性能及 Swift 测试需在目标平台验证。 Windows:TestTrashCommandStartsWithoutAConsoleAndKeepsItsDialogsVisible 检查回收站命令以 CREATE_NO_WINDOW 启动且不设 HideWindow;实机移到回收站不再闪出终端窗口,删除被其他程序占用的文件时系统错误框仍然可见(#2068)。", + "verification": "macOS:单击目录名称只选中本行,箭头展开/折叠,子项不继承高亮;⌘ 点击增减独立选择,Shift 正反向选择,Control 点击右键、右键未选中子项只作用于该行;⌘A 仍选择焦点项同级。拖动已选项携带整组,拖动未选项只携带该项,目录整体移动,父子去重;同窗口项目目录接收拖放,项目根不能移动,同目录无操作,同名整批拒绝,目录移入自身/后代和符号链接越界拒绝;中途失败报告已完成数量、保留剩余源项,切换工作区停止后续项。确认未保存文件保护、成功移动后打开文档路径/历史/目录标记更新;外部拖放仍提供文件 URL。大目录分别测量选择、展开和滚动,懒加载行应能滚动到末尾,折叠与定位保持正确。保留复制/粘贴/副本/废纸篓、快捷键焦点和双击可执行文件回归。Windows 尚无该多选入口;macOS 实机事件、性能及 Swift 测试需在目标平台验证。 Windows:TestTrashCommandStartsWithoutAConsoleAndKeepsItsDialogsVisible 检查回收站命令以 CREATE_NO_WINDOW 启动且不设 HideWindow;实机移到回收站不再闪出终端窗口,删除被其他程序占用的文件时系统错误框仍然可见(#2068)。 Viva 两端用平台主修饰键增减多选(macOS Command,Windows Control):先普通点击 A,再修饰键点击 B,A/B 都保留选中底色;再次点击 A 只取消 A,普通点击 C 恢复单选,Shift 范围与键盘方向导航保持正确。Core fixture 和 macOS 真实鼠标无头测试覆盖,明暗主题截图可检查;Windows 原生交互未执行,验证状态保持 pending。", "legacy": { "revision": "5a54c41aa37a4e6e6b68918a4b05765b9dd07a36", "macos": {