Don't show all items on the items sidebar #67

Closed
opened 2026-10-15 14:02:38 +00:00 by Syndria98 · 35 comments
Owner

Right now, the items entries are all the items on the foundry items tab, but also the items that the character contain. Can you make that it only appears the items that are on the items tab on foundry? In other words, make them equal

Right now, the items entries are all the items on the foundry items tab, but also the items that the character contain. Can you make that it only appears the items that are on the items tab on foundry? In other words, make them equal
Syndria98 added the ai-ready label 2026-10-15 14:02:38 +00:00
Agent added the working label 2026-10-15 16:01:37 +00:00
Collaborator

I'll start by exploring the repo structure and finding the relevant files.

I'll start by exploring the repo structure and finding the relevant files.
Collaborator

Let me look at the test files and the frontend item components to understand the items sidebar.

Let me look at the test files and the frontend item components to understand the items sidebar.
Collaborator

Now let me look at the Foundry module side, which decides what gets synced.

Now let me look at the Foundry module side, which decides what gets synced.
Collaborator

Now let me look at how the sidebar fetches items and how the Foundry module sends actor snapshots with embedded items.

Now let me look at how the sidebar fetches items and how the Foundry module sends actor snapshots with embedded items.
Collaborator

Let me look at the tests directory to understand existing test conventions and what covers this sync behavior.

Let me look at the tests directory to understand existing test conventions and what covers this sync behavior.
Collaborator

Let me look at the reconcile function and how items come back to Foundry, to understand full implications.

Let me look at the reconcile function and how items come back to Foundry, to understand full implications.
Collaborator

Let me look at the remaining relevant tests and the item list route to fully understand current behavior before changing anything.

Let me look at the remaining relevant tests and the item list route to fully understand current behavior before changing anything.
Collaborator

Let me check the item route (frontend-facing list) and the module README's sync description.

Let me check the item route (frontend-facing list) and the module README's sync description.
Collaborator

Let me verify no existing tests depend on actor-embedded items becoming Item rows, and check the foundry-sync-toggle test.

Let me verify no existing tests depend on actor-embedded items becoming Item rows, and check the foundry-sync-toggle test.
Collaborator

Let me check for any test that asserts actor-embedded gear creates an Item row (which would depend on current behavior).

Let me check for any test that asserts actor-embedded gear creates an Item row (which would depend on current behavior).
Collaborator

Let me confirm no test asserts that actor-only gear becomes an Item row (dedup-by-name), which my change would reverse.

Let me confirm no test asserts that actor-only gear becomes an Item row (dedup-by-name), which my change would reverse.
Collaborator

Let me examine forceSyncActorsToDragonroll and confirm no other path relies on embedded items becoming Item rows.

Let me examine `forceSyncActorsToDragonroll` and confirm no other path relies on embedded items becoming Item rows.
Collaborator

Let me check whether any test regex-matches the specific comments I plan to touch, before editing.

Let me check whether any test regex-matches the specific comments I plan to touch, before editing.
Collaborator

Let me read the full harness of the existing sync test so I can write focused new tests in the same style.

Let me read the full harness of the existing sync test so I can write focused new tests in the same style.
Collaborator

I have a clear picture. Let me confirm the root cause with a quick baseline test run before changing anything.

I have a clear picture. Let me confirm the root cause with a quick baseline test run before changing anything.
Collaborator

Baseline is green (233 tests). The root cause is clear:

snapshotItemSources in backend/src/routes/foundry-link.js merges both the world's item directory (body.items = Foundry's "items tab") and every actor's embedded items (actor.items). Gear that exists only inside a character therefore becomes its own Dragonroll Item document and shows up in the sidebar.

The fix is to make the campaign's Item collection mirror the world item directory only. Actor inventory is stored separately on the actor document (foundryActorToCharacter reads foundryActor.items), so dropping embedded items from the item sync won't affect character sheets.

Let me make the backend change.

