Skip to content

fix: honor Open File toggle for reuse#1007

Merged
chhoumann merged 1 commit intomasterfrom
fix/1001-open-file-tab
Dec 9, 2025
Merged

fix: honor Open File toggle for reuse#1007
chhoumann merged 1 commit intomasterfrom
fix/1001-open-file-tab

Conversation

@chhoumann
Copy link
Copy Markdown
Owner

@chhoumann chhoumann commented Dec 9, 2025

Summary

  • map legacy openInNewTab=false to reuse the active tab
  • align Open File settings modal default to reuse when toggle is off
  • add regression test for legacy open-file mapping

Testing

  • bun run test

Closes #1001

Summary by CodeRabbit

Bug Fixes

  • Updated file opening behavior: when the "open in new tab" option is disabled, files now correctly reuse the current tab instead of opening in a new tab. This change applies across file opening functionality and ensures consistent behavior in the file command settings.

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link
Copy Markdown

vercel Bot commented Dec 9, 2025

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

Project Deployment Preview Updated (UTC)
quickadd Ready Ready Preview Dec 9, 2025 9:34pm

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Dec 9, 2025

Walkthrough

This PR fixes a bug where the "Open File" command was always opening files in new tabs, regardless of the openInNewTab setting. The changes update three files to consistently return location: "reuse" (current tab) instead of location: "tab" (new tab) when openInNewTab is false.

Changes

Cohort / File(s) Summary
Fix "Open File" command tab reuse behavior
src/engine/helpers/openFileOptions.ts, src/engine/MacroChoiceEngine.openFileOptions.test.ts, src/gui/MacroGUIs/OpenFileCommandSettingsModal.ts
Updated legacy mapping and default behavior to return location: "reuse" instead of location: "tab" when openInNewTab is false. Test expectations updated to reflect the new correct behavior where files open in the current tab rather than a new tab.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10–15 minutes

  • Homogeneous changes (consistent "new tab" → "reuse" mapping across all three files)
  • Straightforward logic updates with no control flow complexity
  • Small, focused diff addressing a single bug
  • Areas to verify: Test assertions align with implementation; consistency of "reuse" behavior across all three files; correct resolution of the linked bug report

Possibly related PRs

  • feat: improve macro open file command #994: Modifies the same files (buildOpenFileOptions, deriveLocation, and OpenFileCommandSettingsModal) related to open-file tab behavior, though with different mapping logic changes.

Poem

🐰 A file opens wrong, always new, always spread,
But now with "reuse" the rabbit said,
Tabs stay put in the current view,
No more wandering—one tab, tab true! ✨

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ 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: honor Open File toggle for reuse' directly describes the main change: fixing the Open File command to respect the toggle setting when disabled (reusing the active tab instead of always opening a new tab).
Linked Issues check ✅ Passed The PR changes directly address the bug reported in #1001: mapping legacy openInNewTab=false to reuse the active tab, with test coverage and modal default alignment.
Out of Scope Changes check ✅ Passed All changes are focused and directly related to fixing the Open File toggle behavior; no unrelated modifications outside the stated objectives are present.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/1001-open-file-tab

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bcb5312 and 978af42.

📒 Files selected for processing (3)
  • src/engine/MacroChoiceEngine.openFileOptions.test.ts (1 hunks)
  • src/engine/helpers/openFileOptions.ts (1 hunks)
  • src/gui/MacroGUIs/OpenFileCommandSettingsModal.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
src/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Source code lives in src/: core logic under engine/, services/, and utils/; Svelte UI in src/gui; shared types in src/types; settings entry in src/quickAddSettingsTab.ts

Files:

  • src/engine/helpers/openFileOptions.ts
  • src/gui/MacroGUIs/OpenFileCommandSettingsModal.ts
  • src/engine/MacroChoiceEngine.openFileOptions.test.ts
src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

src/**/*.{ts,tsx}: Biome enforces tab indentation (width 2), LF endings, and an 80-character line guide; align editor settings
Use camelCase for variables and functions
Prefer type-only imports in TypeScript files
Route logging through the logger utilities for consistent output
Structure production code so Obsidian dependencies are injected behind interfaces; unit tests target pure logic and swap in adapters or tests/obsidian-stub.ts

Files:

  • src/engine/helpers/openFileOptions.ts
  • src/gui/MacroGUIs/OpenFileCommandSettingsModal.ts
  • src/engine/MacroChoiceEngine.openFileOptions.test.ts
src/**/*.{ts,tsx,svelte}

📄 CodeRabbit inference engine (AGENTS.md)

Use PascalCase for classes and Svelte components

Files:

  • src/engine/helpers/openFileOptions.ts
  • src/gui/MacroGUIs/OpenFileCommandSettingsModal.ts
  • src/engine/MacroChoiceEngine.openFileOptions.test.ts
🧠 Learnings (1)
📚 Learning: 2025-12-09T21:20:52.398Z
Learnt from: CR
Repo: chhoumann/quickadd PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-09T21:20:52.398Z
Learning: Applies to tests/**/*.{ts,tsx} : Add regression coverage for bug fixes

Applied to files:

  • src/engine/MacroChoiceEngine.openFileOptions.test.ts
🧬 Code graph analysis (1)
src/engine/MacroChoiceEngine.openFileOptions.test.ts (1)
src/engine/helpers/openFileOptions.ts (1)
  • buildOpenFileOptions (4-57)
🔇 Additional comments (3)
src/engine/helpers/openFileOptions.ts (1)

45-48: LGTM! Legacy mapping correctly fixed.

The change correctly maps openInNewTab: false to reuse the active tab instead of opening a new tab. The updated comment clearly documents the intent, and the logic aligns with the fix for issue #1001.

src/engine/MacroChoiceEngine.openFileOptions.test.ts (1)

29-34: LGTM! Test correctly updated for the fix.

The test name and expectation accurately reflect the corrected behavior. Setting location: undefined explicitly ensures the legacy mapping code path is tested, providing regression coverage for this bug fix. Based on learnings, this aligns with the guidance to add regression coverage for bug fixes.

src/gui/MacroGUIs/OpenFileCommandSettingsModal.ts (1)

164-164: LGTM! Modal default now aligns with engine behavior.

The change correctly updates the default open location to "reuse" when the toggle is off, aligning the UI modal's behavior with the fixed engine logic. This ensures the dropdown displays the correct default when openInNewTab is false.


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 merged commit 1b67d77 into master Dec 9, 2025
4 checks passed
@chhoumann chhoumann deleted the fix/1001-open-file-tab branch December 9, 2025 21:43
github-actions Bot pushed a commit that referenced this pull request Dec 9, 2025
# [2.9.0](2.8.0...2.9.0) (2025-12-09)

### Bug Fixes

* honor dateFormat in requestInputs ([903df23](903df23))
* preserve macro user script variable updates ([#999](#999)) ([26a7cf5](26a7cf5))
* reuse current tab when open file new-tab is off ([#1007](#1007)) ([1b67d77](1b67d77))

### Features

* improve macro open file command ([#994](#994)) ([9b4f177](9b4f177))
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Dec 9, 2025

🎉 This PR is included in version 2.9.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Dec 9, 2025

🚀 Release has been published: v2.9.0

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Macro "Open File" command ALWAYS opens file in new tab

1 participant