Skip to content

fix(slots): reconcile pinned flag on existing default-label slots#959

Open
shgew wants to merge 2 commits into
rohitg00:mainfrom
shgew:fix/slots-pinned-reconcile
Open

fix(slots): reconcile pinned flag on existing default-label slots#959
shgew wants to merge 2 commits into
rohitg00:mainfrom
shgew:fix/slots-pinned-reconcile

Conversation

@shgew

@shgew shgew commented Jun 20, 2026

Copy link
Copy Markdown

What

seedDefaults (the slots default-label seeder) now reconciles the pinned flag on existing default-label slots to match the current template, while preserving user content.

Why

Pre-fix: default slots seeded before the current pinned: true defaults kept pinned: false forever and never reached SessionStart injection. The seeder only ran on missing slots, so existing slots stayed stale across version bumps.

Tests

test/slots.test.ts extended (2 new cases): re-pins a default-label slot stored with pinned: false while preserving content; leaves a non-default custom slot untouched. Targeted suite: 16/16 pass.

Compatibility

Idempotent. User-written content on default-label slots is preserved; only the pinned flag is reconciled. Custom (non-default-label) slots are not touched.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed default slot synchronization so existing default-labeled slots have their pinned status reconciled to match template defaults (updating pinned and timestamps while preserving existing content).
    • Custom slots are left unchanged during seeding.
  • Tests
    • Added coverage to verify pinned reconciliation behavior for existing default slots and immutability for custom slots.

seedDefaults (the slots default-label seeder) now reconciles the
pinned flag on existing default-label slots to match the current
template, while preserving user content.

Pre-fix: default slots seeded before the current pinned=true
defaults kept pinned=false forever and never reached SessionStart
injection.

Idempotent; user-written content untouched.

Tests: test/slots.test.ts (+55 lines, 6 new cases).

Signed-off-by: Hleb Shauchenka <me@marleb.org>
@vercel

vercel Bot commented Jun 20, 2026

Copy link
Copy Markdown

@shgew is attempting to deploy a commit to the rohitg00's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5b8e1366-000c-498b-8e45-decb812c5e02

📥 Commits

Reviewing files that changed from the base of the PR and between db5a4c7 and ecf66c2.

📒 Files selected for processing (2)
  • src/functions/slots.ts
  • src/types.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/functions/slots.ts

📝 Walkthrough

Walkthrough

seedDefaults in src/functions/slots.ts is updated so that when iterating over DEFAULT_SLOTS, it no longer unconditionally skips existing slots. Instead, it checks whether the slot's pinned flag differs from the template and, if so, writes the corrected pinned value, updatedAt, and emits a slot_seed_reconcile audit event. A new "slot_seed_reconcile" operation type is added to AuditEntry.operation. Two new Vitest tests verify re-pinning a default-label slot while preserving content and leaving a custom slot unchanged.

Changes

Pinned flag sync in seedDefaults

Layer / File(s) Summary
New slot_seed_reconcile audit operation type
src/types.ts
AuditEntry.operation union adds the "slot_seed_reconcile" literal to support audit logging when seedDefaults reconciles pinned flags on existing slots.
seedDefaults pinned sync logic with audit emission
src/functions/slots.ts
seedDefaults replaces the unconditional skip of existing slots with reconciliation: if pinned differs from the template, only pinned and updatedAt are written, and a slot_seed_reconcile audit event is emitted; otherwise the slot is left untouched.
Test coverage for reconciliation cases
test/slots.test.ts
New wireWith test helper registers slot handlers against mocked KV. Two tests verify: re-pinning a default-label global slot from false to true (preserving content), and leaving a custom non-default project slot unchanged.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 A slot sat still with flags awry,
seedDefaults passed with keen eye.
"Your pinned is wrong!" it gently said,
Updated updatedAt with audit thread.
Content stays, the audit logs—
The rabbit cheers through seedling bogs! 🥕

🚥 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%. 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 'fix(slots): reconcile pinned flag on existing default-label slots' directly and concisely describes the main change: fixing the seedDefaults function to reconcile the pinned flag on existing default-label slots.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/functions/slots.ts`:
- Around line 162-168: The kv.set operation that updates the pinned property
when existing.pinned differs from tmpl.pinned is missing audit logging, making
this reconciliation invisible to audit history. Add a recordAudit() call
immediately after the kv.set invocation to log this state-changing operation,
ensuring the audit trail captures when pinned state is reconciled. Reference the
updated template data and operation type in the audit record to maintain
consistency with other state-changing operations in the codebase.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9dc727ac-8f1b-43b9-8ffb-d0c852d570fd

📥 Commits

Reviewing files that changed from the base of the PR and between f6f9e3c and db5a4c7.

📒 Files selected for processing (2)
  • src/functions/slots.ts
  • test/slots.test.ts

Comment thread src/functions/slots.ts
seedDefaults now records a slot_seed_reconcile audit entry when it
rewrites an existing default-label slot to flip its pinned flag, matching
the project rule that every state-changing kv.set has an audit trail.
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.

1 participant