[PR #4558] [CLOSED] experiment: charlib #6421

Closed
opened 2026-10-23 04:10:16 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/4558
Author: @Gunterlie
Created: 8/4/2026
Status: ❌ Closed

Base: staging ← Head: all-my-little-piggies


📝 Commits (6)

  • 3831f58 feat(characters): bulk operations and manager views in the full character library
  • eed74d6 Add tag filtering and manager to character library
  • 9d0195a Rework character library selection and filters
  • 1eb3fc1 Extract shared character library card model and filter pipeline
  • 7aa66f3 Add group filtering, per-card actions and persisted view state to the library
  • 69358cf Give Professor Mari a library digest so she can curate characters

📊 Changes

20 files changed (+3055 additions, -520 deletions)

View changed files

📝 docs/characters/library-organization.md (+51 -0)
📝 package.json (+2 -1)
➕ packages/client/src/components/characters/CharacterBulkEditModal.tsx (+341 -0)
📝 packages/client/src/components/characters/CharacterLibraryView.tsx (+1288 -199)
➕ packages/client/src/components/characters/CharacterTagManagerModal.tsx (+346 -0)
📝 packages/client/src/components/panels/CharactersPanel.tsx (+58 -223)
📝 packages/client/src/hooks/use-characters.ts (+19 -0)
➕ packages/client/src/lib/card-library-filter.ts (+153 -0)
📝 packages/client/src/lib/card-library-search.ts (+29 -0)
➕ packages/client/src/lib/character-library-card.ts (+219 -0)
📝 packages/client/src/lib/character-token-count.ts (+8 -91)
📝 packages/client/src/localization/locales/en.json (+3 -0)
📝 packages/client/src/stores/ui.store.ts (+30 -0)
📝 packages/server/src/routes/characters.routes.ts (+52 -0)
📝 packages/server/src/routes/generate/professor-mari-prompt-context.ts (+35 -6)
📝 packages/shared/src/index.ts (+2 -0)
➕ packages/shared/src/utils/character-bulk-tags.ts (+52 -0)
➕ packages/shared/src/utils/character-card-health.ts (+145 -0)
📝 scripts/regressions/card-library-search.regression.ts (+161 -0)
➕ scripts/regressions/character-bulk-edit.regression.ts (+61 -0)

📄 Description

Why

The character library is already feature-rich, but the two character surfaces had drifted into parallel implementations:

  • CharactersPanel.tsx (sidebar) — folders, drag-drop, duplicate, import-metadata badge, tag-match-count sort tiebreak
  • CharacterLibraryView.tsx (full library) — grid/table, density, bulk edit, tag manager, keyboard nav, no grouping at all

They duplicated parseCharacterRow, getCharacterTags, the sort switch, the tag filter loop, allTags and the scroll-restore block — and the copies had already diverged in behaviour. Every new feature cost two implementations.

This is an experiment at closing that gap and building a real manager layer on top, reusing plumbing that already ships rather than adding infrastructure.

What changed

1. Shared card model and filter pipeline (1eb3fc1)

New lib/character-library-card.ts (card model, group parsing, computeGroupMembershipUpdates) and lib/card-library-filter.ts (filter/sort/tag helpers). Both surfaces now run through them.

Two deliberate behaviour convergences, called out because they are not no-ops:

  • The full library gains the sidebar's tag-match-count sort tiebreak. Previously only the sidebar floated better tag matches to the top.
  • The sidebar's included-tag filtering is preserved as OR via an explicit tagMatch: "any" option. The sidebar widens on multiple tags where the library narrows; unifying these silently would have changed filtering under existing users.

2. Groups, per-card actions, persisted view state (7aa66f3)

  • Group filter chips in the library (All groups / each group / Ungrouped)
  • Right-click menu on grid cards: edit, chat, favourite, duplicate, export, move between groups, remove from group, delete
  • View mode and density persist instead of resetting on every reload

character_groups stays one table serving both the library's grouping and the chat/game wizards' party presets (ChatSetupWizard, GameSetupWizard, NoodleHome). No schema change, no migration. A kind discriminator would have needed a backfill default, and getting it wrong makes existing party presets vanish from the wizards.

3. Professor Mari as librarian (69358cf)

Mari already had update_character — it patches tags, favourite and every card field, with version snapshots and a character_updated event. What she lacked was sight: her prompt context handed her a bare comma-joined list of names.

Her character list now carries one digest line per card — name [tags] ~tokens needs: gaps. That is the whole change. No new command types, no approval renderer, no changes to the 2,841-line workspace agent. Libraries over 200 characters fall back to plain names so the digest cannot crowd out the context window.

Token estimation moved into packages/shared (re-exported from the old client path, so no import sites changed) alongside a new getCardHealthIssues.

Scope notes

  • The CharacterPanelRow merge in the original plan was dropped. The two sidebar card copies were expected to differ by one button; on reading they differ in avatar size, text scale, DOM element choice, data attributes, and the actions block is flex with four icons in one and grid-cols-3 w-24 with a labelled chat button in the other. Merging would mean a props union reproducing both branches. Left alone.
  • The line-count win is smaller than planned: the extraction is roughly neutral (−296 in the components, +372 in the new libs). The value is single-source-of-truth, not deletion.
  • Semantic search over card embeddings was not built. The infrastructure exists (/generate/raw/embeddings, localEmbed, cosineSimilarity) but vectors need somewhere to live, and substring search still covers real library sizes.
  • The folder → group copy rename was skipped — pure vocabulary churn across every locale file for no functional gain.

Incidental fix

Root-level character rows in the sidebar had onClick but no role / tabIndex / onKeyDown, so they were mouse-only while folder members were keyboard-accessible. Root is where most characters live.

Automated checks run

  • pnpm check (TypeScript + ESLint + localization + build) — passing
  • pnpm regression:card-library-search — extended with asserts on the filter/sort pipeline, AND-vs-OR tag semantics, group membership updates, and card health
  • pnpm regression:chat-resource-drop — the drag payload path the sidebar rewrite touches
  • pnpm regression:character-bulk-edit, pnpm regression:localization — passing

Test plan — needs manual verification

Nothing below has been verified in a browser. These are to-dos, not results.

  • Sidebar: confirm multi-tag filtering still ORs (picking two tags widens the list, does not narrow it)
  • Full library: confirm multi-tag filtering still ANDs
  • Sidebar: confirm sort order is unchanged for name/newest/oldest/favorites, with and without tag filters active
  • Sidebar: drag a character between two groups, confirm exactly two PATCH requests in the network tab
  • Sidebar: drag a character onto a chat, confirm the chat-resource drop still works
  • Sidebar: open a root-level character with the keyboard (Tab to it, press Enter)
  • Library: exercise every right-click menu entry, including move-to-group and remove-from-group
  • Library: confirm group chips filter correctly, including Ungrouped
  • Library: change view mode and density, reload, confirm both persist
  • Wizards: create a group in the sidebar, confirm it still appears as a party preset in ChatSetupWizard and GameSetupWizard
  • Personas: confirm the persona library is unaffected (no group chips, no character-only menu entries)
  • Mari: ask "which of my characters are untagged?" and confirm she answers from the digest
  • Mari: ask her to tag them, confirm character_updated events fire and version snapshots are created
  • Mari: confirm a library over 200 characters falls back to plain names
  • Mobile: check the library toolbar chip row wrapping with several groups

Linked issue

No issue or feature request is linked. Per CONTRIBUTING.md § Before You Open a Pull Request one should be opened before this is considered for merge — flagging rather than silently skipping, especially as this is exploratory.


🔄 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/4558 **Author:** [@Gunterlie](https://github.com/Gunterlie) **Created:** 8/4/2026 **Status:** ❌ Closed **Base:** `staging` ← **Head:** `all-my-little-piggies` --- ### 📝 Commits (6) - [`3831f58`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3831f58fdfa18bfd802efa34ab16a3896fd97877) feat(characters): bulk operations and manager views in the full character library - [`eed74d6`](https://github.com/Pasta-Devs/Marinara-Engine/commit/eed74d6b5c751a9b7840d48d13f48bb5a8183827) Add tag filtering and manager to character library - [`9d0195a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/9d0195ac52d949082b75cc959392f31116a93352) Rework character library selection and filters - [`1eb3fc1`](https://github.com/Pasta-Devs/Marinara-Engine/commit/1eb3fc1421c6f2c7b8ed728594421d0204f4e9e2) Extract shared character library card model and filter pipeline - [`7aa66f3`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7aa66f327982836fa4969a421b7e229fc45a8449) Add group filtering, per-card actions and persisted view state to the library - [`69358cf`](https://github.com/Pasta-Devs/Marinara-Engine/commit/69358cf3f3e4df8c741aa017f9e60539a2a573f9) Give Professor Mari a library digest so she can curate characters ### 📊 Changes **20 files changed** (+3055 additions, -520 deletions) <details> <summary>View changed files</summary> 📝 `docs/characters/library-organization.md` (+51 -0) 📝 `package.json` (+2 -1) ➕ `packages/client/src/components/characters/CharacterBulkEditModal.tsx` (+341 -0) 📝 `packages/client/src/components/characters/CharacterLibraryView.tsx` (+1288 -199) ➕ `packages/client/src/components/characters/CharacterTagManagerModal.tsx` (+346 -0) 📝 `packages/client/src/components/panels/CharactersPanel.tsx` (+58 -223) 📝 `packages/client/src/hooks/use-characters.ts` (+19 -0) ➕ `packages/client/src/lib/card-library-filter.ts` (+153 -0) 📝 `packages/client/src/lib/card-library-search.ts` (+29 -0) ➕ `packages/client/src/lib/character-library-card.ts` (+219 -0) 📝 `packages/client/src/lib/character-token-count.ts` (+8 -91) 📝 `packages/client/src/localization/locales/en.json` (+3 -0) 📝 `packages/client/src/stores/ui.store.ts` (+30 -0) 📝 `packages/server/src/routes/characters.routes.ts` (+52 -0) 📝 `packages/server/src/routes/generate/professor-mari-prompt-context.ts` (+35 -6) 📝 `packages/shared/src/index.ts` (+2 -0) ➕ `packages/shared/src/utils/character-bulk-tags.ts` (+52 -0) ➕ `packages/shared/src/utils/character-card-health.ts` (+145 -0) 📝 `scripts/regressions/card-library-search.regression.ts` (+161 -0) ➕ `scripts/regressions/character-bulk-edit.regression.ts` (+61 -0) </details> ### 📄 Description ## Why The character library is already feature-rich, but the two character surfaces had drifted into parallel implementations: - `CharactersPanel.tsx` (sidebar) — folders, drag-drop, duplicate, import-metadata badge, tag-match-count sort tiebreak - `CharacterLibraryView.tsx` (full library) — grid/table, density, bulk edit, tag manager, keyboard nav, **no grouping at all** They duplicated `parseCharacterRow`, `getCharacterTags`, the sort switch, the tag filter loop, `allTags` and the scroll-restore block — and the copies had already diverged in behaviour. Every new feature cost two implementations. This is an experiment at closing that gap and building a real manager layer on top, reusing plumbing that already ships rather than adding infrastructure. ## What changed **1. Shared card model and filter pipeline** (`1eb3fc1`) New `lib/character-library-card.ts` (card model, group parsing, `computeGroupMembershipUpdates`) and `lib/card-library-filter.ts` (filter/sort/tag helpers). Both surfaces now run through them. Two deliberate behaviour convergences, called out because they are *not* no-ops: - The full library gains the sidebar's tag-match-count sort tiebreak. Previously only the sidebar floated better tag matches to the top. - The sidebar's included-tag filtering is **preserved as OR** via an explicit `tagMatch: "any"` option. The sidebar widens on multiple tags where the library narrows; unifying these silently would have changed filtering under existing users. **2. Groups, per-card actions, persisted view state** (`7aa66f3`) - Group filter chips in the library (All groups / each group / Ungrouped) - Right-click menu on grid cards: edit, chat, favourite, duplicate, export, move between groups, remove from group, delete - View mode and density persist instead of resetting on every reload `character_groups` stays **one table** serving both the library's grouping and the chat/game wizards' party presets (`ChatSetupWizard`, `GameSetupWizard`, `NoodleHome`). No schema change, no migration. A `kind` discriminator would have needed a backfill default, and getting it wrong makes existing party presets vanish from the wizards. **3. Professor Mari as librarian** (`69358cf`) Mari already had `update_character` — it patches tags, favourite and every card field, with version snapshots and a `character_updated` event. What she lacked was *sight*: her prompt context handed her a bare comma-joined list of names. Her character list now carries one digest line per card — `name [tags] ~tokens needs: gaps`. That is the whole change. No new command types, no approval renderer, no changes to the 2,841-line workspace agent. Libraries over 200 characters fall back to plain names so the digest cannot crowd out the context window. Token estimation moved into `packages/shared` (re-exported from the old client path, so no import sites changed) alongside a new `getCardHealthIssues`. ## Scope notes - **The `CharacterPanelRow` merge in the original plan was dropped.** The two sidebar card copies were expected to differ by one button; on reading they differ in avatar size, text scale, DOM element choice, data attributes, and the actions block is `flex` with four icons in one and `grid-cols-3 w-24` with a labelled chat button in the other. Merging would mean a props union reproducing both branches. Left alone. - The line-count win is smaller than planned: the extraction is roughly neutral (−296 in the components, +372 in the new libs). The value is single-source-of-truth, not deletion. - Semantic search over card embeddings was **not** built. The infrastructure exists (`/generate/raw/embeddings`, `localEmbed`, `cosineSimilarity`) but vectors need somewhere to live, and substring search still covers real library sizes. - The `folder` → `group` copy rename was skipped — pure vocabulary churn across every locale file for no functional gain. ## Incidental fix Root-level character rows in the sidebar had `onClick` but no `role` / `tabIndex` / `onKeyDown`, so they were mouse-only while folder members were keyboard-accessible. Root is where most characters live. ## Automated checks run - `pnpm check` (TypeScript + ESLint + localization + build) — passing - `pnpm regression:card-library-search` — extended with asserts on the filter/sort pipeline, AND-vs-OR tag semantics, group membership updates, and card health - `pnpm regression:chat-resource-drop` — the drag payload path the sidebar rewrite touches - `pnpm regression:character-bulk-edit`, `pnpm regression:localization` — passing ## Test plan — needs manual verification Nothing below has been verified in a browser. These are to-dos, not results. - [ ] Sidebar: confirm multi-tag filtering still ORs (picking two tags widens the list, does not narrow it) - [ ] Full library: confirm multi-tag filtering still ANDs - [ ] Sidebar: confirm sort order is unchanged for name/newest/oldest/favorites, with and without tag filters active - [ ] Sidebar: drag a character between two groups, confirm exactly two PATCH requests in the network tab - [ ] Sidebar: drag a character onto a chat, confirm the chat-resource drop still works - [ ] Sidebar: open a root-level character with the keyboard (Tab to it, press Enter) - [ ] Library: exercise every right-click menu entry, including move-to-group and remove-from-group - [ ] Library: confirm group chips filter correctly, including Ungrouped - [ ] Library: change view mode and density, reload, confirm both persist - [ ] Wizards: create a group in the sidebar, confirm it still appears as a party preset in `ChatSetupWizard` and `GameSetupWizard` - [ ] Personas: confirm the persona library is unaffected (no group chips, no character-only menu entries) - [ ] Mari: ask "which of my characters are untagged?" and confirm she answers from the digest - [ ] Mari: ask her to tag them, confirm `character_updated` events fire and version snapshots are created - [ ] Mari: confirm a library over 200 characters falls back to plain names - [ ] Mobile: check the library toolbar chip row wrapping with several groups ## Linked issue No issue or feature request is linked. Per `CONTRIBUTING.md § Before You Open a Pull Request` one should be opened before this is considered for merge — flagging rather than silently skipping, especially as this is exploratory. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:10:16 +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#6421
No description provided.