Skip to content

resolvedなコメントの表示/非表示を切り替えるFudeReviewToggleResolvedを追加 - #163

Merged
kyu08 merged 7 commits into
mainfrom
feat/toggle-resolved-comments
Jul 23, 2026
Merged

resolvedなコメントの表示/非表示を切り替えるFudeReviewToggleResolvedを追加#163
kyu08 merged 7 commits into
mainfrom
feat/toggle-resolved-comments

Conversation

@kyu08

@kyu08 kyu08 commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

概要

resolvedなコメントのエディタ表示をランタイムでトグルする:FudeReviewToggleResolvedを追加します(Closes #103)。#73(PR #156)で導入したresolvedラベル表示が前提のため、base branchをfeat/comment-resolved-labelにしたstacked PRです。#156のマージ後にbaseをmainへ切り替えてください。

変更内容

  • config.lua: state.show_resolved(runtime override、current_comment_styleパターン)とget_show_resolved()/toggle_show_resolved()を追加。セッション終了でリセット
  • comments/data.lua: build_comment_map(comments, opts)opts.hide_resolvedを追加。comment_mapがextmarks・]c/[cナビゲーション・コメントviewerの共通データ源のため、ここで一元フィルタ。GitHubのis_resolvedとローカルレビューのresolved:FudeReviewResolveでresolveしたスレッド)の両方を対象にする
  • comments/sync.lua / comments/local_sync.lua: comment_map構築時に現在の可視性を渡し、reload・auto-reload・ローカル操作後もトグル状態を維持
  • comments.lua: toggle_resolved_visibility()(comment_map再構築+extmarks更新)
  • plugin/fude.lua: :FudeReviewToggleResolvedコマンド。resolved.show = false(キルスイッチ)時は警告のみ
  • コメントブラウザ(:FudeReviewListComments)は影響を受けず、常に[resolved]ラベル付きで表示する(outdatedの前例と一貫)

また、レビューで検出した#156のエッジケースをあわせて修正しています:

  • 未送信pendingリプライへのresolved伝播を除外: resolved済みスレッドに未送信のpendingリプライがある場合、従来はリプライにもis_resolvedが伝播し、未送信コメントが残る行が[resolved]表示になっていました。トグルで自分の未送信リプライごと非表示になる事故も防ぐため、pendingコメントにはis_resolvedを付けないようにしました

