Skip to content

fix(preflight): preserve mapped dropdown defaults in capture#1175

Merged
chhoumann merged 3 commits intomasterfrom
1174-valueoption1option2|textdisplay1display2-capture-format-not-workversion-2120-obsidian-version-1127
Apr 27, 2026
Merged

fix(preflight): preserve mapped dropdown defaults in capture#1175
chhoumann merged 3 commits intomasterfrom
1174-valueoption1option2|textdisplay1display2-capture-format-not-workversion-2120-obsidian-version-1127

Conversation

@chhoumann
Copy link
Copy Markdown
Owner

@chhoumann chhoumann commented Apr 27, 2026

Fix mapped VALUE|text Capture defaults when one-page preflight is enabled.

The bug was that the one-page dropdown visually selected the first mapped option, but if the user submitted without touching the dropdown, the modal stored an empty string instead of the raw option value. Capture then treated that empty string as an intentional resolved value and emitted empty output like background-color:.

This change keeps formatter/runtime empty-string semantics intact and fixes the mismatch in the preflight dropdown path by seeding the submitted result with the same raw value the UI shows as selected. It also adds focused regression coverage and a live e2e covering the untouched-dropdown Capture flow.

Follow-up from review:

  • hardens the e2e against stale output by using a unique run marker and output file per test run
  • normalizes stale non-empty dropdown starting values to the first valid raw option
  • keeps the strict product-path e2e by exercising real quickadd:run behavior, using a narrowly scoped test-only diagnostic flag for CLI-verifiable one-page modal submission

Validation:

  • focused unit/regression tests for preflight and capture formatter mapping
  • real e2e for the one-page modal path in the dev vault
  • bun run build

Fixes #1174

Summary by CodeRabbit

  • Bug Fixes

    • Dropdown fields in modal inputs now properly initialize and persist their selected values, including automatic normalization of outdated or invalid selections to valid options.
  • Tests

    • Added comprehensive test coverage for modal dropdown initialization and value resolution logic.

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
quickadd Ready Ready Preview Apr 27, 2026 8:08pm

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8c119463-d8f8-4b43-8d86-b806141ae091

📥 Commits

Reviewing files that changed from the base of the PR and between 95dcc7d and 939cd46.

📒 Files selected for processing (1)
  • src/preflight/OnePageInputModal.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/preflight/OnePageInputModal.ts

📝 Walkthrough

Walkthrough

The PR fixes the {{VALUE:option1,option2|...}} capture format by introducing a resolveDropdownInitialValue resolver function that properly initializes dropdown selections in OnePageInputModal. The function normalizes stale initial values against available options and ensures resolved values are persisted to the result map before user interaction.

Changes

Cohort / File(s) Summary
Dropdown Value Resolution
src/preflight/suggesterValueMapping.ts, src/preflight/suggesterValueMapping.test.ts
Introduces new resolveDropdownInitialValue function that reconciles starting value with options, selecting the first option if starting value is empty or stale, and adds comprehensive test coverage for all initialization scenarios.
Modal Initialization
src/preflight/OnePageInputModal.ts, src/preflight/OnePageInputModal.test.ts
Updates dropdown initialization to use resolveDropdownInitialValue and immediately persist the resolved value to the result map. New test file covers both untouched and stale-value normalization cases with DOM polyfills and mocked dependencies.
Formatter Test Enhancement
src/formatters/captureChoiceFormatter-selection.test.ts
Extends test helper createFormatter to accept optional variables map, enabling choiceExecutor injection for VALUE template testing; adds test case verifying {{VALUE:...}} substitution without prompting.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • #1055: Overlaps with capture preflight/modal and VALUE-resolution code paths, addressing selection-as-value prefill and Capture VALUE handling.

Suggested labels

released

Poem

🐰 A dropdown once lost, now finds its way home—
Initial values resolved, no longer alone.
Colors cascade where templates decree,
Fixed VALUE formats dance wild and free! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(preflight): preserve mapped dropdown defaults in capture' directly summarizes the main fix—ensuring dropdown defaults are preserved in the capture preflight flow.
Linked Issues check ✅ Passed The PR successfully addresses issue #1174 by fixing the mapped VALUE capture format to submit the raw dropdown value instead of an empty string when untouched.
Out of Scope Changes check ✅ Passed All changes focus on resolving the dropdown initialization and value preservation issue in the preflight flow with targeted test additions and the new resolver function.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 1174-valueoption1option2|textdisplay1display2-capture-format-not-workversion-2120-obsidian-version-1127

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@chhoumann chhoumann marked this pull request as ready for review April 27, 2026 15:37
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Apr 27, 2026

Deploying quickadd with  Cloudflare Pages  Cloudflare Pages

Latest commit: 939cd46
Status: ✅  Deploy successful!
Preview URL: https://6b36395e.quickadd.pages.dev
Branch Preview URL: https://1174-valueoption1option2-tex.quickadd.pages.dev

View logs

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

@chhoumann chhoumann merged commit c078603 into master Apr 27, 2026
5 checks passed
@chhoumann chhoumann deleted the 1174-valueoption1option2|textdisplay1display2-capture-format-not-workversion-2120-obsidian-version-1127 branch April 27, 2026 20:15
chhoumann added a commit that referenced this pull request May 5, 2026
Add regression coverage for labeled VALUE dropdown tokens
({{VALUE:option-a,option-b|label:Pick one}}) in the One-page
input modal. The bug reported in issue #1180 reproduced at
v2.12.0 — capture wrote an empty value instead of the selected
option. The runtime fix landed in PR #1175 (`resolveDropdownInitialValue`
+ missing `setValue(req.id, selectedValue)` in OnePageInputModal),
but only the unlabeled id case was covered by tests.

Closes #1180
chhoumann added a commit that referenced this pull request May 5, 2026
Add regression coverage for labeled VALUE dropdown tokens
({{VALUE:option-a,option-b|label:Pick one}}) in the One-page
input modal. The bug reported in issue #1180 reproduced at
v2.12.0 — capture wrote an empty value instead of the selected
option. The runtime fix landed in PR #1175 (`resolveDropdownInitialValue`
+ missing `setValue(req.id, selectedValue)` in OnePageInputModal),
but only the unlabeled id case was covered by tests.

Closes #1180
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.

{{VALUE:option1,option2|text:display1,display2}} capture format not work【version 2.12.0, obsidian version 1.12.7】

1 participant