Skip to content

[Task] F3: add reactive AND-tokenized process search with cancellation #17

Closed

Description

@DavidVFitzGerald

Delivery phase

Phase 1 - frontend with mock services

Goal

Filter the existing tree predictably while preserving user selections and avoiding stale search results.

Context and authority

Milestone F3; read AGENTS.md, docs/team/product-manager.md, docs/product/LCA_diff_PRD.md, docs/engineering/roadmap.md, and docs/engineering/LCA_diff_Implementation_Specification.md §§6.2, 7.1, 7.4. Current planning baseline is on docs/agent-workflow, pending review/merge into main; proposed ADRs are not accepted authority. Extend selector search UI/hooks and tests using the existing mock search service; keep search state separate from selected IDs. These application paths are planned until created. Exclude all archive/reference folders.

Requirements and constraints

Primary process-name field plus clear ×; advanced fields Process Name, Geography, Category, Subcategory and Reference Flow Name. Every token/field combines with AND, case-insensitive literal substring. Use short documented debounce and AbortSignal; no fuzzy/regex/Boolean semantics. Preserve matching ancestors and expand matching paths.

One session-sized task/PR including verification and handoff. Run all development, installation and checks in containers; install nothing on the host. No real backend, Firebase project, cloud credentials or proprietary inputs. If the current PRD/spec must change, prepare an ADR and updates to both current documents in the same PR.

Acceptance criteria

  • AC1 - Default view exposes process-name search; advanced fields have accessible labels and combine populated tokens/fields exactly as specified.
  • AC2 - Debounced changes cancel obsolete work; a slower earlier response cannot overwrite a newer query result.
  • AC3 - Only matching leaves and their ancestors appear, with ancestors expanded; explicit no-results and loading/error/retry states keep existing selections intact.
  • AC4 - Clear resets all search fields and restores the full tree without clearing selected IDs; filters are not written to persistent workspace storage.
  • AC5 - Unit/browser cases cover whitespace, mixed case, multiword/field AND, literal punctuation, cancellation races and no matches.

Out of scope and follow-ups

Selection storage/control is #18, filter-scoped bulk actions are #19. No approximate search, server search engine or persistence of filters.

Verification plan

Inside ./dev shell, run format:check/lint/typecheck/test:unit/build and npm --prefix apps/frontend run test:e2e. Use deterministic delayed mock responses and selected IDs to demonstrate query race rejection and clear-search selection retention.

Engineer records branch/SHA and exact results, leaves issue open, and hands off to QA. QA verifies every criterion at that SHA and reports PASS/FAIL/BLOCKED; mock evidence is not proof of real security/integration.

Dependencies and readiness

Blocked by #16, #18. No implementation until dependencies and the M1 environment runtime gate are satisfied. This body is groomed planning material, not PM READY while blockers remain. Coordinator/PM rechecks merged dependencies and session-sized scope before starting.

Current readiness — supersedes historical planning baseline/blockers above

Rechecked 2026-11-14 on main at a7b529b. #16 (PR #50) and #18 (PR #53) are merged and closed; the M1/M2 gates were satisfied previously.

Merged interfaces this issue consumes

