WIP: RynthChat: server default chat tabs (plugin-declared, server-scoped) #15

Draft
AwfulWaffle wants to merge 7 commits from AwfulWaffle/RynthCore:chat/server-tabs into main
First-time contributor

Lets a server plugin ship a default RynthChat tab for its own server. First user: DreamWeave's "Network" tab for the Dereth Network (cross-world tells, invite-only channels and the shared Global room), declared in RynthServers (companion PR).

What it does

  • Manifest: the sections manifest gains an optional chatTabs key: server, id, name, pinned, globalRoomFallback and rules (the usual rule fields, plus globalRoom). Old engines ignore the key. A bad entry is dropped and logged as a partial read, and the rest of the manifest still loads.
  • Seeding: a tab is added once, the first time its server is active. After that, the player owns its name, pin and deletion. A deleted tab stays deleted, including after relog or a manifest that gains a rule.
  • Server-scoped: while its server is not active, the tab is hidden and its rules do not run. New settings fields: seededTabs, tabServers, globalRooms, and on rules server, owner and globalRoom. All are optional and written only when set.
  • Plugin-owned rules refresh: they refresh from the manifest, paired by content rather than list position, so a reorder keeps each rule's on/off and colour. In both rule editors their pattern, mode, action, tab, move and delete controls are locked; on/off and colour stay live.
  • Global room discovery: the room that carries the Global room is learned from chat. The first [Room] Name@world says, " line from a remote speaker records it per server; until then the declared fallback (Roleplay) is used. No command is sent to the server.
  • Name clashes: a player's own tab is never taken over. A taken name seeds as <Name> (<server name>). A new player tab never lands in a hidden server tab; it gets a numbered name instead.
  • Settings file: an unreadable file never lets seeding overwrite it. Seeding waits for a successful read, and the read is retried every 2 s.
  • Export/import: export leaves plugin rules out, and import turns any it finds into ordinary player rules.

Threading

SectionRegistry.Rebuild (render thread) and discovery on the pump both apply under ChatModel.EditLock. Nothing done while holding the lock takes another lock or calls out, and the active-server set is published by whole-array replacement. A steady-state apply is a no-op: no save and no version bump. The decision core is the pure ChatServerTabs.Apply, tested in tools/ChatFilterTests.

Known limits (documented, not coded)

  • rynthchat_settings.json is shared by every client. An older engine saving it drops the new fields. The tab and rules are then reclaimed by content on the next session on that server, but until then the tab can show on other servers.
  • A player's own Move rule into a server tab still moves lines while that tab is hidden.

Tests

  • tools/SectionsTests: 245/245 checks pass.
  • tools/ChatFilterTests: 1740/1740 checks pass. New cases cover seeding, the no-op second apply, rename and delete, deleted-tab resurrection, content pairing, reclaim, clashes, discovery (including forged lines), visibility and export/import.
  • The engine Release build has 0 errors.
  • Not yet run in game.

🤖 Generated with Claude Code

Lets a server plugin ship a default RynthChat tab for its own server. First user: DreamWeave's "Network" tab for the Dereth Network (cross-world tells, invite-only channels and the shared Global room), declared in RynthServers (companion PR). ## What it does - **Manifest:** the sections manifest gains an optional `chatTabs` key: `server`, `id`, `name`, `pinned`, `globalRoomFallback` and `rules` (the usual rule fields, plus `globalRoom`). Old engines ignore the key. A bad entry is dropped and logged as a partial read, and the rest of the manifest still loads. - **Seeding:** a tab is added once, the first time its server is active. After that, the player owns its name, pin and deletion. A deleted tab stays deleted, including after relog or a manifest that gains a rule. - **Server-scoped:** while its server is not active, the tab is hidden and its rules do not run. New settings fields: `seededTabs`, `tabServers`, `globalRooms`, and on rules `server`, `owner` and `globalRoom`. All are optional and written only when set. - **Plugin-owned rules refresh:** they refresh from the manifest, paired by content rather than list position, so a reorder keeps each rule's on/off and colour. In both rule editors their pattern, mode, action, tab, move and delete controls are locked; on/off and colour stay live. - **Global room discovery:** the room that carries the Global room is learned from chat. The first `[Room] Name@world says, "` line from a remote speaker records it per server; until then the declared fallback (Roleplay) is used. No command is sent to the server. - **Name clashes:** a player's own tab is never taken over. A taken name seeds as `<Name> (<server name>)`. A new player tab never lands in a hidden server tab; it gets a numbered name instead. - **Settings file:** an unreadable file never lets seeding overwrite it. Seeding waits for a successful read, and the read is retried every 2 s. - **Export/import:** export leaves plugin rules out, and import turns any it finds into ordinary player rules. ## Threading `SectionRegistry.Rebuild` (render thread) and discovery on the pump both apply under `ChatModel.EditLock`. Nothing done while holding the lock takes another lock or calls out, and the active-server set is published by whole-array replacement. A steady-state apply is a no-op: no save and no version bump. The decision core is the pure `ChatServerTabs.Apply`, tested in `tools/ChatFilterTests`. ## Known limits (documented, not coded) - `rynthchat_settings.json` is shared by every client. An older engine saving it drops the new fields. The tab and rules are then reclaimed by content on the next session on that server, but until then the tab can show on other servers. - A player's own Move rule into a server tab still moves lines while that tab is hidden. ## Tests - `tools/SectionsTests`: 245/245 checks pass. - `tools/ChatFilterTests`: 1740/1740 checks pass. New cases cover seeding, the no-op second apply, rename and delete, deleted-tab resurrection, content pairing, reclaim, clashes, discovery (including forged lines), visibility and export/import. - The engine Release build has 0 errors. - Not yet run in game. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SectionRegistry.Rebuild hands every manifest's chatTabs and the active
server ids to ChatModel.ApplyServerTabs, which seeds each entry's tab once
(seededTabs), rewrites its owned rules from the manifest, and gates the tab
(tabServers) and its rules (ChatFilterRule.Server, ChatRouter) on the
server being active. The pump records the Global room from network room
lines (globalRooms) and rewrites the Global-room rule.