テスト計画

  • 既存テスト全パス(make all: luacheck / stylua / 全spec / check-state-deps / check-purity / check-docs)
  • 新規テスト追加: config_spec(get/toggle)、comments_spechide_resolvedフィルタ・ローカルresolved対応・toggle_resolved_visibility)、sync_integration_spec(reload後の維持・pending除外)
  • 手動確認: resolvedスレッドを持つPRで:FudeReviewToggleResolvedを実行し、(a) virtualText/inlineインジケーターと]c/[cから消えること、(b) ブラウザには残ること、(c) :FudeReviewReload後も非表示が維持されること、(d) ローカルレビューで:FudeReviewResolveしたスレッドにも効くこと

備考

  • 非表示中はresolved行を対象とするreply/edit draftマーカーも消えます(drafts.jsonは保持)。doc/fude.txtに既知挙動として記載しています
  • サイドパネルやファイルピッカーのコメント数はstate.comments(未フィルタ)由来のためトグルの影響を受けません

Generated with Claude Code

@kyu08
kyu08 force-pushed the feat/comment-resolved-label branch from ac4cf9c to a71dcad Compare July 21, 2026 10:40
Base automatically changed from feat/comment-resolved-label to main July 22, 2026 01:13
kyu08 and others added 4 commits July 22, 2026 10:23
- config: state.show_resolved runtime override with
  get_show_resolved()/toggle_show_resolved() (current_comment_style
  pattern; editor-only, resets on stop)
- data: build_comment_map/merge_pending_into_comments accept
  opts.hide_resolved to exclude resolved comments from the map,
  hiding them from extmarks, navigation, and the comment viewer;
  the comment browser stays unaffected
- sync: comment_map is built with the current visibility so the
  toggle survives reloads
- comments: toggle_resolved_visibility() rebuilds comment_map and
  refreshes extmarks; wired to the new user command
- fix: apply_thread_info no longer marks unsubmitted pending
  comments as resolved — a pending reply on a resolved thread must
  keep the line unresolved (and never be hidden by the toggle)
- extmarks: build inline opts only in inline mode

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Local review mode marks threads with a thread-level `resolved` flag
(FudeReviewResolve) instead of GitHub's `is_resolved`. Make
build_comment_map's hide_resolved cover both fields and thread the
current visibility through local_sync's re-materialize so the toggle
behaves the same in both backends.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@kyu08
kyu08 force-pushed the feat/toggle-resolved-comments branch from 239926e to 4574296 Compare July 22, 2026 01:28
Copilot AI review requested due to automatic review settings July 22, 2026 01:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

:FudeReviewToggleResolved を追加し、GitHub 上で resolve 済み(およびローカルレビューで resolved 済み)のスレッドを エディタ表示(extmarks / ナビゲーション / comment viewer)からランタイムで表示・非表示切り替えできるようにする変更です。comment_map を単一のフィルタリングポイントにして、reload/auto-reload/ローカル操作後もトグル状態が維持されるように統合されています。

Changes:

  • config.state.show_resolvedget_show_resolved() / toggle_show_resolved() を追加し、セッション中の表示状態を保持
  • comments/data.luabuild_comment_maphide_resolved を導入し、resolved フィルタを comment_map 構築に集約
  • GitHub resolved スレッド上の 未送信 pending reply には is_resolved を付与しないようにして、誤って [resolved] 扱い・非表示になるのを回避

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.

Show a summary per file
File Description
plugin/fude.lua :FudeReviewToggleResolved コマンド追加と無効化設定時の警告
lua/fude/config.lua show_resolved の runtime state と get/toggle API 追加、reset でクリア
lua/fude/comments/data.lua build_comment_map(..., { hide_resolved }) による resolved フィルタの一元化
lua/fude/comments.lua toggle_resolved_visibility() を追加し comment_map 再構築+extmarks 更新
lua/fude/comments/sync.lua comment_map 構築へ可視性反映、pending reply へ resolved 伝播しない修正
lua/fude/comments/local_sync.lua comment_map 構築へ可視性反映(ローカル resolved も対象)
lua/fude/ui/extmarks.lua inline 用オプション構築を inline 時に限定(挙動維持の整理)
tests/fude/config_spec.lua get_show_resolved / toggle_show_resolved / reset のユニットテスト追加
tests/fude/comments_spec.lua hide_resolved フィルタと toggle_resolved_visibility の挙動テスト追加
tests/fude/sync_integration_spec.lua reload 維持・pending reply 除外の統合テスト追加
README.md コマンド一覧・resolved 設定説明へトグル追記
doc/fude.txt :FudeReviewToggleResolved のヘルプ追記と設定節への補足
CLAUDE.md アーキテクチャ/状態依存一覧の追記・整合

Comment thread CLAUDE.md
Comment thread CLAUDE.md Outdated
- **`comments.lua`** — Facade module re-exporting `comments/data.lua`, `comments/sync.lua`, and `comments/pickers.lua`. Contains comment navigation (`next_comment`/`prev_comment`), creation (`create_comment`/`suggest_change`), viewing (`view_comments`), reply (`reply_to_comment`), editing (`edit_comment`), deletion (`delete_comment`), and thread resolution (`toggle_resolve`, local mode only). Dispatches mutations to `comments/sync.lua` (GitHub) or `comments/local_sync.lua` (local JSONL) by `state.review_mode`. Also provides ownership helpers: `is_own_comment`, `is_pending_comment`, `find_pending_key`, and `toggle_resolved_visibility()` (flips `config.toggle_show_resolved()`, rebuilds `comment_map` from `state.comments` with `hide_resolved`, and refreshes extmarks — used by `:FudeReviewToggleResolved`; the comment browser is unaffected). `require("fude.comments")` is the public interface.
- **`comments/data.lua`** — Pure data functions with no state or side effects: `line_from_diff_hunk`, `build_comment_map`, `find_next_comment_line`, `find_prev_comment_line`, `find_comment_by_id`, `get_comment_thread`, `parse_draft_key`, `build_pending_comments_from_review`, `build_review_comment_object`, `merge_pending_into_comments`, `pending_comments_to_array`, `get_comment_line_range`, `get_reply_target_id`, `get_comments_at`, `get_comment_lines`, `build_comment_entries`, `build_comment_browser_entries`, `merge_draft_entries` (flags existing entries with `has_draft` for matching reply/edit/line/issue drafts and appends `type="draft"` rows for new line/suggest/issue drafts, then re-sorts by `last_ts`).
- **`comments/sync.lua`** — GitHub API sync/submit operations: `load_comments`, `sync_pending_review`, `submit_as_review`, `reply_to_comment`, `edit_comment`, `delete_comment`. `load_comments` is the main entry point: detects pending review via `GET /pulls/{pr}/reviews`, then fetches both submitted comments (`GET /pulls/{pr}/comments`) and pending review comments (`GET /reviews/{id}/comments`) in a single flow, converting `position` to `line` via `line_from_diff_hunk` and building both `comment_map` and `pending_comments`. Also fetches review threads via GraphQL (skipped when `outdated.show` and `resolved.show` are both false and no pending review exists) and applies `is_outdated` (root comments only, gated by `outdated.show`) and `is_resolved` (per-thread state, propagated to replies via `in_reply_to_id`, gated by `resolved.show`) to comment objects. Internal `fetch_comments` is used by other functions for refreshing after mutations. Uses lazy `require("fude.ui")` to avoid circular dependencies.
- **`comments/sync.lua`** — GitHub API sync/submit operations: `load_comments`, `sync_pending_review`, `submit_as_review`, `reply_to_comment`, `edit_comment`, `delete_comment`. `load_comments` is the main entry point: detects pending review via `GET /pulls/{pr}/reviews`, then fetches both submitted comments (`GET /pulls/{pr}/comments`) and pending review comments (`GET /reviews/{id}/comments`) in a single flow, converting `position` to `line` via `line_from_diff_hunk` and building both `comment_map` and `pending_comments`. Also fetches review threads via GraphQL (skipped when `outdated.show` and `resolved.show` are both false and no pending review exists) and applies `is_outdated` (root comments only, gated by `outdated.show`) and `is_resolved` (per-thread state, propagated to replies via `in_reply_to_id`, gated by `resolved.show`) to comment objects. `comment_map` is built with `hide_resolved = not config.get_show_resolved()` so the runtime resolved-visibility toggle survives reloads. Internal `fetch_comments` is used by other functions for refreshing after mutations. Uses lazy `require("fude.ui")` to avoid circular dependencies.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

unresolved

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

a

The toggle previously removed resolved comments from comment_map, which
also hid them from navigation, the comment viewer, and the comment
browser. Restrict it to inline comment boxes only:

- comment_map always keeps resolved comments (build_comment_map and
  merge_pending_into_comments no longer take hide_resolved); navigation,
  the comment viewer, the virtualText style, and the comment browser are
  unaffected
- refresh_extmarks factors the EOL indicators into
  render_virt_text_indicators, reused so a resolved comment whose inline
  box is hidden falls back to the same virtualText indicator
  ([resolved] + count)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 23, 2026 05:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Comment thread lua/fude/ui/extmarks.lua Outdated
When FudeReviewToggleResolved hid a resolved comment's inline box, the
EOL fallback judged `[resolved]` over only the hidden subset, so a line
mixing an unresolved thread with a resolved one wrongly showed
`[resolved]`. Render the fallback only when the whole line has no box,
so render_virt_text_indicators judges over all of the line's comments
like the virtualText style. Also split box/fallback on `is_resolved`
alone (matching util.all_comments_resolved) so they never disagree.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 23, 2026 06:10
…l set)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.

