feat: mark merge request files as viewed in the sidebar

Description

Adds a native "viewed" checkbox to changed file items in the merge request tree views (both the Issues and Merge Requests and For current branch sidebars), mirroring the "Viewed" checkbox in the GitLab web UI file diff.

  • Checking a file marks it as viewed: the item is dimmed via a FileDecorationProvider (gitDecoration.ignoredResourceForeground).
  • The state is persisted per user in the extension globalState, keyed by instance URL, project id, and MR id, capped at the 100 most recently updated MRs.
  • When a new push changes a file's diff (or the file is renamed), only that file resets to "not viewed" — same behavior as the web UI. This is done by storing a hash of (old_path, new_path, diff) at the time the file is marked.

Implementation notes

  • TreeItem.checkboxState (stable API) provides the checkbox; both tree views were converted from registerTreeDataProvider to createTreeView so the extension can subscribe to onDidChangeCheckboxState.
  • There is no public GitLab API for the web UI "viewed" state (the web UI persists it in browser localStorage), so the extension state is local to the editor and does not synchronize with the web UI — the same limitation the web UI itself has.
  • Known trade-off: for very large diffs where the REST API omits/truncates the diff text, the content hash degrades to paths only, so the viewed state may survive a content change in that edge case.

Resolves #270 (closed)

(#571 (closed) requested the same feature and was closed as a duplicate of #270 (closed).)

How has this been tested?

Unit tests (Jest, colocated):

  • viewed_files_store.test.ts: set/unset, hash invalidation on content change, isolation between MRs and instances, pruning (including dropping emptied MR entries).
  • viewed_decoration_provider.test.ts: decoration present/absent/stale, change event.
  • viewed_checkbox_handler.test.ts: checkbox events update the store and fire decoration changes.
  • changed_file_item.test.ts: initial checkbox state and the new query params on resourceUri.

Manual testing (Extension Development Host and packaged VSIX):

  1. Open a repository with an open MR that has several changed files.
  2. In the sidebar, expand the MR (in either view), in list or tree mode.
  3. Check the checkbox on a file: it dims immediately; reload the window and the state is kept.
  4. Push a change to one of the viewed files: after the tree refreshes, only that file returns to unchecked.
  • If src/browser or src/common has been modified, please consider interoperability with the Web IDE — neither was modified: the feature is desktop-only (src/desktop/); the only file outside it is the Jest mock src/__mocks__/vscode.js.
  • Consider an end-to-end test for significant new features that aren't covered by integration tests — not added; the feature is covered by the colocated unit tests above. Happy to add an e2e test if maintainers think it is warranted.

Screenshots (if appropriate)

A checkbox is shown next to each changed file in the MR tree; checked files are dimmed using the theme's gitDecoration.ignoredResourceForeground color.

What CHANGELOG entry will this MR create?

  • fix: Bug fix fixes - a user-facing issue in production - included in changelog
  • feature: New feature - a user-facing change which adds functionality - included in changelog
  • BREAKING CHANGE: (fix or feature that would cause existing functionality to change) - should bump major version, mentioned in the changelog
  • None - other non-user-facing changes
Edited by Henrique Pavanatti

Merge request reports

Loading
Loading