- Apply is a no-op when nothing changed (EditFiltersIfChanged; rules
  compared as canonical forms with ChatServerTabs.SameRule), since Rebuild
  runs every second, and waits for the settings file to load first.
- Rules an older engine stripped of "owner" are reclaimed by content
  (ChatServerTabs.Reclaim) instead of a second set being added.
- A deleted server tab stays deleted across a reload: its disabled owned
  rules no longer re-create it in LoadSettings.
- AllTabs caches per filter version and active-server set.
- The rule editor marks server rules; a manifest with a dropped chatTabs
  entry is logged as partly read, not as unread.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Dereth Network README names Roleplay as the room a world usually
borrows for the Global room, so an entry that leaves the fallback out
matches Roleplay until chat shows another room.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The decision core of ChatModel.ApplyServerTab moves into
ChatServerTabs.Apply, a pure function returning edits (rule updates,
inserts, removals, tab create, pin, seed mark, tab server); ChatModel
only carries them out. ChatFilterTests drives it through a small
settings model.

- A seeded entry whose tab was deleted never gets a rule turned on: a
  rule the manifest gains, or one re-added after the player deleted
  the rules, is added off. Tab listing skips a tab only an inactive
  server's rule fills.
- Owned rules pair with declared ones by content (Global-room flag,
  then when/action/mode/pattern, then leftovers), never by position,
  so a reorder or delete no longer moves on/off or colour to another
  rule. Reclaim uses the same pairing.
- Settings count as ready only after a successful read (or no file);
  a failed read is retried every 2 s, the unreadable copy kept once.
- Export leaves out server rules and server tabs; Import makes every
  imported rule the player's (no owner, server or globalRoom).
- Both rule editors lock pattern, mode, when, action, tab, move and
  delete on a server rule; on/off and colour stay live, with a note.
- No adopt-by-name: a taken name seeds "<Name> (<server name>)"
  instead, and tabServers is written only for a tab the plugin made.
  Reclaim requires the entry's name, its clash name, or a tab holding
  only the matched rules. AddCustomTab checks hidden tabs.
- Global-room discovery re-reads the entries and active servers under
  the lock. The manifest parser rejects a bad when or mode, and keeps
  a pattern's spaces.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
"New tab: Network" on a server where the DreamWeave Network tab is
hidden returned that hidden tab, so the player's new rule filled the
server's tab. ChatServerTabs.ResolveNewTab now keeps "returns the
existing one" for a visible tab only; a hidden match gets a free
numbered name ("Network 2"). An unreadable settings file is logged
once per run instead of on every 2 s retry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This pull request is marked as a work in progress.
This branch is out-of-date with the base branch
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u chat/server-tabs:AwfulWaffle-chat/server-tabs
git switch AwfulWaffle-chat/server-tabs

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch main
git merge --no-ff AwfulWaffle-chat/server-tabs
git switch AwfulWaffle-chat/server-tabs
git rebase main
git switch main
git merge --ff-only AwfulWaffle-chat/server-tabs
git switch AwfulWaffle-chat/server-tabs
git rebase main
git switch main
git merge --no-ff AwfulWaffle-chat/server-tabs
git switch main
git merge --squash AwfulWaffle-chat/server-tabs
git switch main
git merge --ff-only AwfulWaffle-chat/server-tabs
git switch main
git merge AwfulWaffle-chat/server-tabs
git push origin main
Sign in to join this conversation.
No reviewers
No labels
No milestone
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
rynth/RynthCore!15
No description provided.