Comment thread lua/fude/comments.lua
Comment on lines +59 to +63
--- Only affects inline comment boxes (the virt_lines rendered in "inline"
--- comment style): refresh_extmarks skips resolved comments when hidden.
--- comment_map is left intact, so navigation, the comment viewer, virtualText
--- indicators, and the comment browser (FudeReviewListComments) always show
--- resolved threads regardless of this toggle.
Copilot AI review requested due to automatic review settings July 23, 2026 06:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.

Comment thread lua/fude/ui/extmarks.lua
Comment on lines +162 to +167
-- Inline mode: display full comment content below the line.
-- When FudeReviewToggleResolved is off, resolved comments do not get an
-- inline box. If that leaves the line with nothing to show, it falls back
-- to the same EOL virtualText indicator the virtualText style would show
-- (e.g. `[resolved] 🗒️1`) so the line stays marked. Pending comments are
-- never resolved, so they always keep their inline box.
@kyu08
kyu08 marked this pull request as ready for review July 23, 2026 07:14
@kyu08
kyu08 requested a review from flexphere as a code owner July 23, 2026 07:14
@kyu08 kyu08 linked an issue Jul 23, 2026 that may be closed by this pull request
@kyu08
kyu08 merged commit 657b44a into main Jul 23, 2026
10 checks passed
@kyu08
kyu08 deleted the feat/toggle-resolved-comments branch July 23, 2026 07:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Resolvedなコメントの表示/非表示を切り替える

2 participants