Skip to content

FIX: Bind Attack History requests to the runtime generation - #3894

Merged
hannahwestra25 merged 5 commits into
microsoft:mainfrom
itsrayeedscodespace:fix/attack-history-runtime-generation
Nov 17, 2026
Merged

hannahwestra25 merged 5 commits into
microsoft:mainfrom
itsrayeedscodespace:fix/attack-history-runtime-generation

Conversation

@itsrayeedscodespace

@itsrayeedscodespace itsrayeedscodespace commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes #3745.

Bind Attack History requests, pagination and filter options to the current runtime generation. Requests wait for runtime readiness; late responses from an obsolete generation are ignored. Changing the runtime restarts pagination without a previous runtime's cursor and clears old filter options and errors before paint. Auto-refresh waits for readiness and settled list loading.

The implementation preserves main's page-request identity and cursor handling, quiet refresh, simplified filters, and option-error behavior. The PR changes only AttackHistory.tsx and its tests relative to current main. No API or type changes.

Validation

After merging upstream main f6a664768 in 6dbed2a1619b4abe49b68b023319acd68d38343b:

  • AttackHistory suite: 55 passed.
  • AttackHistory, useRuntime and useAutoRefresh suites together after npm ci: 67 passed.
  • Frontend ESLint: passed.
  • Application TypeScript checking and Vite production build (npm run build): passed.
  • Test TypeScript checking (npx tsc --project tsconfig.test.json --noEmit): passed.
  • git diff --check: passed.

The runtime regressions cover readiness, stale list responses and rejections, old list errors, reconnect pagination, old operator/options errors, narrowed labels, and cursor-free refresh. Earlier revisions demonstrated the original seven lifecycle regressions and the old-list-error regressions failing before their fixes; those historical baseline experiments were not repeated for this merge-only update.

The full frontend coverage suite and browser E2E were not rerun for this update. The earlier broad coverage run had three failures that also reproduced on its untouched main baseline; it is not a passing result for the current head. Hosted CI still requires maintainer approval to run.

AI assistance: verified and tested with OpenAI Codex.

Attack History did not read useRuntime(), so a list response from the
previous runtime could land after RuntimeProvider reported a new
generation, and a later page's cursor and cached filter options carried
over to the new runtime.

Key list requests by runtime generation as well as filters, so a new
generation cancels the in-flight request, drops the old cursor and loads
page 1. Re-request filter options per generation, ignore late responses
and clear the previous generation's options before paint. Send no
requests until the runtime is ready.

Fixes microsoft#3745

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 3, 2026 19:42

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.

🟢 Approval recommended

No active review issues are recorded for the runtime-aware Attack History changes.

No open issues 🎉

What changed in this PR

Binds Attack History requests to the runtime generation, addressing #3745 and aligning History with the existing Dataset and Analytics reload behavior.

Changes:

  • Gates history and filter-option requests on runtime readiness and ignores responses from obsolete requests.
  • Resets pagination to the first page and clears cached filter options when the runtime generation changes.
  • Adds three regression tests covering readiness, stale list responses, and reconnect pagination with fresh options.
File Description
frontend/​src/​components/​History/​AttackHistory.tsx Adds runtime-aware request handling, pagination invalidation, and filter-option resets.
frontend/​src/​components/​History/​AttackHistory.test.tsx Adds runtime mocks and regression tests for readiness and generation changes.

Review effort: Balanced

@itsrayeedscodespace

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

@hannahwestra25 hannahwestra25 self-assigned this Nov 9, 2026
@hannahwestra25

Copy link
Copy Markdown
Collaborator

