[PR #61] [MERGED] feat: bot browser improvements — PNG download, JanitorAI gating, persistent state #4430

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/61
Author: @LukaTheHero
Created: 4/5/2026
Status: ✅ Merged
Merged: 4/5/2026
Merged by: @LukaTheHero

Base: main ← Head: feature/bot-browser-improvements


📝 Commits (1)

  • 7c09fbe feat: download as PNG, JanitorAI import gating, session expiry detection, persistent browser state

📊 Changes

2 files changed (+277 additions, -9 deletions)

View changed files

📝 packages/client/src/components/bot-browser/BotBrowserView.tsx (+255 -5)
📝 packages/client/src/components/layout/AppShell.tsx (+22 -4)

📄 Description

What's new

1. Download as PNG Character Card (all providers)

  • New "Download as PNG" button in the character detail view for every provider
  • Builds a valid SillyTavern-compatible PNG with embedded V2 character card metadata
  • Downloaded PNGs can be re-imported into Marinara or any ST-compatible frontend

2. JanitorAI Import/Download Gating

  • Not logged in: Import and Download buttons show "Log in to JanitorAI" in amber — clicking opens the login modal
  • Logged in, hidden definitions: Both buttons greyed out showing "Extract Definitions to Unlock"
  • Logged in, definitions available (or extracted): Both buttons fully enabled
  • Other providers are unaffected — buttons always work normally

3. JanitorAI Session Expiry Detection

  • When clicking a JanitorAI character, the session is checked first
  • If expired, the UI immediately updates and shows a warning toast: "JanitorAI session expired — please log in again"
  • Prevents confusing "Login Required" messages when the user thinks they're still logged in

4. Persistent Browser State

  • Bot browser now preserves its state (search results, selected character, page, filters) when closed and reopened
  • Uses CSS visibility toggle instead of unmounting, with lazy initialization (only loads on first open)

Files changed

  • packages/client/src/components/bot-browser/BotBrowserView.tsx — PNG builder, button gating, session check
  • packages/client/src/components/layout/AppShell.tsx — persistent mount wrapper for bot browser

Technical Notes on Persistent Mount

The BotBrowserPersistent wrapper uses a simple pattern:

  • Lazy initialization: The BotBrowserView component is NOT loaded until the user opens the bot browser for the first time (everOpened flag). Before that, it renders null — zero cost.
  • CSS hiding: When the browser is closed, the component is hidden via className="hidden" (Tailwind's display: none). This means:
    • No layout calculations occur for hidden elements
    • No paint or composite operations
    • No event listeners fire on hidden DOM
    • React does not re-render hidden children unless their state/props change
  • No background activity: The bot browser has no intervals, timers, or polling when idle. The search only triggers on user interaction. So a hidden bot browser is completely inert.

Will this cause lag?

No. A display: none element is effectively invisible to the browser's rendering pipeline — it's skipped during layout, paint, and compositing. The only cost is the DOM nodes staying in memory, which for a search results page is negligible (a few hundred KB at most). This is the same pattern used by browser tab managers, VS Code panels, and Discord's own channel switching. The component does absolutely nothing while hidden — no network requests, no timers, no re-renders. The only moment it "wakes up" is when the user opens the bot browser again, at which point the browser simply flips it back to display: flex and the already-rendered content appears instantly.


🔄 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/61 **Author:** [@LukaTheHero](https://github.com/LukaTheHero) **Created:** 4/5/2026 **Status:** ✅ Merged **Merged:** 4/5/2026 **Merged by:** [@LukaTheHero](https://github.com/LukaTheHero) **Base:** `main` ← **Head:** `feature/bot-browser-improvements` --- ### 📝 Commits (1) - [`7c09fbe`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7c09fbe6b8b6fde79a63f7be43ebcf665242b731) feat: download as PNG, JanitorAI import gating, session expiry detection, persistent browser state ### 📊 Changes **2 files changed** (+277 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `packages/client/src/components/bot-browser/BotBrowserView.tsx` (+255 -5) 📝 `packages/client/src/components/layout/AppShell.tsx` (+22 -4) </details> ### 📄 Description ## What's new ### 1. Download as PNG Character Card (all providers) - New "Download as PNG" button in the character detail view for every provider - Builds a valid SillyTavern-compatible PNG with embedded V2 character card metadata - Downloaded PNGs can be re-imported into Marinara or any ST-compatible frontend ### 2. JanitorAI Import/Download Gating - **Not logged in:** Import and Download buttons show "Log in to JanitorAI" in amber — clicking opens the login modal - **Logged in, hidden definitions:** Both buttons greyed out showing "Extract Definitions to Unlock" - **Logged in, definitions available (or extracted):** Both buttons fully enabled - Other providers are unaffected — buttons always work normally ### 3. JanitorAI Session Expiry Detection - When clicking a JanitorAI character, the session is checked first - If expired, the UI immediately updates and shows a warning toast: "JanitorAI session expired — please log in again" - Prevents confusing "Login Required" messages when the user thinks they're still logged in ### 4. Persistent Browser State - Bot browser now preserves its state (search results, selected character, page, filters) when closed and reopened - Uses CSS visibility toggle instead of unmounting, with lazy initialization (only loads on first open) ## Files changed - `packages/client/src/components/bot-browser/BotBrowserView.tsx` — PNG builder, button gating, session check - `packages/client/src/components/layout/AppShell.tsx` — persistent mount wrapper for bot browser ## Technical Notes on Persistent Mount The `BotBrowserPersistent` wrapper uses a simple pattern: - **Lazy initialization:** The BotBrowserView component is NOT loaded until the user opens the bot browser for the first time (`everOpened` flag). Before that, it renders `null` — zero cost. - **CSS hiding:** When the browser is closed, the component is hidden via `className="hidden"` (Tailwind's `display: none`). This means: - No layout calculations occur for hidden elements - No paint or composite operations - No event listeners fire on hidden DOM - React does not re-render hidden children unless their state/props change - **No background activity:** The bot browser has no intervals, timers, or polling when idle. The search only triggers on user interaction. So a hidden bot browser is completely inert. ## Will this cause lag? **No.** A `display: none` element is effectively invisible to the browser's rendering pipeline — it's skipped during layout, paint, and compositing. The only cost is the DOM nodes staying in memory, which for a search results page is negligible (a few hundred KB at most). This is the same pattern used by browser tab managers, VS Code panels, and Discord's own channel switching. The component does absolutely nothing while hidden — no network requests, no timers, no re-renders. The only moment it "wakes up" is when the user opens the bot browser again, at which point the browser simply flips it back to `display: flex` and the already-rendered content appears instantly. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:07:32 +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#4430
No description provided.