refactor: UnresolvedWikilink に displayPath field を追加 (#253)#254
Merged
Conversation
- IPC 境界 type に UnresolvedWikilinkReference extends WikilinkReference { displayPath: string } を追加
- scanUnresolvedWikilinksImpl で file 単位 hoist で displayPath を 1 度だけ算出 (PR #252 BacklinkSource と同 pattern)
- UnresolvedLinksPanel の per-render toRelativePath 計算を削除し reference.displayPath を直接読み
- e2e mock の displayPath 計算 (scanUnresolvedWikilinks / scanBacklinks の 2 箇所) を mockDisplayPath helper に集約 (/simplify Reuse 採用)
- test mock 1 site に displayPath 追加
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
概要
PR #252 (BacklinkSource に displayName / displayPath 追加) の波及。
UnresolvedWikilink.referencesの各要素にdisplayPathfield を追加し、UnresolvedLinksPanel.tsxの毎-rendertoRelativePath計算を scan-time に hoist。合わせて
/simplifyReuse 角度の採用として、e2e mock のwsPrefix+ slice 計算 (本 PR の scanUnresolvedWikilinks 側 + 既存 scanBacklinks 側) をmockDisplayPathhelper に集約 (2 箇所重複解消)。関連 Issue
closes #253
移行 Stage
本 PR は migration plan の Stage とは独立 (Stage 6 完了後の継続改善)。
変更内容
src/types/wikilink.ts:UnresolvedWikilinkReference extends WikilinkReference { displayPath: string }を追加、UnresolvedWikilink.referencesの型を更新electron/main/ipc/search.ts:scanUnresolvedWikilinksImplで file 単位 hoist でdisplayPath = toDisplayPath(workspacePath, inFiles[idx])を 1 度算出し、callback push 時に{ ...ref, displayPath }でUnresolvedWikilinkReferenceを構築。map 型をMap<string, UnresolvedWikilinkReference[]>に更新src/components/search/UnresolvedLinksPanel.tsx:toRelativePathimport 削除、per-renderrelativePath計算削除、reference.displayPathを直接読み (return → 直接 JSX 構文に変換)e2e/helpers/electron-api-mock.ts:installApiMock内 helper としてmockDisplayPath(workspacePath, absolutePath)を追加 (本番toDisplayPathと同等を/区切り前提で再現)。scanUnresolvedWikilinks/scanBacklinksの inlinewsPrefix+startsWith/slice計算 2 箇所を helper 呼び出しに統一src/stores/wikilink.test.ts: mockLinks の reference にdisplayPath: "note.md"を追加 (1 site)設計判断: Option B (UnresolvedWikilinkReference 専用型)
検討した Option A (
WikilinkReference自体にdisplayPathを common 追加) と Option B (本採用:UnresolvedWikilinkReference extends WikilinkReference { displayPath: string }新型) の比較:BacklinkSource.references[i].displayPathが source.displayPath と redundant (常に sourceFile == reference.filePath なので)/code-review low
(none)— production hunk 3 file (wikilink.ts型追加 /search.tsの file 単位 hoist + spread copy /UnresolvedLinksPanel.tsxの per-render 計算削除) に runtime correctness bug / duplicate / dead code 該当なし。/simplify pass 1
wsPrefix+ slice 計算が scanBacklinks 側 (PR refactor: BacklinkSource に displayName / displayPath field を追加 (#239) #252 で導入) と identical pattern だったためmockDisplayPathhelper に集約 (本 PR scanUnresolvedWikilinks 側 + 既存 scanBacklinks 側、2 箇所重複解消)動作確認
pnpm test(unit): 2230 pass / 2 skipped ✅tsc --noEmit -p tsconfig.web.json: clean ✅tsc --noEmit -p tsconfig.node.json: clean ✅tsc --noEmit -p tsconfig.e2e.json: clean ✅biome check: 変更 5 file clean ✅ (既存のrecommendeddeprecated info / version mismatch info は本 PR と無関係)スクリーンショット
UI の見た目は変わらない (per-render
toRelativePath()の結果 =reference.displayPathで表示文字列同等)。再 render 時の string allocation だけが削減される。