Thanks for contributing!! This branch conflicts with main after #3649, #3997 and #3982, so please re-apply the fix to main's version. Line numbers below are from AttackHistory.tsx on current main.

  1. List key. Import and call useRuntime() (L10, near L71). Add listKey = JSON.stringify([runtime.generation, filterKey]) after filterKey (L96–102). Then use it wherever list requests compare against filterKey:
  • settledFilterKey (L103)
  • fetchToken and its render-time reset (L118–126)
  • fetchAttacks (L133–134)
  • effectiveCursor (L202)
  • the list effect's dependencies (L245)
  • filtersPending (L276)
  1. Auto-refresh (L278–283). Enable it only when runtime.ready && !displayLoading, and compare fetchToken.listKey === listKey (L281) so a reconnect never re-sends the old cursor.

  2. Generation reset. Add optionsGeneration state and the render-time reset after L90. Drop the attack-type and converter setters, and also clear optionsError and narrowedOptionsError (L79–83).

  3. Readiness gating. Return early when the runtime isn't ready, and add the runtime dependencies:

  • Options effect: return before optionsPending.current = true (L139). Dependencies at L164.
  • Narrowed-label effect: L168, dependencies at L190–194.
  • List effect: return before pending.current = true (L201). Dependencies at L238–247.

Tests (AttackHistory.test.tsx):

  • main asserts that getAttackOptions and getConverterOptions are never called (L442–443, L731–732) and that attack-type-filter is absent (L102). The readiness test (PR L1326) and the reconnect test (PR L1371–1374 and L1414–1417) need to use getLabels / operator-filter instead.
  • Please also add tests that the old operator options are cleared on reconnect and that auto-refresh after a reconnect sends no cursor.

@itsrayeedscodespace

Copy link
Copy Markdown
Contributor Author

Thanks hannahwestra25! I merged the latest main and reapplied the fix in d0afcfa, keeping the current filters, option-error handling, and auto-refresh.

History and filter-option requests now wait for runtime readiness. List requests and pagination use the generation plus filter key, and a generation change clears the old options and option errors. Auto-refresh also waits for readiness and cannot reuse the previous generation’s cursor.

I updated the tests to use labels/operator options and added the two regressions you requested. There are seven runtime regression tests in total, covering readiness, stale list and option responses, reconnect pagination, clearing old operator options/errors, narrowed labels, and cursor-free auto-refresh. All 48 History tests pass on the pushed head; all seven new regressions fail against unmodified main. Lint, TypeScript checking, and the production build also pass.

The broader frontend coverage run, before merging main’s latest attachment-upload commit, had 4,660 passing tests and three failures. All three reproduce on untouched main at 1d27ae7: the ScenarioDetail failed-preview accessibility test and the two App.drafts new-conversation route tests. Coverage thresholds passed. I left those unrelated tests unchanged.

Could you take another look when you have a chance? Thanks!

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.

🟢 Approval recommended

No active review issues were identified for the Attack History runtime-generation changes.

No open issues 🎉

Review effort: Balanced

itsrayeedscodespace and others added 3 commits November 10, 2026 22:18
Gate both list error render branches on the settled generation-aware list key. Cover replacement readiness, pending requests, settled success and failure, and late obsolete rejections without changing request lifecycles.

Signed-off-by: Rayeed Zaman <rayeedzaman@gmail.com>
…e conflicts

Keep main's page-request pagination while binding requests and filter options to runtime generations. Preserve both regression suites.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@itsrayeedscodespace

Copy link
Copy Markdown
Contributor Author

Merged current main f6a664768 in 6dbed2a16 to clear the branch freshness requirement. The merge was clean and preserves main's page-request/cursor handling alongside the runtime-generation guards. The PR diff remains limited to History and its tests.

Fresh validation after npm ci: 55 History tests pass; History plus useRuntime/useAutoRefresh totals 67 passing tests. Frontend lint, application and test TypeScript checks, the production build, and diff checks pass. The full coverage suite and browser E2E were not rerun. Hosted workflows still require maintainer approval; these local results do not establish hosted CI success. I updated the description to reflect the current implementation and validation.

@hannahwestra25
hannahwestra25 added this pull request to the merge queue Nov 17, 2026
Merged via the queue into microsoft:main with commit 36eecb9 Nov 17, 2026
59 checks passed
@itsrayeedscodespace

Copy link
Copy Markdown
Contributor Author

thanks hannahwestra25! just wanted to let you know that im a cs major at georgia tech and if you guys are hiring interns, please let me know. happy to contribute on a larger scale.

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.

Attack history accepts a previous-runtime response after RuntimeProvider reports a replacement generation

3 participants