Skip to content

FE-3142 fix(agent): type the unknown value in the free-use placement test - #19840

Closed
dante01yoon wants to merge 1 commit into
mainfrom
jaewon/fe-3142-type-the-free-use-placement-test
Closed

dante01yoon wants to merge 1 commit into
mainfrom
jaewon/fe-3142-type-the-free-use-placement-test

Conversation

@dante01yoon

@dante01yoon dante01yoon commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Type the unknown-value row of the free-use placement test as the untyped wire payload it models, so main typechecks again. Test-only change, two lines.

Why

main fails pnpm typecheck since #19712 merged (2026-10-02 00:02 UTC), so every PR's CI, which builds the PR merged with main, fails the typecheck and everything that builds behind it: lint-pr / typecheck, the Tests E2E gates, Dist Telemetry Scan, OSS Assets Validation, Size Data and perf-tests all stop at the same single diagnostic:

src/workbench/extensions/agent/experiments/freeUsePlacement.test.ts(44,7): error TS2322: Type 'string | undefined' is not assignable to type '"above-input" | "control" | "inside-input" | "near-composer" | "top-banner" | undefined'.

Root cause

RemoteConfig is Partial<GetFeaturesResponses[200]> & {...}, and the generated ingest type (#19526) declares 'agent-free-use-message-placement' as a closed five-value union. #19712 also added 'agent-free-use-message-placement'?: string in src/platform/remoteConfig/types.ts, but intersecting string with the union leaves the union, so that line has no effect.

The union is only a compile-time claim: at runtime commitRemoteConfigSuccess assigns a raw Record<string, unknown> into remoteConfig.value without validating it, and isFreeUseVariant takes string | undefined, so the hook's fallback to control for a value it does not know is correct. The test was wrong to type its payload as RemoteConfig: the 'unknown' row feeds a value the server could send but the generated type rules out.

How

The row builds the payload as the untyped record it is on the wire (Record<string, unknown>) and assigns that to remoteConfig.value, the same way production does. Both rows (undefined and 'unknown'), their names and their assertions are unchanged. No cast, no any, no suppression.

Rejected: widening the production type with Omit<..., key> & { key?: string } (the omit-and-redeclare pattern docs/guidance/typescript.md forbids, and it would drop the generated contract for the values the server does send), a double assertion ('unknown' as unknown as ..., banned), and JSON.parse (returns any).

Review Focus

  • Test-only; no production type or behavior changes. The fallback rows still catch a regression: making isFreeUseVariant always return true turns both red.
  • Left alone on purpose: the dead 'agent-free-use-message-placement'?: string line in src/platform/remoteConfig/types.ts (a stale leftover, can be removed separately) and a similar unnecessary double cast in src/composables/auth/useTurnstile.test.ts:59.
  • Backport: cloud/1.55 has no such key in its generated /features type (it is a plain string there), so the backport [backport cloud/1.55] feat(agent): run the free-use messaging placement experiment (#19712) #19830 already typechecks with the original test and cherry-picking this fix there is harmless. No backport label on purpose.
  • The same sweep over src found no other plain string | undefined assigned to a literal-union key of the generated /features response.

AS IS / TO BE

AS IS: AS IS at 2bbba14425: pnpm typecheck, the command lint-pr / typecheck runs, exits 2 with exactly one diagnostic, freeUsePlacement.test.ts(44,7): error TS2322: Type 'string | undefined' is not assignable to the five-value placement union, while vitest does not typecheck so pnpm test:unit on that file passes 4 of 4 with exit 0, keeps control for undefined and keeps control for unknown included

TO BE: TO BE at 9fcbaf060a: pnpm typecheck prints no diagnostic and exits 0 on a cold typecheck cache, pnpm test:unit on freeUsePlacement.test.ts passes 4 of 4 with exit 0, and with isFreeUseVariant temporarily made to always return true keeps control for undefined fails on the exposure payload (placement undefined instead of control) and keeps control for unknown fails on the variant ('unknown' instead of control), 2 failed and 2 passed with exit 1, and git status is empty once the edit is reverted

The evidence is the pnpm typecheck output on the current main tip and on this branch, and the test run.

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

🎨 Storybook: ✅ Built — View Storybook

Details

⏰ Completed at: 10/02/2026, 12:37:05 AM UTC

Links

🌾 Fallow: ✅ Passed

Fallow audits the diff for duplication, complexity and dead code. It gates on new findings only, so when the audit completes, a red is something this PR introduced or moved — never inherited backlog. A red can also mean the audit itself did not finish; the details below say which happened.

No new findings in the changed files.

Reproduce locally
# the base the gate compared against
npx fallow audit --root . --quiet --format json \
  --changed-since 2bbba14425d6959a2f5c0180bb9833705041662b

Full docs: ADR-DEVEX-LINT-0015

🧩 Custom Nodes Ecosystem Matrix: 🟡 Withheld — could not measure

Executes the frontend JS of every registry pack that ships any, against this change, in both renderers. The eight ecosystem-matrix shard checks are a harness self-test; the pack verdict is matrix-verdict.

This candidate changes nothing the matrix measures, so every expensive stage was skipped.

Reproduce locally
# build one shard's fixture, then run it
python3 scripts/registry-census/build_matrix.py --shard 1/4
MATRIX_RENDERER=vue MATRIX_VUE=1 \
  npx vitest run --config vitest.matrix.config.mts

Full docs: scripts/registry-census/README.md

@coderabbitai

coderabbitai Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: Comfy-Org/ComfyUI_frontend/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: a59a3777-3205-4b2f-8271-7040e3980c8f

📥 Commits

Reviewing files that changed from the base of the PR and between 2bbba14 and 9fcbaf0.

📒 Files selected for processing (1)
  • src/workbench/extensions/agent/experiments/freeUsePlacement.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The unknown-placement test now assigns its unchanged configuration through a Record<string, unknown> variable before setting remoteConfig.value.

Changes

Test configuration assignment

Layer / File(s) Summary
Typed configuration assignment
src/workbench/extensions/agent/experiments/freeUsePlacement.test.ts
The test stores the placement configuration in a Record<string, unknown> variable before assigning it to remoteConfig.value. The key and value remain unchanged.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Bug fix

Suggested reviewers: christian-byrne

Merge Risk: ⚪ Minimal · up to 9fcba

This test-only typing change preserves the existing fixture and assertions, with no concrete merge-blocking risk identified.

Architecture Summary

Architecture risk: 🔵 Low · up to 9fcba

The change affects 1 system.

Changed systems: src

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — src (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in src/workbench/extensions/agent/experiments/freeUsePlacement.test.ts: The test now stores the placement configuration in a Record<string, unknown> variable before assigning it to remoteConfig.value; the key and value are unchanged.
🚥 Pre-merge checks | ✅ 6 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
End-To-End Regression Coverage For Fixes ⚠️ Warning The PR title and commit subject contain the bug-fix signal “fix”. The PR changes src/workbench/extensions/agent/experiments/freeUsePlacement.test.ts and no file under browser_tests/. The descripti… Add or update a Playwright regression test under browser_tests/, or add a concrete explanation in the PR description stating why an end-to-end regression test is not practical.
✅ Passed checks (6 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Website End-To-End Regression Coverage ✅ Passed The PR changes only src/workbench/extensions/agent/experiments/freeUsePlacement.test.ts. It does not change files under apps/website/src/ or apps/website/public/, so this website-specific check …
Adr Compliance For Entity/Litegraph Changes ✅ Passed The changed-file list contains only src/workbench/extensions/agent/experiments/freeUsePlacement.test.ts. It does not modify src/lib/litegraph/, src/ecs/, or a graph-entity-related file. The ADR …
Title check ✅ Passed The title clearly identifies the test-only type fix for the unknown free-use placement value and matches the main change.
Description check ✅ Passed The description explains the problem, root cause, implementation, validation evidence, and review focus. It does not use the template's explicit "## Changes" heading, but it provides the required chan…
Full details: End-To-End Regression Coverage For Fixes

Explanation

The PR title and commit subject contain the bug-fix signal “fix”. The PR changes src/workbench/extensions/agent/experiments/freeUsePlacement.test.ts and no file under browser_tests/. The description explains the typecheck issue and the unit-test change, but it does not give a concrete reason why an end-to-end regression test was not added.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Oct 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

@@            Coverage Diff             @@
##             main   #19840      +/-   ##
==========================================
+ Coverage   84.74%   85.49%   +0.74%     
==========================================
  Files        3412     2397    -1015     
  Lines      163766   137028   -26738     
  Branches    44655    36989    -7666     
==========================================
- Hits       138790   117147   -21643     
+ Misses      23029    19515    -3514     
+ Partials     1947      366    -1581     
Flag Coverage Δ
billing-web-unit ?
unit 82.22% <ø> (ø)
website-unit ?

Flags with carried forward coverage won't be shown. Click here to find out more.
see 1017 files with indirect coverage changes

🚀 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.

@github-actions github-actions Bot added the risk:medium PR risk grade (advisory shadow check; grader-owned) label Oct 2, 2026

@christian-byrne christian-byrne 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.

The test now models the unvalidated wire payload without weakening the generated production contract. The fallback assertions remain unchanged, the two-line diff is thread-free, and current-head CI is settled green.

@dante01yoon
dante01yoon added this pull request to the merge queue Oct 2, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Oct 2, 2026
@dante01yoon

Copy link
Copy Markdown
Collaborator Author

Closing as superseded. While this sat in the merge queue, main moved to ea63d4aa57 (#18154), which also rewrote the same test row (Reflect.set(remoteConfig.value, 'agent-free-use-message-placement', value)), so the TS2322 on freeUsePlacement.test.ts(44,7) is gone and this change now conflicts in that file (the queue removed it at 00:58 with merge_conflict). Nothing else in this PR is needed.

@dante01yoon dante01yoon closed this Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk:medium PR risk grade (advisory shadow check; grader-owned)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants