Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Rate limit exceeded@chhoumann has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 4 minutes and 12 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (2)
WalkthroughAdds a runtime-backed Changes
Sequence Diagram(s)sequenceDiagram
participant UserScript as User Script
participant Engine as MacroChoiceEngine (params)
participant Backing as sharedVariables (Map)
participant ChoiceExec as choiceExecutor
Note over Engine,Backing: Engine creates sharedVariables and variablesProxy
Engine->>Backing: create sharedVariables Map
Engine->>Engine: createVariablesProxy(sharedVariables)
UserScript->>Engine: read params.variables (getter)
Engine->>UserScript: return variablesProxy (reflects Backing)
alt Script assigns a new object/Map (params.variables = newObj)
UserScript->>Engine: params.variables = newObj
Engine->>Backing: clear()
Engine->>Backing: populate entries from newObj
Engine->>ChoiceExec: choiceExecutor reads variables from Backing (updated)
else Script mutates same backing (in-place)
UserScript->>Backing: mutate via proxy (add/update keys)
Backing-->>ChoiceExec: choiceExecutor reads variables including mutations
else Script assigns invalid value (e.g., number)
UserScript->>Engine: params.variables = invalid
Engine-->>UserScript: ignore invalid assignment (do not clear Backing)
Engine->>ChoiceExec: choiceExecutor sees Backing with any in-place mutations
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/engine/MacroChoiceEngine.ts (1)
88-121: LGTM! Clean implementation of the variables proxy with backward-compatible assignment semantics.The dynamic property definition correctly handles both object and Map assignment, enabling scripts to replace the backing store while maintaining the proxy interface. The setter's clear-and-repopulate approach ensures downstream templates can consume updated variables.
Optional optimization: The self-assignment guard at line 104 could also check
next === variablesProxyto avoid an unnecessary clear+repopulate cycle when a script doesparams.variables = params.variables. Currently this results in clearing and repopulating the Map with identical entries, which is functionally correct but inefficient.set: (next: unknown) => { - if (next === sharedVariables) return; + if (next === sharedVariables || next === variablesProxy) return; const entries =Optional clarification: The comment at line 99 mentions
QuickAdd.variablesbut the code definesparams.variables. Consider updating the comment to match the actual property name for clarity:-// Backward compatibility: some scripts assign `QuickAdd.variables = {...}`. +// Backward compatibility: some scripts assign `params.variables = {...}`.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/engine/MacroChoiceEngine.entry.test.ts(1 hunks)src/engine/MacroChoiceEngine.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 underengine/,services/, andutils/; Svelte UI insrc/gui; shared types insrc/types; settings entry insrc/quickAddSettingsTab.ts
Files:
src/engine/MacroChoiceEngine.entry.test.tssrc/engine/MacroChoiceEngine.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 theloggerutilities for consistent output
Structure production code so Obsidian dependencies are injected behind interfaces; unit tests target pure logic and swap in adapters ortests/obsidian-stub.ts
Files:
src/engine/MacroChoiceEngine.entry.test.tssrc/engine/MacroChoiceEngine.ts
src/**/*.{ts,tsx,svelte}
📄 CodeRabbit inference engine (AGENTS.md)
Use PascalCase for classes and Svelte components
Files:
src/engine/MacroChoiceEngine.entry.test.tssrc/engine/MacroChoiceEngine.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.entry.test.ts
🧬 Code graph analysis (2)
src/engine/MacroChoiceEngine.entry.test.ts (4)
src/types/macros/IUserScript.ts (1)
IUserScript(3-6)src/types/choices/IMacroChoice.ts (1)
IMacroChoice(4-7)src/types/macros/IMacro.ts (1)
IMacro(3-7)src/engine/MacroChoiceEngine.ts (1)
MacroChoiceEngine(58-648)
src/engine/MacroChoiceEngine.ts (3)
src/utils/variablesProxy.ts (1)
createVariablesProxy(7-54)src/quickAddApi.ts (1)
QuickAddApi(33-643)src/errors/MacroAbortError.ts (1)
MacroAbortError(1-6)
🔇 Additional comments (2)
src/engine/MacroChoiceEngine.entry.test.ts (2)
329-371: LGTM! Excellent regression coverage for replacement semantics.This test correctly validates that assigning a new object to
params.variablesreplaces the backing Map entirely, removing pre-existing keys. The test structure is clear and aligns with the PR objective to preserve macro variables when scripts reassign the map.
373-416: LGTM! Good coverage for self-assignment edge case.This test validates that self-assigning the proxy doesn't inadvertently clear existing variables. The scenario of
params.variables = params.variablesfollowed by mutation is an important edge case to cover.
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/engine/MacroChoiceEngine.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 underengine/,services/, andutils/; Svelte UI insrc/gui; shared types insrc/types; settings entry insrc/quickAddSettingsTab.ts
Files:
src/engine/MacroChoiceEngine.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 theloggerutilities for consistent output
Structure production code so Obsidian dependencies are injected behind interfaces; unit tests target pure logic and swap in adapters ortests/obsidian-stub.ts
Files:
src/engine/MacroChoiceEngine.ts
src/**/*.{ts,tsx,svelte}
📄 CodeRabbit inference engine (AGENTS.md)
Use PascalCase for classes and Svelte components
Files:
src/engine/MacroChoiceEngine.ts
🧬 Code graph analysis (1)
src/engine/MacroChoiceEngine.ts (3)
src/utils/variablesProxy.ts (1)
createVariablesProxy(7-54)src/quickAddApi.ts (1)
QuickAddApi(33-643)src/errors/MacroAbortError.ts (1)
MacroAbortError(1-6)
🔇 Additional comments (4)
src/engine/MacroChoiceEngine.ts (4)
50-50: LGTM!The import is correctly added and aligns with the new variable proxy functionality.
88-97: LGTM!The variables proxy is correctly initialized, and the type assertion pattern is appropriate for the dynamic property definition that follows.
102-103: LGTM!The getter correctly returns the variables proxy, enabling scripts to read variables.
118-120: LGTM!The property descriptor configuration is appropriate:
enumerable: trueensures visibility in standard object iterations, andconfigurable: falseprotects the getter/setter mechanism from being overridden or deleted.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/engine/MacroChoiceEngine.ts (1)
114-116: Consider logging when an invalid assignment is ignored (debuggability).
Silent no-ops can be hard to diagnose in user scripts; alog.logWarning(...)here would help without changing behavior.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/engine/MacroChoiceEngine.entry.test.ts(1 hunks)src/engine/MacroChoiceEngine.ts(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/engine/MacroChoiceEngine.entry.test.ts
🧰 Additional context used
📓 Path-based instructions (3)
src/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
Source code lives in
src/: core logic underengine/,services/, andutils/; Svelte UI insrc/gui; shared types insrc/types; settings entry insrc/quickAddSettingsTab.ts
Files:
src/engine/MacroChoiceEngine.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 theloggerutilities for consistent output
Structure production code so Obsidian dependencies are injected behind interfaces; unit tests target pure logic and swap in adapters ortests/obsidian-stub.ts
Files:
src/engine/MacroChoiceEngine.ts
src/**/*.{ts,tsx,svelte}
📄 CodeRabbit inference engine (AGENTS.md)
Use PascalCase for classes and Svelte components
Files:
src/engine/MacroChoiceEngine.ts
🧬 Code graph analysis (1)
src/engine/MacroChoiceEngine.ts (2)
src/utils/variablesProxy.ts (1)
createVariablesProxy(7-54)src/errors/MacroAbortError.ts (1)
MacroAbortError(1-6)
🔇 Additional comments (1)
src/engine/MacroChoiceEngine.ts (1)
88-125: Good backward-compatibility shim forparams.variables(getter/setter + self-assignment no-op).
This should address the “script-set variables not seen by templating” regression while preventing accidental clearing onparams.variables = params.variables.
|
🎉 This PR is included in version 2.9.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Fixes #1014. Fixes #1010.
Both issues report user scripts populating variables, but Templater behaves as if the values were never set (prompting for missing
{{VALUE:*}}fields).This PR makes
params.variablesa getter/setter backed by the shared variablesMap:Map(QuickAdd.variables = {...}/params.variables = {...}) replaces the backing store so downstream templating sees the new values.Map/params.variables = params.variables) is treated as a no-op to avoid clearing variables.Tests:
bun run test.Summary by CodeRabbit
Tests
Bug Fixes
✏️ Tip: You can customize this high-level summary in your review settings.