Skip to content

feat(template): add Do nothing to Keep existing file - #2245

Merged
chhoumann merged 2 commits into
masterfrom
issue-2244
Oct 18, 2026
Merged

chhoumann merged 2 commits into
masterfrom
issue-2244

Conversation

@chhoumann

@chhoumann chhoumann commented Oct 16, 2026 •

Copy link
Copy Markdown
Owner

Why

With Open off and If the target file already exists set to Keep existing file, a Template choice still opened the existing note, and there was no way to keep it closed. That auto-open is a released feature (#867, from #61), so this change adds an option instead of changing it. Fixes #2244.

What changed

  • Keep existing file now has a Keep action row with two options. Open existing file is the current behavior and opens the note even when Open is off. Do nothing leaves the note alone and lets Open decide.
  • When a choice set to Do nothing leaves the note closed, and no link or clipboard step shows it, QuickAdd shows "'' already exists." so the run is not silent.
  • The Ask every time prompt keeps the same six items, and each one does what it did before. Its last item, which opened the note, now reads Open existing file.

Scope

  • No settings migration. Saved choices keep the stored id doNothing, now labeled Open existing file, and behave as before. The new option is leaveUnchanged.
  • The prompt has no Do nothing item. Escape already leaves the note alone.
  • The Open note action for a selected existing note (Search existing notes) is unchanged.

Tradeoffs

  • Renaming the stored id to match the new label would need a migration. Packages exported from older versions and older QuickAdd installs on synced devices would then read existing choices wrong.

Blast Radius

Existing choices and prompt picks behave as before. An older QuickAdd on a synced device cannot run or edit a choice saved with Do nothing, because it does not know the new mode. Any new mode has this limit.

Verification

  • Native E2E tests/e2e/file-exists-behavior.test.ts runs every mode with Open off. Against master's code, only leaveUnchanged fails, and doNothing already opens the note. With the change, all 35 tests pass.
  • In live Obsidian, a choice set to Do nothing with Open off was run twice from the command palette. The first run shows "Created 'Standup 2026-10-18'." and the second shows "'Standup 2026-10-18' already exists." Only Home.md stays open.
  • pnpm run test (6900 passed) and pnpm run lint pass.

Keep action row

Ask every time prompt

Do nothing with Open off, run twice


Note

Medium Risk
Changes template collision UX and auto-open behavior for existing notes; legacy doNothing keeps prior behavior but older QuickAdd versions cannot read leaveUnchanged.

Overview
Keep existing file now exposes a Keep action with two choices instead of one implicit behavior. Open existing file (doNothing, unchanged stored id) still opens the colliding note even when Open is off. Do nothing (leaveUnchanged) leaves the file closed unless Open is on.

The template engine uses opensExistingFile on reuse-existing resolutions rather than always auto-opening. When a run ends with effect: unchanged and nothing opens or links the note, it shows an "'…' already exists." notice (same pattern as create notices).

The Ask every time prompt renames the old Do nothing entry to Open existing file and omits the new true no-op (Escape already dismisses). Docs and CLI effect wording now refer to Keep existing file instead of the old Do nothing label.

The choice builder always shows the mode row for update/create/keep (including Keep action). Saved choices keep doNothing without migration.

Reviewed by Cursor Bugbot for commit 2c36246. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Add 'Do nothing' keep mode for existing files in Template choices

  • Splits the former single keep behavior into two modes in fileExistsPolicy.ts: 'Open existing file' (renamed from 'Do nothing') always opens the existing file, and the new 'Leave unchanged' opens it only when the Open setting is enabled. Both resolve to reuseExisting.
  • The Template choice form now shows a Keep action row with both modes, and existing-file reuse in TemplateChoiceEngine.ts opens according to the selected mode instead of always opening.
  • Runs that keep an existing file without opening it now emit an unchanged-file notice from TemplateChoiceEngine.run.
  • File-exists prompts still offer only the always-open mode; the leave-unchanged mode is excluded from getPromptModes.
  • Adds unit tests in TemplateChoiceEngine.collision.test.ts, form tests, and an end-to-end suite in file-exists-behavior.test.ts covering all collision modes with Open disabled.
  • Behavioral Change: the doNothing mode ID keeps its ID but its label and behavior now mean 'Open existing file' — it always opens the existing file even when Open is disabled; previously the Open setting could suppress this. Persisted leaveUnchanged values now resolve via a legacy mapping instead of being unmapped.

Macroscope summarized 2c36246.

Summary by CodeRabbit

  • New Features
    • Added a Do nothing option under Keep existing file. It leaves an existing file unchanged and opens it only when Open is enabled.
    • The Open existing file option now opens the file regardless of the Open setting.
    • When a file is kept closed and unchanged, a notice indicates that it already existed.
  • Bug Fixes
    • Corrected the behavior and descriptions of existing-file actions across the template settings and CLI documentation.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Deploying quickadd with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2c36246
Status: ✅  Deploy successful!
Preview URL: https://f6f44ba0.quickadd.pages.dev
Branch Preview URL: https://issue-2244.quickadd.pages.dev

View logs

@chhoumann chhoumann linked an issue Oct 16, 2026 that may be closed by this pull request
@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8fd22bd5-6257-41ba-9b38-ea9a918a1211
📥 Commits

Reviewing files that changed from the base of the PR and between 2071b4f and 2c36246.

📒 Files selected for processing: 11
  • docs/src/content/docs/docs/Advanced/CLI.md
  • docs/src/content/docs/docs/Choices/TemplateChoice.md
  • src/engine/TemplateChoiceEngine.collision.test.ts
  • src/engine/TemplateChoiceEngine.ts
  • src/engine/choiceOutcomeRecorder.ts
  • src/gui/ChoiceBuilder/TemplateChoiceForm.svelte
  • src/gui/ChoiceBuilder/TemplateChoiceForm.test.ts
  • src/template/fileExistsPolicy.test.ts
  • src/template/fileExistsPolicy.ts
  • src/types/ChoiceOutcome.ts
  • tests/e2e/file-exists-behavior.test.ts
🚧 Files skipped from review as they are similar to previous changes: 1
  • docs/src/content/docs/docs/Choices/TemplateChoice.md

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

The keep behavior now offers separate actions to open an existing file or leave it unchanged. The engine applies the selected action’s opening behavior. The form, documentation, and tests reflect these options and outcomes.

Changes: Existing-File Open Behavior

Layer / File(s) Summary
Define existing-file actions
src/template/fileExistsPolicy.ts, src/gui/ChoiceBuilder/TemplateChoiceForm.svelte, src/gui/ChoiceBuilder/TemplateChoiceForm.test.ts, docs/src/content/docs/docs/Choices/TemplateChoice.md, docs/src/content/docs/docs/Advanced/CLI.md, src/engine/choiceOutcomeRecorder.ts, src/types/ChoiceOutcome.ts, src/template/fileExistsPolicy.test.ts
The keep modes now distinguish “Open existing file” from “Do nothing.” The form shows mode options based on the selected apply mode. The documentation and comments use the updated names and opening behavior.
Apply mode opening behavior
src/engine/TemplateChoiceEngine.ts
The engine sets auto-open from the selected mode. When an unchanged note is neither opened nor linked, the engine shows a notice that identifies it as already existing.
Test existing-file outcomes
src/engine/TemplateChoiceEngine.collision.test.ts, tests/e2e/file-exists-behavior.test.ts
Unit tests check opening behavior, notices, and errors for existing files. End-to-end tests check file outcomes and whether the note opens when Open is disabled.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature · Severity of issue fixed: Low

Merge Risk: ⚪ Minimal · up to 2c362

This change adds a Do nothing option for Keep existing file and keeps the existing behavior for saved choices. No actionable merge-blocking risk is evident.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Linked Issues check Warning Issue #2244 requires Template → Behavior → Open=false to prevent an existing target from opening for every existing-file setting. The current PR explicitly preserves doNothing as **Open existing fil… Change the existing-file flow so Open=false suppresses opening for doNothing and every other existing-file mode, or update the linked issue and acceptance criteria if the intended requirement is now only the new leaveUnchanged mode.
Docstring Coverage Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 8 files. (3 skipped: 3… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title accurately identifies the main change: adding a Do nothing keep action to Template’s Keep existing file behavior.
Out of Scope Changes check Passed The changes remain connected to the existing-file behavior in #2244. They add the Keep action modes, preserve the stored doNothing ID, update related documentation, and add unit, form, and E2E cover…
Full details: Out of Scope Changes check

Explanation

The changes remain connected to the existing-file behavior in #2244. They add the Keep action modes, preserve the stored doNothing ID, update related documentation, and add unit, form, and E2E coverage. No unrelated implementation or documentation change is demonstrated.

Full details: Linked Issues check

Explanation

Issue #2244 requires Template → Behavior → Open=false to prevent an existing target from opening for every existing-file setting. The current PR explicitly preserves doNothing as Open existing file, with opensExistingFile: true, so that mode still opens the target when Open is off. The new leaveUnchanged mode satisfies the issue only for that new mode.

Resolution

Change the existing-file flow so Open=false suppresses opening for doNothing and every other existing-file mode, or update the linked issue and acceptance criteria if the intended requirement is now only the new leaveUnchanged mode.

Full details: Docstring Coverage

Explanation

Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 8 files. (3 skipped: 3 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

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

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

A rabbit checks the file once more,
“Open” means open; “Do nothing” stays.
A quiet note, a clear report,
Two paths now guide its closing days.
Tests hop through each choice and case,
Then rest beside the policy’s page.

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

@chhoumann
chhoumann marked this pull request as ready for review October 16, 2026 21:18
@chhoumann

Copy link
Copy Markdown
Owner Author

Verifier verdict: PASS (independent agent, codex_pool/gpt-6-astra, run on a live Obsidian instance at a commit with the same patch as head 2071b4f3)

  • tests/e2e/file-exists-behavior.test.ts: 34 passed at head. With the engine reverted to master, only doNothing leaves the note closed fails.
  • Reporter flow, Keep existing file and Open off: run 2 leaves 0 tabs open and shows "'repro2244-test' already exists." With Open on, the note opens.
  • "Ask every time", then pick Do nothing with Open off: 0 tabs, no notice, file unchanged.
  • dev:errors: no errors captured.

@chhoumann
chhoumann marked this pull request as draft October 17, 2026 14:54
Keep existing file always opens the note, even with Open off. These
tests expect a second keep mode, Do nothing, that leaves the note
closed unless Open is on, while the saved mode keeps opening it.

Refs #2244
Keep existing file opened the note even with Open off, and there was no
way to keep it closed. Keep existing file now has two actions. Open
existing file is the old behavior, under the id that saved choices
already store. Do nothing leaves the note alone and lets Open decide.
When the choice is set to Do nothing and nothing else shows the note,
QuickAdd says the note already exists.

The Ask every time prompt keeps its items and what they do. Its Do
nothing item, which opened the note, is now labeled Open existing file.

Fixes #2244
@chhoumann chhoumann changed the title fix(template): let Open decide whether Keep existing file opens the note feat(template): add Do nothing to Keep existing file Oct 18, 2026
@chhoumann
chhoumann marked this pull request as ready for review October 18, 2026 07:40
@chhoumann

Copy link
Copy Markdown
Owner Author

Verifier verdict: PASS for head 2c36246a, the non-breaking redesign. The earlier verdict covered a version that changed Keep existing file and no longer applies. Independent agent (codex_pool/gpt-6-astra), live Obsidian 1.13.7.

  • tests/e2e/file-exists-behavior.test.ts: 35 passed.
  • Saved doNothing choice with Open off: the note opens, there is no notice, and the content is unchanged.
  • Do nothing with Open off: run 1 shows "Created 'new'." and opens no tab. Run 2 shows "'new' already exists." and opens no tab. With Open on, the note opens.
  • Ask every time: the items are Append to bottom, Append to top, Overwrite file, Increment trailing number, Append duplicate suffix, and Open existing file. Picking the last one opens the note.
  • Builder: the Keep action row offers Open existing file and Do nothing. Picking Do nothing saves to data.json.
  • dev:errors: no errors captured.

@chhoumann
chhoumann merged commit 040300d into master Oct 18, 2026
17 of 20 checks passed
@chhoumann
chhoumann deleted the issue-2244 branch October 18, 2026 07:44
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.

[BUG] Template open disabled - existing file still gets opened

1 participant