Decisions

  • D1 Fields.
    • At the top of the Processes sidebar is a text input labelled Process Name, the default and only active field, with a one-click Clear search × button. The button shows whenever any field has text.
    • An Advanced search disclosure button (aria-expanded, collapsed by default) reveals labelled Geography, Category, Subcategory and Reference Flow Name inputs.
    • Process Name stays the primary field and is not duplicated in the panel, so there is one control per field.
    • Each input has maxLength 256.
  • D2 Normalization.
    • Each field value is trimmed and has internal whitespace collapsed before sending. Fields that become empty are omitted.
    • All fields empty means no filter, so the full lazy tree shows.
    • Input text is never rewritten in the field, and stored names are untouched.
    • There is no regex, Boolean, fuzzy or stemming syntax; punctuation is literal. Matching is the service's job (spec §6.2.1–2).
  • D3 Debounce and cancellation.
    • SEARCH_DEBOUNCE_MS = 200. Clear applies immediately.
    • Each normalized field set is its own query key. Changing it unsubscribes the old query, and TanStack aborts its consumed AbortSignal.
    • A late response for an old key never renders, because results are read only for the current key.
  • D4 Filtered tree.
    • While a filter is active, each release root issues one root-scoped search (fields, single-release snapshot, no branch_path, limit 50), continued by that release's "Load more" row.
    • Only matching leaves and their ancestor branches render. Roots and every branch with loaded matches are expanded by default; the user may collapse them, and those collapses reset when the filter changes.
    • Counts are the exact matching counts. Nested branches show no continuation rows of their own.
    • Unfiltered expansion state and loaded pages are kept and return after Clear.
  • D5 States.
    • Loading and error rows, and Retry when retryable, reuse [Task] F3: render the paginated release and nested process tree #16 per release.
    • A release with zero matches shows "No matching processes in ".
    • When every release has finished with zero matches, an explicit "No processes match your search." message shows.
    • A polite live region announces the match count once results load.
    • Selections are never changed by searching, failing, retrying or clearing.
  • D6 State and persistence. Search fields live in component state inside the UID-keyed Workspace. They are never written to storage and are discarded on signout or account change.
  • D7 Focus. Typing never moves focus. Filtering never steals focus from the inputs. Clear returns focus to the Process Name input.

Scope

Change a new src/components/process-search/ (component, normalizeFields, CSS), ProcessTree.tsx (add a fields prop and the filtered mode) and App.tsx. Add tests (unit, component under src/services/mock/) and e2e/process-search.spec.ts, and update the roadmap F3 row. There is no service, contract or composition change. Filter-scoped bulk selection and tri-state controls are #19.

