Skip to content

Fix connection ID not incrementing when adding new connections#33

Closed
jgeudens wants to merge 2 commits intomasterfrom
claude/fix-connection-id-increment-9zRj8
Closed

Fix connection ID not incrementing when adding new connections#33
jgeudens wants to merge 2 commits intomasterfrom
claude/fix-connection-id-increment-9zRj8

Conversation

@jgeudens
Copy link
Copy Markdown
Member

@jgeudens jgeudens commented Apr 16, 2026

When adding new connection tabs, each new connection was getting the same
"id" value copied from adapter defaults. Fix by assigning _nextItemTabIndex
(the existing monotonic 1-based counter) to the "id" field when the item
schema defines one, so connections are numbered 1, 2, 3, … consistently.

Add test addTabIncrementsId to verify sequential assignment.

https://claude.ai/code/session_01YHUJArN5sCs31hZDyntm1e

Summary by CodeRabbit

  • Bug Fixes

    • Newly created adapter tabs now receive unique, sequential identifiers when added.
  • Tests

    • Added a test verifying that adding a new adapter tab increments/assigns the tab identifier rather than reusing an existing default.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 16, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5b1b62a0-fa5f-4712-92e3-bf49c830127a

📥 Commits

Reviewing files that changed from the base of the PR and between b9a5c1d and e146b12.

📒 Files selected for processing (3)
  • src/dialogs/adaptersettings.cpp
  • tests/dialogs/tst_adaptersettings.cpp
  • tests/dialogs/tst_adaptersettings.h
✅ Files skipped from review due to trivial changes (1)
  • src/dialogs/adaptersettings.cpp
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/dialogs/tst_adaptersettings.h
  • tests/dialogs/tst_adaptersettings.cpp

Walkthrough

Adds conditional injection of an "id" default into newly created item tabs: when the item schema includes an id property, AdapterSettings::addItemTab() sets defaultValues["id"] to the current _nextItemTabIndex before creating the tab. A unit test verifies the incremented id on add.

Changes

Cohort / File(s) Summary
Adapter Settings Production Code
src/dialogs/adaptersettings.cpp
When creating a new item tab, check the item schema for a properties.id entry and, if present, set defaultValues["id"] = _nextItemTabIndex before calling SchemaFormWidget::setSchema(...).
Adapter Settings Test Code
tests/dialogs/tst_adaptersettings.cpp, tests/dialogs/tst_adaptersettings.h
Added test TestAdapterSettings::addTabIncrementsId() and its declaration: constructs an array-item schema with id, seeds an existing item, requests a new tab, asserts the tab count and that the new tab's SchemaFormWidget has values()["id"] == 2.

Possibly Related PRs

  • UI names #13: Refactors device/tab code and tests to use and propagate id field handling alongside this PR's automatic injection of id values in adapter schemas.
🚥 Pre-merge checks | ✅ 2 | ❌ 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 (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly addresses the main bug fix: ID values not incrementing when adding new connections, which aligns with the core change in the code.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/fix-connection-id-increment-9zRj8

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 `@tests/dialogs/tst_adaptersettings.cpp`:
- Around line 203-208: Update the test in tst_adaptersettings.cpp so the
defaults include an "id" on the initial connection (e.g., add "id" to
defaultConn) to reproduce the regression where addItemTab() might reuse the
default id; then after calling addItemTab() assert that the newly added tab's id
is not the same as the seeded default but is incremented/unique (verify via the
same accessor used elsewhere in this test), ensuring the second tab's id is
generated rather than copied.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e5507f47-bc02-4594-8a1e-90ae36e90930

📥 Commits

Reviewing files that changed from the base of the PR and between 705c8f3 and b9a5c1d.

📒 Files selected for processing (3)
  • src/dialogs/adaptersettings.cpp
  • tests/dialogs/tst_adaptersettings.cpp
  • tests/dialogs/tst_adaptersettings.h

Comment thread tests/dialogs/tst_adaptersettings.cpp
claude and others added 2 commits April 17, 2026 19:26
When adding new connection tabs, each new connection was getting the same
"id" value copied from adapter defaults. Fix by assigning _nextItemTabIndex
(the existing monotonic 1-based counter) to the "id" field when the item
schema defines one, so connections are numbered 1, 2, 3, … consistently.

Add test addTabIncrementsId to verify sequential assignment.

https://claude.ai/code/session_01YHUJArN5sCs31hZDyntm1e
Seed the defaults with id=1 and pre-populate the config with one existing
connection so _nextItemTabIndex starts at 2. The new tab must receive id=2,
not copy the default id=1 — previously the test would have passed even if
the explicit id override in addItemTab() were accidentally removed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jgeudens jgeudens force-pushed the claude/fix-connection-id-increment-9zRj8 branch from b9a5c1d to e146b12 Compare April 17, 2026 17:33
@jgeudens jgeudens closed this Apr 18, 2026
@jgeudens jgeudens deleted the claude/fix-connection-id-increment-9zRj8 branch April 18, 2026 11:14
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.

2 participants