[PR #4317] [MERGED] Add scoped context capabilities to Browser Extensions #6332

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/4317
Author: @SpicyMarinara
Created: 7/30/2026
Status: ✅ Merged
Merged: 7/30/2026
Merged by: @SpicyMarinara

Base: staging ← Head: agent/scoped-extension-context


📝 Commits (6)

  • 4972fd7 Add scoped browser extension context API
  • f54ac64 Add scoped extension record permissions
  • 06be424 Address scoped extension review feedback
  • 2cefb72 Unify extension context limits
  • 4998d14 Cancel unsubscribed context callbacks
  • d10f428 Harden extension context subscriptions

📊 Changes

25 files changed (+1156 additions, -53 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 docs/FAQ.md (+1 -1)
📝 docs/development/frontend.md (+1 -1)
📝 docs/development/personal-extensions.md (+27 -2)
📝 docs/extending/personal-extensions.md (+50 -2)
📝 docs/home/professor-mari.md (+1 -1)
📝 packages/client/src/components/layout/PersonalExtensionInjector.tsx (+89 -4)
📝 packages/client/src/components/panels/settings/PersonalExtensionsSettings.tsx (+69 -2)
➕ packages/client/src/lib/personal-extension-context.ts (+48 -0)
📝 packages/client/src/lib/personal-extension-import.ts (+38 -7)
📝 packages/client/src/lib/personal-extension-transfer.ts (+1 -0)
📝 packages/client/src/localization/locales/en.json (+10 -2)
📝 packages/client/src/localization/locales/ko.json (+1 -1)
📝 packages/server/src/db/schema/extensions.ts (+1 -0)
📝 packages/server/src/routes/backup.routes.ts (+29 -6)
📝 packages/server/src/routes/personal-extensions.routes.ts (+338 -1)
📝 packages/server/src/services/extensions/personal-extension-hash.ts (+12 -2)
📝 packages/server/src/services/extensions/personal-extension-storage.service.ts (+27 -5)
📝 packages/server/src/services/mari-db/mari-db.service.ts (+25 -1)
📝 packages/server/src/services/professor-mari/workspace-agent.service.ts (+8 -2)

...and 5 more files

📄 Description

Important

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

Linked issue

Closes #4316

Why this change

Browser Personal Extensions need stable active-chat context for tools such as per-chat Notepad tabs. Extensions that genuinely need the active Character cards or selected Persona should be able to request that data explicitly without restoring legacy DOM, same-origin API, whole-library, message, or mutation authority.

What changed

  • Added Browser Extension API v5 with immutable active chat and Character IDs plus live context subscriptions.
  • Added separate read_active_characters and read_active_persona permissions. Requested permissions are persisted in revisions, included in the executable hash, and disclosed in Settings and exact-hash approval.
  • Added a server broker that derives records from the active chat, exposes only selected text fields, and enforces per-field, aggregate, tag, and record-count bounds. The Worker independently validates, bounds, freezes, and drops undeclared/out-of-scope records.
  • Kept messages, whole libraries, creator notes, system prompts, post-history instructions, comments, avatar paths, chat metadata, DOM, database, network, and mutation operations unavailable.
  • Preserved legacy hashes for extensions that request no new permissions; permission changes disable an extension and require fresh approval.
  • Updated import/export, backup quarantine, Professor Mari authoring, docs, localization, and security regression coverage.

Validation

Local automated validation completed successfully:

  • pnpm check
  • pnpm regression:extensions-security (including macOS Seatbelt runtime proof)
  • pnpm localization:check
  • pnpm regression:docs
  • pnpm regression:backup
  • pnpm exec playwright test -c playwright.config.ts --grep "Personal Extensions" (desktop and mobile)

Human verification still requested:

  • Manually verify a Browser Extension keeps separate state while switching chats.
  • Manually verify group chats expose all active Character IDs.
  • Manually verify undeclared Character-card and Persona permissions return no record data.
  • Manually verify each declared permission is visible before approval.
  • Manually verify active Character and Persona fields render correctly in a real extension.

Docs and release impact

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

Docs were updated and translation follow-up #4318 was opened.

UI evidence

The Personal Extensions settings flow passes in desktop and mobile Chromium. The approval dialog and Requested data access section use localized, explicit permission copy; final real-extension verification remains listed above.

Summary by CodeRabbit

  • New Features

    • Browser Personal Extensions (API v5) now expose an immutable active-chat context snapshot plus subscription-based updates.
    • Extensions can request separately approved, bounded read access to active Character-card fields and/or the selected Persona.
    • Personal Extensions settings now include a client capabilities picker and display requested permissions during review.
  • Security

    • Capability requests are included in approval and enforce re-binding to the approved revision; changing permissions disables until re-approved.
  • Documentation / Tests

    • Updated FAQ and Personal Extensions documentation to clarify snapshot contents, permission bounds, and denied access.
    • Strengthened scoped-context regression coverage.

🔄 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/4317 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 7/30/2026 **Status:** ✅ Merged **Merged:** 7/30/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `agent/scoped-extension-context` --- ### 📝 Commits (6) - [`4972fd7`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4972fd7771479abebf6f015ceb63870926cb8984) Add scoped browser extension context API - [`f54ac64`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f54ac64975bdffd05e2604a03e548a107e17867f) Add scoped extension record permissions - [`06be424`](https://github.com/Pasta-Devs/Marinara-Engine/commit/06be42430a86d6b3f49763add30282aeadacdb9f) Address scoped extension review feedback - [`2cefb72`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2cefb7225ba6442332925eaa90ede24b4211f377) Unify extension context limits - [`4998d14`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4998d14ff52ae054b034eca8c37a6d6befe119d3) Cancel unsubscribed context callbacks - [`d10f428`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d10f428d4720c4f7bf60e91bc2d42bc1282493a9) Harden extension context subscriptions ### 📊 Changes **25 files changed** (+1156 additions, -53 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `docs/FAQ.md` (+1 -1) 📝 `docs/development/frontend.md` (+1 -1) 📝 `docs/development/personal-extensions.md` (+27 -2) 📝 `docs/extending/personal-extensions.md` (+50 -2) 📝 `docs/home/professor-mari.md` (+1 -1) 📝 `packages/client/src/components/layout/PersonalExtensionInjector.tsx` (+89 -4) 📝 `packages/client/src/components/panels/settings/PersonalExtensionsSettings.tsx` (+69 -2) ➕ `packages/client/src/lib/personal-extension-context.ts` (+48 -0) 📝 `packages/client/src/lib/personal-extension-import.ts` (+38 -7) 📝 `packages/client/src/lib/personal-extension-transfer.ts` (+1 -0) 📝 `packages/client/src/localization/locales/en.json` (+10 -2) 📝 `packages/client/src/localization/locales/ko.json` (+1 -1) 📝 `packages/server/src/db/schema/extensions.ts` (+1 -0) 📝 `packages/server/src/routes/backup.routes.ts` (+29 -6) 📝 `packages/server/src/routes/personal-extensions.routes.ts` (+338 -1) 📝 `packages/server/src/services/extensions/personal-extension-hash.ts` (+12 -2) 📝 `packages/server/src/services/extensions/personal-extension-storage.service.ts` (+27 -5) 📝 `packages/server/src/services/mari-db/mari-db.service.ts` (+25 -1) 📝 `packages/server/src/services/professor-mari/workspace-agent.service.ts` (+8 -2) _...and 5 more files_ </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository staging branch or a same-repository `hotfix/*` branch to `main`. ## Linked issue Closes #4316 ## Why this change Browser Personal Extensions need stable active-chat context for tools such as per-chat Notepad tabs. Extensions that genuinely need the active Character cards or selected Persona should be able to request that data explicitly without restoring legacy DOM, same-origin API, whole-library, message, or mutation authority. ## What changed - Added Browser Extension API v5 with immutable active chat and Character IDs plus live context subscriptions. - Added separate `read_active_characters` and `read_active_persona` permissions. Requested permissions are persisted in revisions, included in the executable hash, and disclosed in Settings and exact-hash approval. - Added a server broker that derives records from the active chat, exposes only selected text fields, and enforces per-field, aggregate, tag, and record-count bounds. The Worker independently validates, bounds, freezes, and drops undeclared/out-of-scope records. - Kept messages, whole libraries, creator notes, system prompts, post-history instructions, comments, avatar paths, chat metadata, DOM, database, network, and mutation operations unavailable. - Preserved legacy hashes for extensions that request no new permissions; permission changes disable an extension and require fresh approval. - Updated import/export, backup quarantine, Professor Mari authoring, docs, localization, and security regression coverage. ## Validation Local automated validation completed successfully: - `pnpm check` - `pnpm regression:extensions-security` (including macOS Seatbelt runtime proof) - `pnpm localization:check` - `pnpm regression:docs` - `pnpm regression:backup` - `pnpm exec playwright test -c playwright.config.ts --grep "Personal Extensions"` (desktop and mobile) Human verification still requested: - [ ] Manually verify a Browser Extension keeps separate state while switching chats. - [ ] Manually verify group chats expose all active Character IDs. - [ ] Manually verify undeclared Character-card and Persona permissions return no record data. - [ ] Manually verify each declared permission is visible before approval. - [ ] Manually verify active Character and Persona fields render correctly in a real extension. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened - [ ] Version/release files updated (only if this PR includes a version bump) Docs were updated and translation follow-up #4318 was opened. ## UI evidence The Personal Extensions settings flow passes in desktop and mobile Chromium. The approval dialog and **Requested data access** section use localized, explicit permission copy; final real-extension verification remains listed above. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Browser Personal Extensions (API v5) now expose an immutable active-chat context snapshot plus subscription-based updates. * Extensions can request separately approved, bounded read access to active Character-card fields and/or the selected Persona. * Personal Extensions settings now include a client capabilities picker and display requested permissions during review. * **Security** * Capability requests are included in approval and enforce re-binding to the approved revision; changing permissions disables until re-approved. * **Documentation / Tests** * Updated FAQ and Personal Extensions documentation to clarify snapshot contents, permission bounds, and denied access. * Strengthened scoped-context regression coverage. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:09:26 +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#6332
No description provided.