[PR #8406] [MERGED] feat(mari): send the focused field's unsaved text and selection to Prof. Mari #8581

Closed
opened 2026-11-07 16:45:46 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8406
Author: @Gunterlie
Created: 10/28/2026
Status: ✅ Merged
Merged: 10/28/2026
Merged by: @Gunterlie

Base: feat/mari-companion ← Head: feat/mari-field-draft


📝 Commits (1)

  • 5aa25d8 feat(mari): send the focused field's unsaved text and selection to Prof. Mari

📊 Changes

12 files changed (+88 additions, -3 deletions)

View changed files

📝 packages/client/src/components/layout/GlobalOmnibar.tsx (+5 -0)
📝 packages/client/src/components/layout/GlobalOmnibarHost.tsx (+17 -0)
📝 packages/client/src/lib/mari-editor-fields.ts (+18 -0)
📝 packages/client/src/lib/professor-mari-command-center-context.ts (+9 -0)
📝 packages/client/src/lib/professor-mari-presentation.ts (+1 -0)
📝 packages/client/src/stores/ui.store.ts (+6 -1)
📝 packages/server/src/routes/professor-mari-workspace.routes.ts (+1 -0)
📝 packages/server/src/services/professor-mari/workspace-agent.service.ts (+3 -2)
📝 packages/shared/src/types/professor-mari-workspace.ts (+2 -0)
📝 scripts/regressions/command-center.regression.ts (+2 -0)
📝 scripts/regressions/mari-editor-fields.regression.ts (+8 -0)
📝 scripts/regressions/professor-mari/documentation.regression.ts (+16 -0)

📄 Description

Linked issue

No issue: planned work, slice 3 of the Professor Mari companion feature (Prof. Mari floats next to real editors and live-edits them). Slices are PRed into the integration branch feat/mari-companion (slice 1: #8401, slice 2: #8403, fixes: #8405).

Why this change

Prof. Mari only saw the saved character. If the user had unsaved text in a field, or selected a sentence and pressed Cmd+J ("Ask Prof. Mari about this"), she worked on stale text, so "make this warmer" could rewrite the old version. The companion and in-field review (slices 4–5) need her to work on what the user actually sees.

What changed

  • Shared: ProfessorMariAskContext.fieldDraft?: { value; selection? }.
  • Client capture (GlobalOmnibarHost.tsx): when Cmd+K opens the omnibar or Cmd+J opens Mari while focus is in a text input/textarea inside [data-mari-field], the field's current text and selection go into a transient ui.store value mariFieldDraft (cleared when the omnibar closes). Pure helper mariFieldDraft() in lib/mari-editor-fields.ts; list fields (tags, alternate_greetings) are skipped because the focused input is one tag or greeting, not the field.
  • Client send (GlobalOmnibar.tsx, professor-mari-command-center-context.ts): the handoff carries fieldDraft only when its field id matches the focused field; capped at 20 000 / 4 000 chars. Sent once per capture (cleared when Mari's pane takes it). Removing the field chip in Mari's composer also removes fieldDraft (professor-mari-presentation.ts).
  • Server: route schema accepts fieldDraft (same caps). buildHandoffContextPrompt puts it in <ask_mari_context> and tells the model it is the user's current, possibly unsaved text, to treat as untrusted user text.
  • Not sent: the typing-pause quick aside route never gets field text (existing privacy rule).
  • Regressions: capture helper (selection, list fields), chip removal drops the draft, route schema accepts and caps it.

Decisions to confirm in review:

  • Cmd+Enter on a quick-aside answer escalates to full Mari through the normal handoff, so the field text goes along. It is a deliberate press, so this keeps it.
  • Like other handoff context, fieldDraft is stored with the user message in Mari's chat history (up to 20 000 chars). No chip shows it beyond the field chip.

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

Agent-run (not manual): client tsc -b and server tsc --noEmit exit 0; ESLint and Prettier clean on touched client files; regressions mari-editor-fields, command-center and professor-mari/documentation pass. An Opus read-only review found 1 high (chip removal kept the text) and 3 medium issues (list fields, resend in one session, aside escalation); the first three are fixed, the fourth is the decision above.

Live run on a throwaway instance (copied data, MiniMax M3 via Bifrost), request bodies intercepted:

  • Unsaved Description text + selected words, Ctrl+J: body had fieldDraft.value with the unsaved marker and selection; Mari quoted it back (she quoted the whole field, not only the selection).
  • Field chip removed before sending: no fieldDraft.
  • Second Mari entry in the same omnibar session: no fieldDraft.
  • Quick aside (/api/professor-mari/quick/prompt): no field text.
  • Reload with unsaved edit: nothing saved.
  • Tags new-tag input: first run sent the half-typed tag (bug); fixed by skipping list fields by id. Recheck after the fix: Tags sends no fieldDraft; the Description control still does (requests aborted before the model).

To verify manually:

  1. In a Character editor, change Description without saving, select a phrase, press Cmd+J and ask Prof. Mari to rewrite the selection: she works on your unsaved text.
  2. Remove the Description chip before sending: she gets no field text.
  3. Focus the new-tag input in Tags and press Cmd+J: no field text is sent.

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)

UI evidence (if applicable)

No new UI. Screenshots of the live run are local (.tmp/mari-companion/live3/); attach on request.


🔄 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/8406 **Author:** [@Gunterlie](https://github.com/Gunterlie) **Created:** 10/28/2026 **Status:** ✅ Merged **Merged:** 10/28/2026 **Merged by:** [@Gunterlie](https://github.com/Gunterlie) **Base:** `feat/mari-companion` ← **Head:** `feat/mari-field-draft` --- ### 📝 Commits (1) - [`5aa25d8`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5aa25d8afa338a25e7c2029e90632dd5b5dd1775) feat(mari): send the focused field's unsaved text and selection to Prof. Mari ### 📊 Changes **12 files changed** (+88 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `packages/client/src/components/layout/GlobalOmnibar.tsx` (+5 -0) 📝 `packages/client/src/components/layout/GlobalOmnibarHost.tsx` (+17 -0) 📝 `packages/client/src/lib/mari-editor-fields.ts` (+18 -0) 📝 `packages/client/src/lib/professor-mari-command-center-context.ts` (+9 -0) 📝 `packages/client/src/lib/professor-mari-presentation.ts` (+1 -0) 📝 `packages/client/src/stores/ui.store.ts` (+6 -1) 📝 `packages/server/src/routes/professor-mari-workspace.routes.ts` (+1 -0) 📝 `packages/server/src/services/professor-mari/workspace-agent.service.ts` (+3 -2) 📝 `packages/shared/src/types/professor-mari-workspace.ts` (+2 -0) 📝 `scripts/regressions/command-center.regression.ts` (+2 -0) 📝 `scripts/regressions/mari-editor-fields.regression.ts` (+8 -0) 📝 `scripts/regressions/professor-mari/documentation.regression.ts` (+16 -0) </details> ### 📄 Description ## Linked issue No issue: planned work, slice 3 of the Professor Mari companion feature (Prof. Mari floats next to real editors and live-edits them). Slices are PRed into the integration branch `feat/mari-companion` (slice 1: #8401, slice 2: #8403, fixes: #8405). ## Why this change Prof. Mari only saw the saved character. If the user had unsaved text in a field, or selected a sentence and pressed Cmd+J ("Ask Prof. Mari about this"), she worked on stale text, so "make this warmer" could rewrite the old version. The companion and in-field review (slices 4–5) need her to work on what the user actually sees. ## What changed - Shared: `ProfessorMariAskContext.fieldDraft?: { value; selection? }`. - Client capture (`GlobalOmnibarHost.tsx`): when Cmd+K opens the omnibar or Cmd+J opens Mari while focus is in a text input/textarea inside `[data-mari-field]`, the field's current text and selection go into a transient `ui.store` value `mariFieldDraft` (cleared when the omnibar closes). Pure helper `mariFieldDraft()` in `lib/mari-editor-fields.ts`; list fields (`tags`, `alternate_greetings`) are skipped because the focused input is one tag or greeting, not the field. - Client send (`GlobalOmnibar.tsx`, `professor-mari-command-center-context.ts`): the handoff carries `fieldDraft` only when its field id matches the focused field; capped at 20 000 / 4 000 chars. Sent once per capture (cleared when Mari's pane takes it). Removing the field chip in Mari's composer also removes `fieldDraft` (`professor-mari-presentation.ts`). - Server: route schema accepts `fieldDraft` (same caps). `buildHandoffContextPrompt` puts it in `<ask_mari_context>` and tells the model it is the user's current, possibly unsaved text, to treat as untrusted user text. - Not sent: the typing-pause quick aside route never gets field text (existing privacy rule). - Regressions: capture helper (selection, list fields), chip removal drops the draft, route schema accepts and caps it. Decisions to confirm in review: - Cmd+Enter on a quick-aside answer escalates to full Mari through the normal handoff, so the field text goes along. It is a deliberate press, so this keeps it. - Like other handoff context, `fieldDraft` is stored with the user message in Mari's chat history (up to 20 000 chars). No chip shows it beyond the field chip. ## 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 Agent-run (not manual): client `tsc -b` and server `tsc --noEmit` exit 0; ESLint and Prettier clean on touched client files; regressions `mari-editor-fields`, `command-center` and `professor-mari/documentation` pass. An Opus read-only review found 1 high (chip removal kept the text) and 3 medium issues (list fields, resend in one session, aside escalation); the first three are fixed, the fourth is the decision above. Live run on a throwaway instance (copied data, MiniMax M3 via Bifrost), request bodies intercepted: - Unsaved Description text + selected words, Ctrl+J: body had `fieldDraft.value` with the unsaved marker and `selection`; Mari quoted it back (she quoted the whole field, not only the selection). - Field chip removed before sending: no `fieldDraft`. - Second Mari entry in the same omnibar session: no `fieldDraft`. - Quick aside (`/api/professor-mari/quick/prompt`): no field text. - Reload with unsaved edit: nothing saved. - Tags new-tag input: first run sent the half-typed tag (bug); fixed by skipping list fields by id. Recheck after the fix: Tags sends no `fieldDraft`; the Description control still does (requests aborted before the model). To verify manually: 1. In a Character editor, change Description without saving, select a phrase, press Cmd+J and ask Prof. Mari to rewrite the selection: she works on your unsaved text. 2. Remove the Description chip before sending: she gets no field text. 3. Focus the new-tag input in Tags and press Cmd+J: no field text is sent. ## 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) ## UI evidence (if applicable) No new UI. Screenshots of the live run are local (`.tmp/mari-companion/live3/`); attach on request. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 16:45:46 +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#8581
No description provided.