Baseline is green (233 tests). The root cause is clear: `snapshotItemSources` in `backend/src/routes/foundry-link.js` merges **both** the world's item directory (`body.items` = Foundry's "items tab") **and** every actor's embedded items (`actor.items`). Gear that exists only inside a character therefore becomes its own Dragonroll `Item` document and shows up in the sidebar. The fix is to make the campaign's `Item` collection mirror the world item directory only. Actor inventory is stored separately on the actor document (`foundryActorToCharacter` reads `foundryActor.items`), so dropping embedded items from the item sync won't affect character sheets. Let me make the backend change.
Collaborator

Now update the prune comment, which referenced actor copies, and the saveFoundryItem name-dedup comment that assumed actor copies reached it.

Now update the prune comment, which referenced actor copies, and the `saveFoundryItem` name-dedup comment that assumed actor copies reached it.
Collaborator

Let me check the folder section comment and the item-delete comment which also reference actor-embedded items.

Let me check the folder section comment and the item-delete comment which also reference actor-embedded items.
Collaborator

Now let me update the module README and AGENTS.md, which document the old dedup-with-actor-copies behavior.

Now let me update the module README and AGENTS.md, which document the old dedup-with-actor-copies behavior.
Collaborator

Let me verify the README doesn't have a leftover dangling line after my edit.

Let me verify the README doesn't have a leftover dangling line after my edit.
Collaborator

There's a leftover line. Let me remove it.

There's a leftover line. Let me remove it.
Collaborator

Now update AGENTS.md, whose §4 describes items being synced per-carrier.

Now update AGENTS.md, whose §4 describes items being synced per-carrier.
Collaborator

Now let me check the remaining tests won't break, then add focused tests. Let me look at the exact insertion point and confirm the actor-only sync tests don't expect item rows.

Now let me check the remaining tests won't break, then add focused tests. Let me look at the exact insertion point and confirm the actor-only sync tests don't expect item rows.
Collaborator

The existing actor-reconcile tests are unrelated to item sync. Now let me add focused backend tests for issue #67 into the sync-route harness file, which already loads foundry-link.js with stubbed models.

The existing actor-reconcile tests are unrelated to item sync. Now let me add focused backend tests for issue #67 into the sync-route harness file, which already loads `foundry-link.js` with stubbed models.
Collaborator

Let me verify no existing test relies on the old merge/prune behavior that my change flips.

Let me verify no existing test relies on the old merge/prune behavior that my change flips.
Collaborator

The existing tests are unaffected by my change (they pass world items via items:). Now let me add focused tests for issue #67 using the existing stub harness.

The existing tests are unaffected by my change (they pass world items via `items:`). Now let me add focused tests for issue #67 using the existing stub harness.
Collaborator

Now let me add focused tests for issue #67 into the existing sync-route harness.

Now let me add focused tests for issue #67 into the existing sync-route harness.
Collaborator

Let me run the test suite.

Let me run the test suite.
Collaborator

All 237 pass. Let me confirm my 4 new tests actually ran and verify they're meaningful by checking they exercise the new behavior (fail against the old merge logic).

All 237 pass. Let me confirm my 4 new tests actually ran and verify they're meaningful by checking they exercise the new behavior (fail against the old merge logic).
Collaborator

Let me prove the new tests are meaningful by temporarily restoring the old backend logic and confirming they fail.

Let me prove the new tests are meaningful by temporarily restoring the old backend logic and confirming they fail.
Collaborator

The two key tests fail against the old logic and pass with my fix — confirming they're meaningful. Tests 11 and 12 pass in both (they assert invariants preserved by the change). Let me verify my change is intact and the full suite is green.

The two key tests fail against the old logic and pass with my fix — confirming they're meaningful. Tests 11 and 12 pass in both (they assert invariants preserved by the change). Let me verify my change is intact and the full suite is green.
Collaborator

Let me review the final diff of the core backend change to ensure coherence.

Let me review the final diff of the core backend change to ensure coherence.
Collaborator

The change is complete and coherent. Let me do a final syntax check on the two source files I edited (not just comments).

The change is complete and coherent. Let me do a final syntax check on the two source files I edited (not just comments).
Collaborator

