Repository navigation
fork 強化:降低上游 rebase 衝突與功能悄悄壞掉的風險 - #3
Merged
Merged
Conversation
…效 git owner 會重算 relativePath - 新增 getOpenFileGitRelativePath:有 gitWorktreeId 時從 filePath 與 repo worktree 根推導路徑,不再依賴 relativePath 的相對基準 - 讀檔(含遠端 repo selector)、diff、衝突狀態對帳、外部變更 banner/比較、還原衝突掃描、autosave 比對、分頁 git 狀態標記改用推導路徑 - 還原 session 時 git owner 已不存在,relativePath 改為相對 folder 根,避免遠端以 folder selector 讀到錯的檔 - resolveTabOwnerRelativePath 搬到 open-file-git-owner.ts 供還原共用
沒有 missingSides 的 host 讀失敗只回 '',會被當合法空檔複製,之後 Paste & Restore 會清空真檔。 兩側皆空且無 missingSides 時視為 unreadable;新 host 的真空檔(帶 missingSides 或原側非空)照常複製。
涵蓋 RPC/zod/RuntimeGitDiffCommands/provider、IPC git:diff、renderer 本機與遠端 client、web preload; 任一段丟掉 skipRenderLimit 或 graph 都會轉紅。順手移除 git-diff-skip-render-limit.test 的過期 companion 註解。
…edRepos 的測試 options 是 z.unknown(),schema 或 handler 任一段丟掉欄位原本沒有測試會紅。
getDiff 維持兩側都在時省略 missingSides(上游 status-diff 測試以 toEqual 釘住該形狀), staged 複製仍沿用舊 host 判斷:空檔只改權限會被略過並計數,換取不把讀取失敗當成空內容。
… git owner,不再沿用相對 repo 路徑讀錯檔
audichuang
force-pushed
the
feat/fork-hardening
branch
from
October 18, 2026 22:41
2d82052 to
1eb07b7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
把 fork 自己的功能弄得更耐得住上游改版:以後 rebase 到新的上游 release 時,比較不會出現衝突,也比較不會出現「rebase 乾淨、測試全綠,但功能其實已經壞掉」的情況。
What Changed
make fork-check更難被繞過:fork 改到的上游檔案,只要沒有測試涵蓋,gate 就直接失敗並列出檔案。同時補上原本漏掉的測試路徑(updater、workspace-session、src/main/git/status等)。missingSides: [],所以空檔只改權限不會被誤判成讀取失敗。skipRenderLimit的 9 個傳遞點、history graph 的遠端路徑、descendIntoRepos經過 IPC 的那一段。每一個都做過 mutation 驗證,拿掉後測試會紅。typecheck:e2e不放進 gate(上游 release tag 自己就過不了)。Why
三個審查 agent 先找出風險:把 fork 實際 rebase 到上游
origin/main演練、對接縫做 mutation 測試、做程式正確性審查。最大的風險是 fork 的「相對路徑相對 repo」約定和上游即將推出的約定相反。這裡選擇在 consumer 端從絕對路徑推算,而不是一次翻轉約定:翻轉會改到 tab id、需要遷移舊 session,也會讓這個 PR 變得很大,所以另開 PR。getDiff刻意不改成一律回傳missingSides,因為上游的status-diff.test.ts用toEqual釘住了它的回傳形狀。Linked Issue
N/A(fork 內部強化)
Visual Proof
N/A:沒有 UI 改動,行為差異都在邊界情況,由測試涵蓋。
Testing
make fork-check的測試集:24229 個測試通過;changed-code 品質閘門通過。web、cli、process-host 的型別檢查在本機通過。
tsconfig.node.json因為本機 agent 環境每個行程限 4GB 跑不完,交給這個 PR 的 CI 驗證。每個新增的測試都確認過:在沒修的程式上會紅,修完轉綠。
經過 Codex 三輪 adversarial review,最後一輪 approve。
沒有在真實的 SSH 或 runtime 環境端到端測試。
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Notes
已知未處理,留給後續 PR:路徑約定翻轉成相對 folder(上游的
restored-editor-same-workspace-reown測試在 rebase 後仍會紅,fork-check會擋下)、markdown 預覽會丟掉gitWorktreeId、側邊欄「隱藏 repo」的範圍問題。另外src/renderer/src/lib/editor-file-operation-owner.ts:196存檔時只用 id 取第一個 folder,跨主機時可能寫錯路徑:這是上游的程式碼,fork 沒動過。