Skip to content

feat(actions): add addedWithVersion to CommonSettings for version-dependent defaults (#315)#317

Merged
niklam merged 2 commits into
masterfrom
feat/315-added-with-version
Apr 11, 2026
Merged

feat(actions): add addedWithVersion to CommonSettings for version-dependent defaults (#315)#317
niklam merged 2 commits into
masterfrom
feat/315-added-with-version

Conversation

@niklam
Copy link
Copy Markdown
Owner

@niklam niklam commented Apr 11, 2026

Related Issue

Fixes #315

What changed?

  • Added addedWithVersion field to CommonSettings (Zod default "0.0.0" for pre-existing instances)
  • BaseAction.onWillAppear() persists the current plugin version (from config.json via getPluginVersion()) on first appearance when the field is missing
  • Existing instances get "0.0.0", new instances get the current plugin version (e.g., "1.13.0")
  • This enables version-dependent setting defaults: semver.lt(settings.addedWithVersion, "1.13.0") ? oldDefault : newDefault

How to test

  1. Run pnpm test — all tests pass including 3 new tests for version persistence
  2. Verify behavior: action with no addedWithVersion in settings → persisted on first onWillAppear
  3. Verify behavior: action with existing addedWithVersion → not overwritten
  4. Verify behavior: plugin config not initialized → no persistence attempted

Checklist

  • Linked to an approved issue
  • New code has unit tests
  • Changes registered in all applicable plugins (Stream Deck, Mirabox)
  • No unrelated changes included

Summary by CodeRabbit

  • New Features

    • Actions automatically capture and persist the plugin version when first added to a device, improving version tracking and visibility across different plugin deployments.
  • Tests

    • Added test coverage for the automatic version tracking functionality, including verification of initialization behavior and edge cases.

…endent defaults (#315)

Add addedWithVersion field to CommonSettings (defaults to "0.0.0" for
existing instances). BaseAction.onWillAppear persists the current plugin
version on first appearance, enabling version-dependent setting defaults.
@github-actions github-actions Bot added the type: feature New feature label Apr 11, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 11, 2026

Warning

Rate limit exceeded

@niklam has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 21 minutes and 40 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 21 minutes and 40 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7b973a42-ce78-4f86-b9ea-63f80c4e749c

📥 Commits

Reviewing files that changed from the base of the PR and between cb1412b and 0e65bc2.

📒 Files selected for processing (1)
  • packages/deck-core/src/base-action.ts
📝 Walkthrough

Walkthrough

The changes add version tracking to actions by introducing an addedWithVersion field to CommonSettings that defaults to "0.0.0". BaseAction.onWillAppear now conditionally persists the current plugin version on first device appearance when this field is missing, enabling version-dependent setting defaults for new versus existing action instances.

Changes

Cohort / File(s) Summary
Core changes
packages/deck-core/src/common-settings.ts, packages/deck-core/src/base-action.ts
Added addedWithVersion field to CommonSettings with default value "0.0.0". Modified BaseAction.onWillAppear to detect missing addedWithVersion, fetch plugin version from config, and persist it via setSettings on first device appearance.
Test updates
packages/stream-deck-plugin/src/shared/base-action.test.ts
Added initPluginConfig and _resetPluginConfig imports to control global state in tests. Mocked setSettings method and added three test cases verifying: (1) version persistence when missing and config initialized, (2) no persistence when version already exists, (3) no persistence when config not initialized.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

type: feature

Poem

🐰 Hop along with versions tracking,
New actions get the latest backing,
Old ones stay their ways,
Recorded on first days,
Settings safely ever-stacking!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding an addedWithVersion field to CommonSettings for version-dependent defaults, directly matching the PR's primary objective.
Description check ✅ Passed The description is complete and follows the template with all required sections: related issue, what changed, how to test, and a filled checklist confirming all key requirements are met.
Linked Issues check ✅ Passed The PR fulfills all acceptance criteria from issue #315: addedWithVersion added to CommonSettings with default, version persisted on first onWillAppear when missing, read from config file, existing instances get '0.0.0', new instances get current version, and tests cover version persistence.
Out of Scope Changes check ✅ Passed All changes are directly scoped to issue #315 objectives: CommonSettings field addition, BaseAction.onWillAppear persistence logic, and comprehensive test coverage; no unrelated modifications detected.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/315-added-with-version

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.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/deck-core/src/base-action.ts`:
- Around line 304-308: The call to ev.action.setSettings(...) inside the
addedWithVersion block can reject and short-circuit onWillAppear; wrap the await
ev.action.setSettings({...}) in a try/catch (around the code in the
addedWithVersion conditional that uses getPluginVersion and this.logger.debug)
and handle failures by logging the error via this.logger.error (include context
like ev.action.id and the version) but do not rethrow so execution continues and
later setup (e.g., flagsOverlay handling) still runs.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0fbf6b16-5662-4eda-b807-661ffb68ae4e

📥 Commits

Reviewing files that changed from the base of the PR and between c916558 and cb1412b.

📒 Files selected for processing (3)
  • packages/deck-core/src/base-action.ts
  • packages/deck-core/src/common-settings.ts
  • packages/stream-deck-plugin/src/shared/base-action.test.ts

Comment thread packages/deck-core/src/base-action.ts
@niklam niklam merged commit 4061ad0 into master Apr 11, 2026
4 checks passed
@niklam niklam deleted the feat/315-added-with-version branch April 11, 2026 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(actions): add addedWithVersion to CommonSettings for version-dependent defaults

1 participant