[PR #4309] [MERGED] fix: honor chat message ranges in Professor Mari #6329

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

📋 Pull Request Information

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

Base: staging ← Head: agent/4308-chat-message-ranges


📝 Commits (2)

  • cc6784f chore: start issue 4308
  • ea54f8e fix: honor Professor Mari chat ranges

📊 Changes

4 files changed (+102 additions, -13 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 packages/server/src/services/mari-db/mari-db.service.ts (+42 -12)
📝 packages/server/src/services/professor-mari/workspace-agent.service.ts (+1 -0)
📝 scripts/regressions/open-issues.regression.ts (+58 -1)

📄 Description

Linked issue

Closes #4308

Why this change

Professor Mari could retrieve an entire long chat even when the user asked for only the latest messages or messages after a displayed post number. The oversized result was repeatedly truncated and could exhaust the workspace command loop before the requested edit completed.

Root cause

The chat command exposed only generic --tail and --offset pagination, without direct post-number semantics or prompt guidance mapping natural-language ranges onto those flags. Returned messages also omitted their displayed post numbers, making bounded pagination harder to continue reliably.

What changed

  • Added --last <n> and --after-post <n> to mari chats messages
  • Preserved the requested range while paging with --limit and --offset
  • Included each messages 1-indexed displayed postNumber in command output
  • Taught Professor Mari to keep every retrieval inside the user-requested range
  • Added real file-backed storage regression coverage for recent ranges, post-number ranges, pagination, and invalid oversized input
  • Added the fix to the Unreleased changelog

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

Automated verification notes

  • pnpm check — passed (localization, TypeScript/lint, production server/client builds)
  • Isolated file-backed database proof — passed for --last 3, --after-post 2 --limit 2 --offset 1, and rejection of --last 201
  • The same assertions ran successfully inside open-issues.regression.ts; that wider legacy suite later stops on pre-existing stale assertions in unrelated background-folder and Game dynamic-prompt coverage

Manual verification notes

  • Manually verify a Home Professor Mari request using only the last 200 messages from a long chat.
  • Manually verify a request using only messages after a visible #post number.

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] <paths> follow-up issue opened
  • Version/release files updated

No user guide changes are needed; the internal command help and Unreleased changelog are updated.

Summary by CodeRabbit

  • New Features

    • Added support for retrieving only the last N chat messages or messages after a specified post number.
    • Added range-aware pagination with --limit and --offset within the selected message range.
    • Expanded command help to document the new options and usage restrictions.
  • Bug Fixes

    • Prevented limited chat evidence requests from expanding into full-chat reads.
    • Added validation for invalid or conflicting range options.

🔄 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/4309 **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/4308-chat-message-ranges` --- ### 📝 Commits (2) - [`cc6784f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/cc6784f692110c71dd74f7711e6f910e638898e3) chore: start issue 4308 - [`ea54f8e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ea54f8e2e29472396f28d396628f6db9d32beea3) fix: honor Professor Mari chat ranges ### 📊 Changes **4 files changed** (+102 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `packages/server/src/services/mari-db/mari-db.service.ts` (+42 -12) 📝 `packages/server/src/services/professor-mari/workspace-agent.service.ts` (+1 -0) 📝 `scripts/regressions/open-issues.regression.ts` (+58 -1) </details> ### 📄 Description ## Linked issue Closes #4308 ## Why this change Professor Mari could retrieve an entire long chat even when the user asked for only the latest messages or messages after a displayed post number. The oversized result was repeatedly truncated and could exhaust the workspace command loop before the requested edit completed. ## Root cause The chat command exposed only generic `--tail` and `--offset` pagination, without direct post-number semantics or prompt guidance mapping natural-language ranges onto those flags. Returned messages also omitted their displayed post numbers, making bounded pagination harder to continue reliably. ## What changed - Added `--last <n>` and `--after-post <n>` to `mari chats messages` - Preserved the requested range while paging with `--limit` and `--offset` - Included each messages 1-indexed displayed `postNumber` in command output - Taught Professor Mari to keep every retrieval inside the user-requested range - Added real file-backed storage regression coverage for recent ranges, post-number ranges, pagination, and invalid oversized input - Added the fix to the Unreleased changelog ## 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` ### Automated verification notes - `pnpm check` — passed (localization, TypeScript/lint, production server/client builds) - Isolated file-backed database proof — passed for `--last 3`, `--after-post 2 --limit 2 --offset 1`, and rejection of `--last 201` - The same assertions ran successfully inside `open-issues.regression.ts`; that wider legacy suite later stops on pre-existing stale assertions in unrelated background-folder and Game dynamic-prompt coverage ### Manual verification notes - Manually verify a Home Professor Mari request using only the last 200 messages from a long chat. - Manually verify a request using only messages after a visible `#post` number. ## 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] <paths>` follow-up issue opened - [ ] Version/release files updated No user guide changes are needed; the internal command help and Unreleased changelog are updated. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added support for retrieving only the last *N* chat messages or messages after a specified post number. - Added range-aware pagination with `--limit` and `--offset` within the selected message range. - Expanded command help to document the new options and usage restrictions. - **Bug Fixes** - Prevented limited chat evidence requests from expanding into full-chat reads. - Added validation for invalid or conflicting range options. <!-- 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:23 +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#6329
No description provided.