Skip to content

Load a deep-linked job's details first, and only its push - #9823

Open
camd wants to merge 1 commit into
masterfrom
camd/selected-job-first-load
Open

Load a deep-linked job's details first, and only its push#9823
camd wants to merge 1 commit into
masterfrom
camd/selected-job-first-load

Conversation

@camd

@camd camd commented Aug 30, 2026

Copy link
Copy Markdown
Collaborator

Problem

Opening Treeherder with a job or task id in the URL (selectedTaskRun or selectedJob) loaded the latest 10 pushes and all of their job lists before the selection was even resolved — the details panel was the last thing to appear, and the view often failed to scroll to the job. If you deep-link to a job, you want that job's details first.

Changes

Job first, then only its push. On a deep link with no push-range params:

  1. resolveSelectedJobFromUrl() (selectedJobStore) resolves the task via GET /api/jobs/?task_id=… (or ?id=…) before any push traffic and sets the selection immediately, so the details panel starts loading right away.
  2. The URL is rewritten to revision=<the job's push> (keeping selectedTaskRun, normalizing selectedJobselectedTaskRun), and only that push is fetched (fetchInitialPushes() in pushesStore) instead of the latest 10. "Get next N" works from there for users who want surrounding context.
  3. Explicit range params (revision, fromchange, dates, author) still win: no rewrite, but the job is still resolved eagerly for details-first loading. An unresolvable task shows the existing notification and falls back to the default view.

Reliable scroll. The old mount-time one-shot scroll in useJobButtonRegistry fired while other pushes were still inserting DOM (layout shifted after the scroll) and never fired for collapsed groups. It's replaced by a pending-scroll flag consumed by whichever happens first: the job button mounting, or the post-load selection sync finding the rendered button.

Fixed along the way

  • The post-load jobMap sync no longer clears an eagerly-resolved selection it can't find yet.
  • updateRange keeps the selection when narrowing to the push that contains it (previously it cleared the selection unconditionally; React Router v7 applies popstate in a transition, so PushList could see a phantom range diff after the URL rewrite and clobber the selection).
  • searchDatabaseForTaskRun no longer sends the literal retry_id=undefined when the URL has no run id.
  • Filtering_test now resets window.location between tests — job-click tests leaked selectedTaskRun into the shared URL, which a fresh App mount now correctly treats as a deep link.

Tests

  • tests/ui/job-view/SelectedJobFirstLoad_test.jsx — end-to-end (BrowserRouter): asserts the resolve request precedes any push request, exactly one push fetch limited to the job's revision, the URL rewrite, the selected button, and the scroll.
  • tests/ui/job-view/stores/selectedJobEagerResolve_test.jsx — resolution (run-id/none/job-id, highest-retry pick, not-found), keep-vs-clear selection semantics, pending-scroll consumption.
  • tests/ui/shared/stores/fetchInitialPushes_test.jsx — orchestration: single-push fetch + rewrite, explicit-range passthrough, no-selection default, not-found fallback.
  • Registry pending-scroll unit tests in tests/ui/hooks/useJobButtonRegistry.test.js.

Full suite: 102 suites / 1109 tests pass; lint clean.

Note for sheriffs

Deep links to a job now show one push instead of the latest 10 — "Get next 10" restores the surrounding range, and any explicit range param preserves the old behavior.

@netlify

netlify Bot commented Aug 30, 2026

Copy link
Copy Markdown

Deploy Preview for treeherder ready!

Name Link
🔨 Latest commit 2c9cebe
🔍 Latest deploy log https://app.netlify.com/projects/treeherder/deploys/6a9dcf0133b8c5000877403f
😎 Deploy Preview https://deploy-preview-9823--treeherder.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov-commenter

codecov-commenter commented Aug 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.78947% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.86%. Comparing base (9e3979b) to head (2c9cebe).

Files with missing lines Patch % Lines
ui/shared/stores/selectedJobStore.js 91.66% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9823      +/-   ##
==========================================
- Coverage   83.88%   83.86%   -0.03%     
==========================================
  Files         643      643              
  Lines       39264    39341      +77     
  Branches     3492     3457      -35     
==========================================
+ Hits        32937    32992      +55     
- Misses       5938     6204     +266     
+ Partials      389      145     -244     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

When the jobs view is opened with a selectedTaskRun or selectedJob URL
param and no push-range params, resolve the job via the jobs API before
fetching any pushes, so the details panel starts loading immediately.
The URL is then rewritten to revision=<the job's push> and only that
push is fetched, instead of the latest 10; "Get next N" works from
there for users who want more context. Explicit range params still win
(the job is still resolved eagerly for details-first loading).

Scrolling to the selected job is now driven by a pending-scroll flag
that is consumed by whichever happens first: the job button mounting,
or the post-load selection sync finding the rendered button. The
post-load sync also no longer clears an eagerly-resolved selection,
and updateRange keeps the selection when narrowing to the push that
contains it.
@camd
camd force-pushed the camd/selected-job-first-load branch from d4c27ac to 2c9cebe Compare September 6, 2026 20:37
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