Skip to content

feat(autofix): Collapse changed-files list after 3 files - #122487

Open
NicoHinderling wants to merge 4 commits into
masterfrom
feat/autofix-overview-collapse-changed-files
Open

feat(autofix): Collapse changed-files list after 3 files#122487
NicoHinderling wants to merge 4 commits into
masterfrom
feat/autofix-overview-collapse-changed-files

Conversation

@NicoHinderling

Copy link
Copy Markdown
Contributor

On the Autofix Overview page, the "Review Open PRs" cards list every file changed by a PR under Code Changes. For PRs touching many files this produces a long, noisy list that dominates the card.

This collapses each repo group's file list to the first 3 files by default, with an inline toggle to reveal the rest:

  • ≤ 3 files — unchanged, all rendered.
  • > 3 files — shows the first 3, then a Show N more files / Show fewer toggle that expands and collapses inline (no navigation, no extra fetch).
  • The repo header badge still reflects the total file count.

The logic lives in the shared ChangedFilesSection, so both the PR file list (PullRequestFiles) and the generated Code Changes list get the same behavior. Per-group showAll state is owned by an extracted RepoGroup component; the existing expand-to-diff / prefetch flow is unchanged. The toggle carries aria-expanded for screen-reader semantics.

The Review Open PRs cards on the Autofix Overview page list every file
changed by a PR, which can produce a long, noisy list. Show only the
first 3 files per repo group and add an inline "Show N more files"
toggle to reveal the rest, keeping cards compact by default.

The logic lives in the shared ChangedFilesSection, so both the PR file
list and the generated Code Changes list get the same behavior. The
repo header badge still reflects the total file count.
@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Aug 24, 2026
Drop the up/down chevron from the "Show N more files" toggle and use a
plain link-variant button, matching Sentry's house pattern for
in-place list expansion. The chevron clashed with the per-row disclosure
chevrons. Also remove the redundant file-count badge next to each repo
name.
The flush-left link read as a stray link. Render the "Show N more
files" toggle as a centered, muted footer row with a subtle hover
affordance instead, so it reads as part of the file list.
Raise the collapse threshold from 3 to 5, so the "Show N more files"
toggle only appears when a repo group has more than 5 files. Smaller
lists render in full.
Comment on lines +53 to +58
const [showAll, setShowAll] = useState(false);
const hiddenCount = group.files.length - COLLAPSED_FILE_COUNT;
const visibleFiles =
showAll || hiddenCount <= 0
? group.files
: group.files.slice(0, COLLAPSED_FILE_COUNT);

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.

Bug: When collapsing the file list, keys for expanded files that become hidden are not removed from expandedKeys, causing them to auto-expand when the list is revealed again.
Severity: LOW

Suggested Fix

When the showAll state is toggled to false, iterate through the files that are being hidden and remove their corresponding keys from the expandedKeys set. This can be accomplished within the RepoGroup component, possibly using a useEffect hook that triggers when showAll changes, to call onToggle(key, false) for each hidden file.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: static/app/views/seerWorkflows/overview/changedFilesSection.tsx#L53-L58

Potential issue: The `expandedKeys` state, which tracks which files have their diffs
expanded, is not cleared when the file list is collapsed. If a user expands a file that
is only visible when the full list is shown (e.g., file #6 in a list of 7) and then
collapses the list using the "Show fewer" button, the key for that file remains in the
`expandedKeys` set. When the user re-expands the list, the file will unexpectedly render
in an expanded state without any user interaction, because the component finds the stale
key and sets `isExpanded` to `true`.

Did we get this right? 👍 / 👎 to inform future reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant