Skip to content

🐛 fix: keep full review thread context in filtered timelines#42

Merged
SigureMo merged 2 commits intomainfrom
fix/review-thread-window-context
Apr 9, 2026
Merged

🐛 fix: keep full review thread context in filtered timelines#42
SigureMo merged 2 commits intomainfrom
fix/review-thread-window-context

Conversation

@SigureMo
Copy link
Copy Markdown
Contributor

@SigureMo SigureMo commented Apr 9, 2026

修复 #41 可能忽略 review thread 的更新

Co-authored-by: Codex <codex@openai.com>
@SigureMo SigureMo changed the title 🐛 Keep full review thread context in filtered timelines 🐛 fix: keep full review thread context in filtered timelines Apr 9, 2026
Co-authored-by: Codex <codex@openai.com>
@SigureMo SigureMo marked this pull request as ready for review April 9, 2026 17:40
Copilot AI review requested due to automatic review settings April 9, 2026 17:40
@SigureMo SigureMo merged commit 774363c into main Apr 9, 2026
4 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a correctness gap in the timeline --after/--before filtering for PRs: review events can now be retained when their review threads contain updates that fall within the selected time window (so thread context isn’t lost).

Changes:

  • Extend timeline filtering to consider “related timestamps” (e.g., review thread comment timestamps) in addition to the event’s own timestamp.
  • Adjust PR review thread grouping/rendering so a window-matched thread shows full context, with per-comment window markers.
  • Add CLI test coverage to validate that an older review is kept when its thread receives an in-window reply.

Reviewed changes

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

File Description
tests/test_cli.py Adds a regression test ensuring filtered PR timelines keep full review thread context when a thread update matches the window.
src/gh_llm/pager.py Updates filtered collection logic to match events via related timestamps and threads the window through timeline fetches.
src/gh_llm/models.py Adds related_timestamps to TimelineEvent to support window matching beyond the primary event timestamp.
src/gh_llm/github_api.py Propagates timeline_window into parsing/rendering, collects review-thread comment timestamps, and renders window markers/full-context thread headers.
Comments suppressed due to low confidence (2)

src/gh_llm/pager.py:414

  • For PR timelines, this condition disables the early-stop optimization when --after is set, so _collect_filtered_from_end() will walk all the way to the first timeline page. On large PRs this can turn an incremental read into an O(total_pages) fetch, which is a noticeable performance/latency regression.

Consider keeping an early termination strategy for PRs (e.g., precomputing the set of review IDs/threads with any comment timestamps in-window from reviewThreads, then fetching only those missing review nodes by ID, or otherwise bounding how far back the backward walk must go).

            if (
                meta.kind != "pr"
                and current_page.items
                and timeline_window.after is not None
                and current_page.items[0].timestamp <= timeline_window.after
            ):
                break

src/gh_llm/pager.py:505

  • Similarly, for PR timelines this disables the forward early-stop when --before is set, which can force fetching every page from the start even when the requested window is small. That undermines the intended windowed/incremental behavior and can be expensive for long PR timelines.

If correctness requires pulling in older review nodes whose threads were updated in-window, consider a targeted strategy (derive “relevant review IDs” from reviewThreads and fetch only those older reviews) instead of scanning the entire timeline connection.

            if (
                meta.kind != "pr"
                and current_page.items
                and timeline_window.before is not None
                and current_page.items[-1].timestamp >= timeline_window.before
            ):
                break

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b8d7068826

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +660 to +663
def _event_matches_window(event: TimelineEvent, timeline_window: TimelineWindow) -> bool:
if _matches_window(event.timestamp, timeline_window):
return True
return any(_matches_window(timestamp, timeline_window) for timestamp in event.related_timestamps)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Restrict related timestamp matching for --before windows

This change makes _event_matches_window include a review when any related_timestamps entry is inside the window, but reviews now carry full thread history from github_api._get_review_threads_by_review; as a result, a review submitted after a --before cutoff can still be included because the same thread has an older comment timestamp. That breaks time-filter correctness by showing out-of-range events whenever a thread spans multiple reviews.

Useful? React with 👍 / 👎.

Comment on lines +2956 to 2957
if is_minimized and not show_minimized_details and not force_full_context:
minimized_hidden_count += 1
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve minimized-comment filtering in full-context threads

The new and not force_full_context condition bypasses minimized-comment hiding whenever a thread matches the selected window, so filtered timelines (--after/--before) can display minimized comments even when show_minimized_details is false. This regresses the existing CLI contract where minimized comments stay collapsed unless the user explicitly opts in via expand-minimized behavior.

Useful? React with 👍 / 👎.

@SigureMo SigureMo deleted the fix/review-thread-window-context branch April 9, 2026 17:47
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.

2 participants