GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: 折りたたみ中に外部変更を取りこぼしたフォルダを再展開時に取り直す by ymnao · Pull Request #610 · ymnao/scripta

Conversation

@ymnao

@ymnao ymnao commented Oct 6, 2026

Copy link
Copy Markdown
Owner

概要

FileTree で、一度展開してから閉じたフォルダが、閉じている間に外部で作成・削除されたファイルを開き直しても反映しない不具合を直す。あわせて、レビューで見つかった「再取得中に閉じると古い一覧が残る」経路も塞ぐ。

関連 Issue

なし(HANDOFF の候補「Fable レビュー Medium #6: FileTree の listDirectory 再発行」を調べる中で見つけた不具合。#6 の性能面は、modify だけのバッチでも refresh が要る(dir↔file の置き換えが modify に畳まれる)ことと、コストが自動保存 2 秒に 1 回程度であることから、user 判断で見送った)

移行 Stage

  • Stage 0: 雛形 + フロント表示確認
  • Stage 1: ファイル I/O
  • Stage 2: ワークスペース・ファイルツリー・ファイル監視
  • Stage 3: 全文検索(ripgrep sidecar)
  • Stage 4: Git Sync
  • Stage 5: OGP / PDF / アップデート
  • Stage 6: 仕上げ・配布・切り替え

変更内容

  • FileTreeItem の refresh effect(watcher バッチごとに進む refreshKey で走る):
    • 閉じている読み込み済みフォルダは loaded=false に戻す。クリック(キーボードの ArrowRight / Enter / Space もクリック経由)・作成時の自動展開・ドラッグ時の自動展開は、どれも既存の !loaded → loadChildren() 分岐を通るので、次に開いたときに取り直す。描画は expanded && loaded でしか loaded を見ないので、閉じている間は表示に影響しない
    • 再取得の結果を effect cleanup で捨てない。cleanup は「取得中に閉じた」ときにも走り、新しい結果を捨てて loaded=true のまま古い一覧を残していた(main からある挙動)。代わりに fetchIdRef で「最後に発行した取得だけが勝つ」ようにし、loadChildren と refresh の両方で id を進める(FileTree の loadIdRef と同じ形)。unmount は既存の isMountedRef で弾く
  • FileTree.test.tsx に回帰 test を 4 本追加:
    • 閉じている間に refresh があったら、再展開で取り直す
    • 取り直した後の、変化の無い再展開では listDirectory を再発行しない(呼び出し回数で pin)
    • 閉じた後に解決した再取得の結果を捨てない
    • 古い再取得の結果が、再展開で取った新しい結果を上書きしない

コミット 43a2076 の本文にある「折りたたみ中に着地した結果は無害」は、ae49093 で塞いだ経路では成り立たなかった(squash merge なので PR 本文の記述を正とする)。

動作確認

  • vitest run 全件: 3282 passed / 18 skipped
  • 追加した各 test の mutation 検証(下のエビデンス参照)
  • 実機での確認は未実施(挙動は unit test で観測している)
検証エビデンス

リスク分類

tier: medium — reasons なし(classify-risk.sh の出力 {"tier": "medium", "reasons": []})

実行した検証

種別 コマンド 結果
テスト ./node_modules/.bin/vitest run PASS — 142 files passed / 1 skipped、3282 passed / 18 skipped
テスト ./node_modules/.bin/vitest run src/components/filetree PASS — 40 passed
Mutation setLoaded(false) を削除 KILL — 追加 test 2 本が fail
Mutation refresh effect に「cleanup で id を進める」を再導入 KILL — 「閉じた後に解決した結果を捨てない」が fail
Mutation loadChildren の fetchIdRef.current++ を削除 KILL — 「古い結果が上書きしない」が fail
Lint ./node_modules/.bin/biome check src/components/filetree No fixes applied
型 ./node_modules/.bin/tsc --noEmit -p tsconfig.web.json PASS
e2e pnpm test:e2e / pnpm test:e2e:electron 未実施(sandbox では listen できないため CI で確認)
レビュー /simplify(Fable × 4 観点) 指摘 1 件を適用(stale state → loaded のリセット。Reuse / Simplification が同じ結論)
レビュー code-reviewer(Fable)round 1 Warning 1 件を fix(43a2076)/ Suggestion 4 件は Tier3
レビュー code-reviewer(Fable)round 2 Warning 1 件を fix(ae49093。round 1 の fix で開いた経路)/ Suggestion 1 件は Tier3
レビュー codex-review security PASS(0 findings)

レビュー指摘と対応

# 出所 指摘 対応
1 /simplify Reuse・Simplification stale state は閉じている間の setLoaded(false) で表せる 修正済み(5275032)
2 code-reviewer round 1 Warning 再取得中に閉じると cleanup が結果を捨て、古い一覧が残る 修正済み(43a2076)
3 code-reviewer round 2 Warning #2 の修正後、古い refresh の結果が再展開時の loadChildren の結果を上書きできる 修正済み(ae49093)
4 codex-review security — PASS

追跡先

backlog delta: 起票 0 件 / 本 PR で close 0 件 / 現在 open 5 件

なし

Draft 判定

  • 判定: normal
  • 根拠: step 4 — fix していない Tier1 / Tier2 の finding は無く、(b) / (c) の候補も無い

🤖 Generated with Claude Code

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
ymnao and others added 4 commits October 6, 2026 22:21
@ymnao @claude
fix: 折りたたみ中に refresh を取りこぼしたフォルダを再展開時に取り直す
3985b03
- FileTreeItem の refresh effect は展開中のフォルダしか再取得せず、再展開時も loaded なら取り直さなかった
- そのため、一度開いて閉じたフォルダは、閉じている間の外部 create / delete が開き直しても反映されなかった
- 閉じている間に refreshKey が進んだら stale を立て、クリック / 作成時の自動展開 / ドラッグ時の自動展開で取り直す
- 取り直し後は stale を下ろし、変化の無い再展開では listDirectory を再発行しない(呼び出し回数で pin)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymnao @claude
refactor: 折りたたみ中の取りこぼしを stale state ではなく loaded のリセットで表す
5275032
- /simplify の Reuse / Simplification 観点が同じ簡約に収束したため適用
- 閉じている間の refresh で loaded を false に戻せば、クリック / 作成時 / ドラッグ時の 3 経路は既存の !loaded 分岐でそのまま取り直す
- loaded を描画で読むのは expanded && loaded だけなので、閉じている間に false にしても表示は変わらない
- stale state・3 経路の条件追加・deps 追加が不要になる。追加した 2 本の test は無変更で pass し、setLoaded(false) を外す mutant で両方 fail する

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymnao @claude
fix: 再取得中に折りたたんだフォルダの結果を捨てない
43a2076
- code-reviewer の Warning: 展開中フォルダの refresh 用 listDirectory が in-flight の間に折りたたむと、effect cleanup の ignore で結果が捨てられ loaded=true のまま古い children が残った。次の再展開は取り直さない
- 本 PR が直した「折りたたみ中の取りこぼし」と同じ症状なので、cleanup ではなく id で最新の取得だけを採用する形にした (FileTree の loadIdRef と同じ)
- 折りたたみ中に着地した結果は非表示の children に入るだけで無害。unmount は既存の isMountedRef で弾く
- 回帰 test を追加。cleanup で id を進める mutant で fail する

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymnao @claude
fix: 古い refresh の結果が再展開時の取得結果を上書きしないようにする
ae49093
- code-reviewer round 2 の Warning: 前コミットで cleanup の破棄を外したため、展開中に始まった refresh fetch が「折りたたみ → 再 bump → 再展開」で走った loadChildren の結果を後から上書きできるようになっていた (完了順は withRetry の backoff 等で逆転しうる)
- 前コミット本文の「折りたたみ中に着地した結果は無害」はこの経路では成り立たなかった
- loadChildren でも id を進め、2 つの fetch 入口のどちらでも「最後に発行した取得だけが勝つ」ようにする (ref 名を fetchIdRef に変更)
- 回帰 test を追加。loadChildren の id 更新を外す mutant で fail する

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymnao
ymnao merged commit 9f81838 into main Oct 6, 2026
10 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@ymnao
ymnao deleted the fix/filetree-stale-collapsed-folder branch October 6, 2026 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@ymnao
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.