The change is complete and verified. Here's a summary of what I did for Syndria98/dragonroll#67 — "Don't show all items on the items sidebar".

Root cause

The campaign's items sidebar lists Item documents. On a Foundry snapshot, the backend's snapshotItemSources (backend/src/routes/foundry-link.js) merged both the world's item directory (game.items = Foundry's "items tab") and every character's embedded inventory items. So gear that a character carried but that was not on the world's items tab became its own Item row and cluttered the sidebar.

Fix

snapshotItemSources now reads only body.items — the world's item directory — so the campaign's item list equals Foundry's items tab. The full-snapshot prune (which already keys on the world directory's ids) therefore also drops gear that only characters carried.

Character inventories are unaffected: they live on the actor document via foundryActorToCharacter (which reads the actor's embedded items), and the module still sends those inside each actor's snapshot — the backend simply no longer turns them into Item rows.

Files changed

  • backend/src/routes/foundry-link.js — the one-line behavioural fix (snapshotItemSources), plus comment updates that referenced the old actor-copy merge and "one item per carrier" dedup.
  • dragonroll-foundry/scripts/api.js — comment at the snapshot push (code still sends world items + actor inventory; only the explanation changes).
  • dragonroll-foundry/README.md & AGENTS.md — updated the item-sync rules to state the item list mirrors the world's item directory only.
  • tests/item-folder-sync.test.js — 4 new tests: actor gear stays off the list; the list is the world's whole directory; a shared item is listed once as its world entry; and a full snapshot prunes gear only an actor carried.

Verification

  • node --test tests/ → 237 pass, 0 fail (was 233).
  • The two behaviour tests (an actor's gear is kept off… and a full snapshot prunes gear that only an actor carried) fail against the old logic and pass with the fix, confirming they're meaningful regressions.
  • node --check passes on both edited JS files.

No commit/push made, per instructions.

The change is complete and verified. Here's a summary of what I did for **Syndria98/dragonroll#67 — "Don't show all items on the items sidebar"**. ## Root cause The campaign's items sidebar lists `Item` documents. On a Foundry snapshot, the backend's `snapshotItemSources` (`backend/src/routes/foundry-link.js`) merged **both** the world's item directory (`game.items` = Foundry's "items tab") **and** every character's embedded inventory items. So gear that a character carried but that was *not* on the world's items tab became its own `Item` row and cluttered the sidebar. ## Fix `snapshotItemSources` now reads **only** `body.items` — the world's item directory — so the campaign's item list equals Foundry's items tab. The full-snapshot prune (which already keys on the world directory's ids) therefore also drops gear that only characters carried. Character inventories are unaffected: they live on the actor document via `foundryActorToCharacter` (which reads the actor's embedded `items`), and the module still sends those inside each actor's snapshot — the backend simply no longer turns them into `Item` rows. ## Files changed - `backend/src/routes/foundry-link.js` — the one-line behavioural fix (`snapshotItemSources`), plus comment updates that referenced the old actor-copy merge and "one item per carrier" dedup. - `dragonroll-foundry/scripts/api.js` — comment at the snapshot push (code still sends world items + actor inventory; only the explanation changes). - `dragonroll-foundry/README.md` & `AGENTS.md` — updated the item-sync rules to state the item list mirrors the world's item directory only. - `tests/item-folder-sync.test.js` — 4 new tests: actor gear stays off the list; the list is the world's whole directory; a shared item is listed once as its world entry; and a full snapshot prunes gear only an actor carried. ## Verification - `node --test tests/` → **237 pass, 0 fail** (was 233). - The two behaviour tests (`an actor's gear is kept off…` and `a full snapshot prunes gear that only an actor carried`) **fail against the old logic** and pass with the fix, confirming they're meaningful regressions. - `node --check` passes on both edited JS files. No commit/push made, per instructions.
Collaborator

Implementation is ready for review: #75

Implementation is ready for review: https://git.aranroig.com/Syndria98/dragonroll/pulls/75
Agent added help wanted and removed working labels 2026-10-15 16:40:16 +00:00
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Syndria98/dragonroll#67