Skip to content

fix(macro): show a just-added Conditional's new condition and branch counts - #2151

Merged
chhoumann merged 1 commit into
masterfrom
fix/conditional-label-refresh
Oct 2, 2026
Merged

chhoumann merged 1 commit into
masterfrom
fix/conditional-label-refresh

Conversation

@chhoumann

@chhoumann chhoumann commented Oct 2, 2026 •

Copy link
Copy Markdown
Owner

On a macro's page, a Conditional step added in the same session kept "(missing variable) is truthy" after its condition was saved in the dialog, and "Then: 0" after its Then page was left with a step added. The edit was saved; reopening the macro showed it. Not new in #2141 (the dialog builder did the same), but #2141 makes the branch pages part of the same flow.

The condition dialog and the branch pages edit the step in place, and CommandList handed that same object back to the list. A step loaded from data.json is a plain object, which $state proxies, so the in-place edit re-rendered the row. A step added this session is a ConditionalCommand class instance, which $state does not proxy, and with the same reference handed back nothing re-rendered. updateCommand now puts a copy in the list. Persistence is unchanged: the list is still snapshotted to plain data before it is saved.

Checked in Obsidian 1.13.7: add a Conditional, set its condition to mood, and the row reads "$mood is truthy" at once; add a Wait on its Then page, go back, and it reads "Then: 1".

Tests

  • Two CommandList.conditional cases with a fresh ConditionalCommand (a class instance, as an added step is): the label after the condition dialog saves, and the Then count after the branch page reports an edit. Both fail on master.
  • pnpm run build-with-lint, pnpm run test (6620 passed) and .agents/run-e2e pass.

Fixes #2147

Note

Fix CommandList.updateCommand so in-place Conditional edits re-render

Adds regression tests in CommandList.conditional.test.ts that mutate a ConditionalCommand in place via edit callbacks and assert the summary and branch count update.

  • The fix: updateCommand in CommandList.svelte now passes a shallow copy to replaceById. The new object identity triggers reactivity for class-instance edits not proxied by $state.
  • Behavioral Change: updateCommand now persists a shallow copy of the command instead of the original reference.

Macroscope summarized ecd49bd.

Summary by CodeRabbit

  • Bug Fixes
    • Updated command summaries and branch counts to reflect condition changes and branch navigation correctly.

…counts

The condition dialog and the branch pages edit the step in place. A step
added this session is a class instance that $state does not proxy, and
the list got the same object back, so the row kept its old label.

Fixes #2147
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-02T19:16:25.884922Z ecd49bd Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

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: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 5d62d0ac-9717-43e2-986a-81a39322740f

📥 Commits

Reviewing files that changed from the base of the PR and between 3b9550d and ecd49bd.

📒 Files selected for processing (2)
  • src/gui/MacroGUIs/CommandList.conditional.test.ts
  • src/gui/MacroGUIs/CommandList.svelte

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


📝 Walkthrough

Walkthrough

updateCommand now shallow-copies an edited command before replacing it in the renderable list. Tests check that conditional summaries and then-branch counts update after edits.

Changes

Conditional command refresh

Layer / File(s) Summary
Refresh edited commands and verify conditional updates
src/gui/MacroGUIs/CommandList.svelte, src/gui/MacroGUIs/CommandList.conditional.test.ts
updateCommand shallow-copies the edited command before replacing it. Tests check that saving a changed condition updates the summary and edit label, and that leaving the branch page updates the then-branch count.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to ecd49

The conditional display change is ready to merge after normal checks; no actionable risk was identified.

🚥 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%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. (1 skipped: 1 … 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 clearly and concisely describes the main change: updating newly added Conditional rows to show their condition and branch counts immediately.
Linked Issues check ✅ Passed The PR meets the coding requirements in #2147. updateCommand replaces the edited command with a shallow copy, which gives Svelte a new list item after an in-place edit on a newly added `ConditionalC…
Out of Scope Changes check ✅ Passed The changes stay within #2147. The CommandList.svelte change fixes Conditional row refresh after condition and branch edits. The added tests cover those behaviors and the related save-snapshot behav…
Full details: Docstring Coverage

Explanation

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

  • 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
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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 branch count twice,
Then saves a change with care and spice.
The label updates on the screen,
The branch count shows what has been seen.
It hops away, content and serene.

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

@chhoumann
chhoumann merged commit 060ca2f into master Oct 2, 2026
15 checks passed
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.

Macro: a Conditional step added in the same session keeps its old label after its condition or branch is edited

1 participant