Objective verification

  • Unit (normalizeFields):
    • whitespace (leading, trailing, internal, tabs);
    • empty field omission;
    • mixed case preserved for sending;
    • punctuation preserved, including .*, a(b, OR.
  • Component (mock injected):
    • AC1: labels and disclosure; the DTO contains only populated, normalized fields, and multiword AND across fields gives the expected leaves.
    • AC2: a burst of changes within 200 ms issues one search. A slow earlier query is aborted (signal.aborted), and a slower earlier response never replaces newer results.
    • AC3: only matching leaves and ancestors show, expanded, with exact counts. The no-results message appears, zero-match release rows appear, and error then Retry recovers. Selections are intact in every case.
    • AC4: Clear resets every field, restores the prior full tree and keeps the selection; nothing is stored.
    • AC5: mixed case, literal punctuation, field AND with no match, and whitespace-only input means no filter.
  • Browser (e2e/process-search.spec.ts, Chromium and Firefox, composed mock):
    • search "gamma" shows only Gamma with its ancestors expanded; select it;
    • Advanced Geography "de" plus Process Name "road" gives only Beta;
    • "zzz" shows the no-results message;
    • Clear restores the tree with Gamma still selected;
    • no requests or console errors, and no new storage keys.

Verification (container only)

COMPOSE_PROJECT_NAME=lca-diff-f3-search FRONTEND_PORT=5190 ./dev up && ./dev check
docker compose -p lca-diff-f3-search exec -T workspace bash -lc 'cd apps/frontend && npm ci --no-audit --no-fund && npm run format:check && npm run lint && npm run typecheck && npm run test:unit && npm run build && npm run test:e2e -- --grep @smoke && npm run test:e2e'

Mock evidence does not prove real search performance or server-side matching parity (I1).

Activity

  1. added
    task
    frontend
    blocked
    on Nov 13, 2026
  2. DavidVFitzGerald commented on Nov 13, 2026

    @DavidVFitzGerald
    OwnerAuthor

    PM: BLOCKED

    Groomed using docs/team/product-manager.md for F3, Phase 1 — frontend with mock services. Documentation review: PASS for scope, required sections, specification coverage and acyclic dependency links; this is not application QA or implementation readiness.

    Blocking predecessor issues: #16, #18. The M1 runtime gate (#2) and merged bootstrap/M2 configuration (#3) also remain required. PM must recheck merged dependencies and current interfaces before changing this to READY.

    Engineer implements one issue, commits regularly and hands the delivered SHA plus exact container checks to independent QA; do not close before QA, review and approved merge. No backend/Firebase/cloud credentials or host installations are required for Phase 1.

  3. DavidVFitzGerald commented on Nov 14, 2026

    @DavidVFitzGerald
    OwnerAuthor

    Coordinator: re-sequenced by the maintainer — #18 is implemented first (now PM READY); #17 is rechecked after #18 merges.

  4. removed
    blocked
    on Nov 14, 2026
  5. DavidVFitzGerald commented on Nov 14, 2026

    @DavidVFitzGerald
    OwnerAuthor

    PM: READY

    Phase 1 (frontend with mock services), milestone F3. Dependencies #16 (PR #50) and #18 (PR #53) are merged and closed. Spec references: §§6.2 (search rules 1–4, 7), 6.8, 7.1. Decisions D1–D7 are in the issue body's Current readiness section:

    • primary Process Name field plus Clear; an Advanced disclosure with the four other fields;
    • client whitespace normalization only, with matching left to the service;
    • 200 ms debounce and key-based cancellation;
    • a root-scoped, paged filtered tree with matching ancestors expanded and unfiltered state retained;
    • no-results, zero-match, error and Retry states;
    • no persistence; focus rules.

    There is no contract change and no ADR (no PRD or spec deviation). Bulk and tri-state controls are #19. Next: Software Engineer.

  6. DavidVFitzGerald commented on Nov 14, 2026

    @DavidVFitzGerald
    OwnerAuthor

    Engineering: READY FOR QA

    • Branch feat/f3-search, delivered SHA bcc5181 (commits 1049b9c, 76df306, bcc5181); PR F3: reactive AND-tokenized process search with cancellation (#17) #54 (Refs #17, no closing keyword).
    • Container results (lca-diff-f3-search): ./dev check PASS; frozen npm ci PASS (no dependency changes); format, lint, typecheck and build PASS; test:unit 212/212 in 15 files (3 consecutive runs); e2e @smoke 10 PASS; full e2e 32 PASS (Chromium and Firefox).
    • Evidence map: docs/engineering/f3-search-verification.md.
    • Notes:
      • Small model fix: a zero-match release-scoped page now gives the release root an exact count of 0.
      • The F2 keyboard journey was updated for the search tab stops.
      • Debounce, race and failure evidence comes from component tests.
    • Next: independent QA at bcc5181.
  7. DavidVFitzGerald commented on Nov 14, 2026

    @DavidVFitzGerald
    OwnerAuthor

    QA: FAIL

    Reviewed SHA bcc5181 (branch feat/f3-search, PR #54). Phase 1, mock mode only. Rootless compose project lca-diff-qa17 in a detached worktree at bcc5181. This is not evidence of real search, auth or server-side matching parity (I1).

    Commands and results (container only)

    • COMPOSE_PROJECT_NAME=lca-diff-qa17 FRONTEND_PORT=5191 ./dev up && ./dev check: PASS (8 preflight scenarios; rootless, restricted caps, frozen lock).
    • git diff --stat main...bcc5181: 14 files. No package.json or lockfile changes.
    • docker compose -p lca-diff-qa17 exec -T workspace bash -lc 'cd apps/frontend && npm ci --no-audit --no-fund && npm run format:check && npm run lint && npm run typecheck && (npm run test:unit x4) && npm run build && npm run test:e2e -- --grep @smoke && npm run test:e2e': exit 0.
      • npm ci (frozen): 232 packages.
      • format:check, lint (--max-warnings 0) and typecheck: PASS.
      • test:unit: 212/212 in 15 files on each of 4 consecutive runs. No flakiness seen.
      • build: PASS.
      • e2e @smoke: 10 passed.
      • full e2e: 32 passed (Chromium and Firefox).
    • Adversarial probe: a temporary, uncommitted Playwright spec, deleted before teardown, run with npx playwright test e2e/qa17-probe.spec.ts --project=chromium. 2 failed and 1 passed (details below).

    Findings

    F1, High (blocks AC2/AC3, D3/D4): re-applying a recently used filter leaves the release stuck on "Loading…" indefinitely.

    • Reproduction (composed mock, [email protected]):
      1. Type gamma in Process Name. Gamma shows correctly.
      2. Click Clear search, or change the field to beta.
      3. Within about 30 s, type gamma again.
    • Expected: the filtered Gamma tree shows again.
    • Actual: the rows stay ["Synthetic precision fixture fixture v1", "Loading Synthetic precision fixture…"] after more than 6.5 s. The live summary never appears and Gamma cannot be reached or selected. Both probe variants (clear then retype, and A → B → A) failed the same way.
    • Cause:
      • filterRef.current is updated in the parent ProcessTree useEffect (apps/frontend/src/components/process-tree/ProcessTree.tsx:306-308).
      • The new BranchLoader's report effect (ProcessTree.tsx:132-144) is a child effect, so it runs first in the same commit.
      • onLoad therefore drops that initial report as coming from a "superseded" filter (ProcessTree.tsx:326).
      • When the query is cold, a later status change re-reports it, which hides the bug. When TanStack already holds fresh cached data for that key (staleTime: 30_000, apps/frontend/src/app/ApplicationProviders.tsx:35), no further report is ever made. The view keeps an empty load and renders the loading pseudo-row.
    • Common user actions trigger it: retyping a query, backspacing then retyping past the debounce, or toggling between two queries.
    • Suggested fix direction (Engineering's choice): make the current filter visible to onLoad before child effects run, for example by assigning it during render or in a layout effect, or by comparing against the scope passed with the report. Add a regression test that re-applies a cached filter within staleTime.
    • The existing tests miss it: every component and e2e case uses a fresh filter key.

    F2, Low (non-blocking, D4/D5 polish): collapsing a filtered release root discards its loaded results.

    • When a root is collapsed, its loader unmounts and the filtered load is deleted (ProcessTree.tsx:332-341 keeps only unfiltered pages).
    • The root's accessible name loses its exact count ("…fixture v1, 3 processes" becomes "…fixture v1"). The polite summary and the "No processes match your search." message also disappear while any root is collapsed, because settled needs every root load (ProcessTree.tsx:455-464).
    • Re-expanding restores the results correctly from cache: the probe saw the same 8 rows and "3 processes match your search."
    • Consider keeping filtered root pages while collapsed, as is already done for unfiltered pages.

    Per-criterion verdicts

    • AC1, PASS.
      • Process Name is the default field. Clear search shows only when any field has text. Advanced search has aria-expanded and aria-controls and reveals 4 labelled fields. There is one control per field, each with maxLength 256.
      • normalizeFields trims, collapses whitespace and omits empty fields, sending case and punctuation literally. The mock ANDs tokens and fields as literal substrings, with no regex or Boolean handling.
      • Component evidence: the multiword plus Geography AND test. Browser evidence: road service + de gives only Beta.
    • AC2, FAIL (F1).
      • What works: the debounce is 200 ms with a single onChange, Clear applies immediately, and the component race test shows the slow earlier rail query is aborted and never replaces ship. Code review confirms results are read only for the current scoped key and superseded filter loads are purged.
      • What fails: the same filter-scoping guard drops the current query's own result when it comes from cache, so a newer valid query never renders.
    • AC3, FAIL (F1).
      • What works:
        • Only matching leaves and ancestors render, expanded, with exact counts. Browser evidence: "road" gives 3 leaves across levels 1–6, ancestors aria-expanded=true, counts 3/3/3/3/1.
        • Zero-match release rows, the "No processes match your search." message, and error then Retry recovery work, with selections intact.
        • Keyboard End + Space selects in filtered mode. Typing and results never steal focus.
      • What fails: the tree can be stuck on loading, so matching leaves never appear (F1). F2 is a minor count and summary loss while collapsed.
    • AC4, PASS.
      • Clear resets all 5 fields, focuses Process Name, and restores prior unfiltered expansion and pages with the selection retained.
      • Storage keys are unchanged in e2e and in the component test (localStorage and sessionStorage empty).
      • Search state is component state in Workspace only (App.tsx).
    • AC5, PASS with a gap. Whitespace, mixed case, field AND, literal punctuation (STEEL.*, steel.+, (diesel)), cancellation races and no-match cases are covered. Browser probe: whitespace-only input gives the unfiltered tree, and .* gives a literal zero match. There is no regression case for re-applying a cached filter (F1).

    Other review notes

    Next action

    Engineering fixes F1 and adds a regression test, then QA rechecks at the new SHA with unit, e2e and the cached re-apply probe. F2 is optional in this PR or can be a follow-up.

  8. DavidVFitzGerald commented on Nov 14, 2026

    @DavidVFitzGerald
    OwnerAuthor

    Engineering: fixes for QA and hosted CI — READY FOR QA re-check at 3bbf34e (PR #54).

    • QA F1 (High): a filter answered from the query cache stayed on Loading. Fixed by removing the superseded-filter guard in onLoad: only mounted loaders report, and superseded scopes are still purged on filter change. Regression test: process-search.test.tsx › renders a filter reused from the query cache (no new requests, no Loading row, summary present).
    • QA F2 (Low): a collapsed filtered release now keeps its results, count and live summary. Regression test: keeps a collapsed filtered release's count and the summary.
    • Hosted full run failure at bcc5181 (https://github.com/DavidVFitzGerald/LCA-diff/actions/runs/43614206011): in Firefox the Process Name input's intrinsic width pushed Clear × under the comparison pane, so it couldn't be clicked. Inputs now fill the sidebar width, and process-search.spec.ts asserts the controls stay inside the sidebar. That assertion fails in Firefox without the fix.
    • Container: both new component tests fail without the fix and pass with it; format, lint, typecheck and build PASS; test:unit 214/214 (3 consecutive runs); @smoke 10; full e2e 32 PASS.
  9. DavidVFitzGerald commented on Nov 14, 2026

    @DavidVFitzGerald
    OwnerAuthor

    QA: PASS

    Re-check at SHA 3bbf34e (branch feat/f3-search, PR #54), following the QA FAIL at bcc5181. Phase 1, mock mode only. Rootless compose project lca-diff-qa17 in a fresh detached worktree at 3bbf34e. This is not evidence of real search, auth or server-side matching parity (I1). Hosted CI is the coordinator's job.

    Commands and results (container only)

    • COMPOSE_PROJECT_NAME=lca-diff-qa17 FRONTEND_PORT=5191 ./dev up && ./dev check: PASS.
    • git diff --name-only main...3bbf34e: no package.json or lockfile changes.
    • docker compose -p lca-diff-qa17 exec -T workspace bash -lc 'cd apps/frontend && npm ci --no-audit --no-fund && npm run format:check && npm run lint && npm run typecheck && (npm run test:unit x4) && npm run build && npm run test:e2e -- --grep @smoke && npm run test:e2e': exit 0.
      • npm ci (frozen): 232 packages.
      • format:check, lint and typecheck: PASS.
      • test:unit: 214/214 on each of 4 consecutive runs.
      • build: PASS.
      • e2e @smoke: 10 passed.
      • full e2e: 32 passed (Chromium and Firefox).
    • Adversarial probe: a temporary, uncommitted spec, deleted before teardown, run with npx playwright test e2e/qa17-probe.spec.ts. All cases passed in both browsers.

    Re-check of earlier findings

    • F1 (High), FIXED.
      • Search gamma, change to beta, then search gamma again: Gamma and its 4 expanded ancestors render with no Loading row.
      • Search gamma, Clear, then search gamma again: same result, and "1 process matches your search." is announced.
      • The new component test also shows the cached filter is answered with no new requests.
    • F2 (Low), FIXED. In the "road" filter, collapsing the release root keeps …, 3 processes and "3 processes match your search." Re-expanding restores the 3 matching leaves.
    • Superseded results are purged and never render stale.
      • Code review (ProcessTree.tsx onLoad/purge effect):
        • The view reads only loads with the current filter prefix.
        • A filter change unmounts the old loaders, so TanStack aborts their signals.
        • Their final cleanup report is removed by the parent purge effect, which runs after child effects in the same commit.
      • Browser probe: gamma → beta → alpha typed in quick succession, 3 times in a row. Only Alpha rendered, with no Beta or Gamma rows and no Loading row, including 400 ms after settling.
      • The component race test (slow rail aborted, never replacing ship) still passes.
    • Hosted Firefox layout fix. The Clear × right edge is at 219.0 px against a sidebar right edge of 219 px in both browsers, and it is clickable. process-search.spec.ts now asserts that containment.

    Per-criterion verdicts

    • AC1, PASS. Unchanged since bcc5181: default Process Name field, labelled Advanced disclosure, normalized AND fields.
    • AC2, PASS. 200 ms debounce, aborted obsolete work, no stale overwrite, and cached filters now render.
    • AC3, PASS. Only matching leaves and ancestors show, expanded, with exact counts. Collapsed filtered roots keep their count and the summary. No-results, zero-match release rows and error/Retry work, and selections stay intact.
    • AC4, PASS. Clear resets all fields, focuses Process Name, restores the unfiltered tree and keeps the selection. Storage is unchanged.
    • AC5, PASS. The earlier cases still pass, plus new regression tests for cached reuse and collapsed filtered releases.
    • D1–D7: consistent. Focus is never stolen, keyboard navigation and selection work in filtered mode, and nothing is persisted.
    • Services boundary: no component imports mocks or calls HTTP, Firebase or storage.
    • [Task] F3: render the paginated release and nested process tree #16/[Task] F3: manage individual selection order and a virtualized selected-process list #18: no regressions in the unit or full e2e suites.
    • ADR: none needed; no PRD or spec deviation.

    Non-blocking notes

    • My first probe in this container's Firefox reported "Page crashed" inside Playwright locator.evaluateAll for 3 cases. The same flows rewritten with locator assertions passed in Firefox, and the full suite passes, so this is a harness/browser quirk, not an application failure. It is worth watching if a future spec uses evaluateAll in Firefox.

    Next action

    Coordinator: hosted CI, then maintainer review and merge.

  10. DavidVFitzGerald commented on Nov 14, 2026

    @DavidVFitzGerald
    OwnerAuthor

    Coordinator: QA re-check PASS at 3bbf34e (issuecomment-6880597190), after the FAIL at bcc5181. Hosted CI PASS at 3bbf34e (PR quality run 43614944312, full dispatch run 43614973440). State: ready for review; PR #54 awaits maintainer merge. Non-blocking: QA saw Playwright evaluateAll page crashes in container Firefox with an ad-hoc probe; the committed specs don't use it. Watch for this in future specs.

  11. DavidVFitzGerald commented on Nov 14, 2026

    @DavidVFitzGerald
    OwnerAuthor

    Closed by coordinator: PR #54 merged by the maintainer after QA PASS (re-check at 3bbf34e) and hosted CI PASS.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    frontendtask

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions