[PR #8788] [MERGED] fix(client): keep item drags out of their folder and trust only the real host global #8805

Closed
opened 2026-11-07 17:39:49 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8788
Author: @SpicyMarinara
Created: 11/3/2026
Status: ✅ Merged
Merged: 11/3/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/client-folder-drag-host-global


📝 Commits (1)

  • 864ec80 fix(client): keep item drags out of their folder and trust only the real host global

📊 Changes

4 files changed (+74 additions, -17 deletions)

View changed files

📝 e2e/drag-list-scroll.e2e.ts (+52 -12)
📝 e2e/marinara-host-namespace.e2e.ts (+17 -0)
📝 packages/client/src/hooks/use-library-folder-drag.ts (+1 -4)
📝 packages/client/src/lib/marinara-host.ts (+4 -1)

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.

Linked issue

Closes #8787

Why this change

Two problems found in the release-prep audit. (1) #8456 narrowed the folder-drag guard. Since then, pressing a Connection card (Group by folder) or an agent card inside an expanded folder also starts a drag of the folder around it. You see two drag previews, and on drop the folder order changes and Connections switches to Custom sort, which the user never asked for. (2) ensureMarinaraHost accepted any truthy globalThis.MARINARA_HOST. Chat and card HTML keep element ids, and the browser exposes an element's id as a named property of window. So a crafted <div id=\"__MARINARA_HOST__\"> on screen when the first package client loads gets cached as the host, and package clients fail until reload. No linked issue exists yet; one should be opened before the PR is submitted.

What changed

  • Nothing that worked before stops working. Folders can still be dragged by their header in every library panel.
  • Dragging a Connection card or an agent card from inside a folder into another folder now moves only that card. The folder order and the sort setting stay as they were.
  • Agent package clients now always get the Engine's host namespace, even when an element with the id __MARINARA_HOST__ is on the page, for example from chat or card HTML.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

  • Manually verify in the browser: in Connections with Group by folder on, drag an account card from inside folder A onto folder B. Only the card's preview should follow the pointer, the card should land in B, and the folder order and sort should not change.
  • Manually verify in the browser: in Agents, drag an agent card from inside one folder into another folder. Only one preview should appear, and the folder order and sort should not change.
  • Manually verify that dragging a folder by its header still reorders folders in Connections, Agents, Characters and Chats.
  • Manually verify on a touch device (or mobile emulation) that a long-press drag of a card inside a folder moves only the card.
  • Manually verify that an installed agent package client still loads after the Engine starts, including after a dev hot reload.

Agent-run checks (for reference; each regression was shown to fail without its fix):

  • node ./scripts/pnpm-runner.mjs build:shared: exit 0
  • playwright test e2e/drag-list-scroll.e2e.ts e2e/marinara-host-namespace.e2e.ts --grep "connection cards sort|does not stand in" --workers=1 (all projects, custo: 3 passed, 2 skipped, 1 failed. The new host test passed on desktop-chromium; the other projects skip it by design. The connection test passed on desktop-chromium and mobile-chromium. It failed on mobi
  • Same command with the two source files stashed (fail-before): 4 failed, 2 skipped. desktop-chromium and mobile-chromium failed at the new check, drag-list-scroll.e2e.ts:641 (folder A had data-drag-source="true"). The host test failed with version null instead of
  • Clean staging (all changes stashed): playwright mobile-webkit, connection cards sort test: Fails at line 548 the same way, so the mobile-webkit failure already exists on staging and is unrelated to this change.
  • playwright test drag-list-scroll, marinara-host-namespace, handleless-library-drag, agent-apps-category, sprite-library --project=desktop-chromium --project=mob: 34 passed, 6 skipped, 4 failed. The failures were 'standalone apps get their own group...' (agent-apps-category:115, Apps card not found) and 'connection row picks up without a handle...' (handleless-
  • Clean staging (all changes stashed): those two failing tests on desktop-chromium: Both fail the same way on clean staging, so they also existed before this change and are unrelated.
  • packages/client: eslint src/hooks/use-library-folder-drag.ts src/lib/marinara-host.ts: exit 0
  • packages/client: tsc --noEmit -p tsconfig.json: exit 0
  • tsc -p scripts/regressions/tsconfig.client-lanes.json (second half of the client lint script): exit 0
  • node ./scripts/pnpm-runner.mjs check:e2e-types: exit 0
  • prettier --write, then prettier --check on the 4 changed files: All files use Prettier style
  • node ./scripts/run-regressions.mjs --filter marinara-host-namespace / command-center / connection-groups / capability-integrations: Each 1/1 passed

Independent adversarial review: approve.

Known limits and risks:

Low. The folder guard is now exactly main's version, which every other caller (Chats, Characters, Sprites, Lorebooks, Personas, Presets, Backgrounds, Agents) used before #8456. The host change only changes behaviour when the global is not an own property. Failures that already happen on clean staging and are not caused by this change: the connection-folder e2e on mobile-webkit (line 548, the test's first card drag), agent-apps-category 'standalone apps get their own group' (Apps card not found), and handleless-library-drag 'connection row picks up without a handle' (selector [data-touch-drag-card="connection"] not found), the last two on desktop- and mobile-chromium. I did not do the relayed user request about Otome Hearth (outfit shown to a love interest should give +5 affection instead of +20). It was outside this step's assigned findings and worktree, and this repo has no outfit-affection rule. Per AGENTS.md, Otome Hearth (otome-forge) is a downloadable package, so the change belongs in Pasta-Devs/Marinara-Agents and still needs to be made there.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/8788 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 11/3/2026 **Status:** ✅ Merged **Merged:** 11/3/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/client-folder-drag-host-global` --- ### 📝 Commits (1) - [`864ec80`](https://github.com/Pasta-Devs/Marinara-Engine/commit/864ec8078d9649be50200b76135ab5a646688a1f) fix(client): keep item drags out of their folder and trust only the real host global ### 📊 Changes **4 files changed** (+74 additions, -17 deletions) <details> <summary>View changed files</summary> 📝 `e2e/drag-list-scroll.e2e.ts` (+52 -12) 📝 `e2e/marinara-host-namespace.e2e.ts` (+17 -0) 📝 `packages/client/src/hooks/use-library-folder-drag.ts` (+1 -4) 📝 `packages/client/src/lib/marinara-host.ts` (+4 -1) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. ## Linked issue Closes #8787 ## Why this change Two problems found in the release-prep audit. (1) #8456 narrowed the folder-drag guard. Since then, pressing a Connection card (Group by folder) or an agent card inside an expanded folder also starts a drag of the folder around it. You see two drag previews, and on drop the folder order changes and Connections switches to Custom sort, which the user never asked for. (2) ensureMarinaraHost accepted any truthy globalThis.__MARINARA_HOST__. Chat and card HTML keep element ids, and the browser exposes an element's id as a named property of window. So a crafted `<div id=\"__MARINARA_HOST__\">` on screen when the first package client loads gets cached as the host, and package clients fail until reload. No linked issue exists yet; one should be opened before the PR is submitted. ## What changed - Nothing that worked before stops working. Folders can still be dragged by their header in every library panel. - Dragging a Connection card or an agent card from inside a folder into another folder now moves only that card. The folder order and the sort setting stay as they were. - Agent package clients now always get the Engine's host namespace, even when an element with the id `__MARINARA_HOST__` is on the page, for example from chat or card HTML. ## Validation <!-- These are human tasks. Never tick a box for a check that was not actually performed. --> - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` ### Manual verification notes - Manually verify in the browser: in Connections with Group by folder on, drag an account card from inside folder A onto folder B. Only the card's preview should follow the pointer, the card should land in B, and the folder order and sort should not change. - Manually verify in the browser: in Agents, drag an agent card from inside one folder into another folder. Only one preview should appear, and the folder order and sort should not change. - Manually verify that dragging a folder by its header still reorders folders in Connections, Agents, Characters and Chats. - Manually verify on a touch device (or mobile emulation) that a long-press drag of a card inside a folder moves only the card. - Manually verify that an installed agent package client still loads after the Engine starts, including after a dev hot reload. Agent-run checks (for reference; each regression was shown to fail without its fix): - `node ./scripts/pnpm-runner.mjs build:shared`: exit 0 - `playwright test e2e/drag-list-scroll.e2e.ts e2e/marinara-host-namespace.e2e.ts --grep "connection cards sort|does not stand in" --workers=1 (all projects, custo`: 3 passed, 2 skipped, 1 failed. The new host test passed on desktop-chromium; the other projects skip it by design. The connection test passed on desktop-chromium and mobile-chromium. It failed on mobi - `Same command with the two source files stashed (fail-before)`: 4 failed, 2 skipped. desktop-chromium and mobile-chromium failed at the new check, drag-list-scroll.e2e.ts:641 (folder A had data-drag-source="true"). The host test failed with version null instead of - `Clean staging (all changes stashed): playwright mobile-webkit, connection cards sort test`: Fails at line 548 the same way, so the mobile-webkit failure already exists on staging and is unrelated to this change. - `playwright test drag-list-scroll, marinara-host-namespace, handleless-library-drag, agent-apps-category, sprite-library --project=desktop-chromium --project=mob`: 34 passed, 6 skipped, 4 failed. The failures were 'standalone apps get their own group...' (agent-apps-category:115, Apps card not found) and 'connection row picks up without a handle...' (handleless- - `Clean staging (all changes stashed): those two failing tests on desktop-chromium`: Both fail the same way on clean staging, so they also existed before this change and are unrelated. - `packages/client: eslint src/hooks/use-library-folder-drag.ts src/lib/marinara-host.ts`: exit 0 - `packages/client: tsc --noEmit -p tsconfig.json`: exit 0 - `tsc -p scripts/regressions/tsconfig.client-lanes.json (second half of the client lint script)`: exit 0 - `node ./scripts/pnpm-runner.mjs check:e2e-types`: exit 0 - `prettier --write, then prettier --check on the 4 changed files`: All files use Prettier style - `node ./scripts/run-regressions.mjs --filter marinara-host-namespace / command-center / connection-groups / capability-integrations`: Each 1/1 passed Independent adversarial review: approve. Known limits and risks: Low. The folder guard is now exactly main's version, which every other caller (Chats, Characters, Sprites, Lorebooks, Personas, Presets, Backgrounds, Agents) used before #8456. The host change only changes behaviour when the global is not an own property. Failures that already happen on clean staging and are not caused by this change: the connection-folder e2e on mobile-webkit (line 548, the test's first card drag), agent-apps-category 'standalone apps get their own group' (Apps card not found), and handleless-library-drag 'connection row picks up without a handle' (selector [data-touch-drag-card=\"connection\"] not found), the last two on desktop- and mobile-chromium. I did not do the relayed user request about Otome Hearth (outfit shown to a love interest should give +5 affection instead of +20). It was outside this step's assigned findings and worktree, and this repo has no outfit-affection rule. Per AGENTS.md, Otome Hearth (otome-forge) is a downloadable package, so the change belongs in Pasta-Devs/Marinara-Agents and still needs to be made there. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 17:39:49 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#8805
No description provided.