[PR #2460] [MERGED] Fix message extra defaults on create #5615

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/2460
Author: @Xelvanis
Created: 6/6/2026
Status: ✅ Merged
Merged: 6/6/2026
Merged by: @Xelvanis

Base: refactor ← Head: fix/2272-message-extra-defaults


📝 Commits (4)

  • abac60c fix message extra defaults on create
  • 6459416 fix message create validation gaps
  • d0da541 fix active swipe create inheritance
  • 4777583 fix message create validation holes

📊 Changes

8 files changed (+588 additions, -26 deletions)

View changed files

📝 src-tauri/src/commands/storage/commands/entities.rs (+73 -1)
📝 src-tauri/src/commands/storage/contracts.rs (+2 -1)
📝 src-tauri/src/commands/storage/message_swipes.rs (+305 -4)
📝 src-tauri/src/commands/storage/shared.rs (+129 -0)
📝 src/engine/contracts/schemas/chat.schema.ts (+23 -7)
📝 src/features/catalog/chats/hooks/use-chats.ts (+16 -8)
📝 src/shared/api/storage-api.ts (+36 -4)
📝 src/shared/lib/slash-commands.ts (+4 -1)

📄 Description

Linked issue

Closes #2272

Why this change

  • Message creation still missed the legacy MessageExtra default leaves when callers omitted extra.
  • The remaining gap affected the shared API and embedded/remote storage create contract while active-swipe seed and edit sync still needed to stay intact.

What changed

  • Registered messages.extra as a Rust create default and merge displayText, isGenerated, tokenCount, and generationInfo without overwriting provided values.
  • Routed direct message sidecar creates through the same entity-default path so generic storage_create, direct Rust create callers, and remote /api/invoke stay aligned.
  • Updated the TypeScript create schema, shared API default builder, and catalog optimistic create row to preserve richer create payloads while sending the legacy default shape.
  • Added focused Rust coverage for create default extra, initial sidecar swipe persistence, role-based isGenerated, and preservation of richer extra values.

Refactor impact

Primary owner:

Rust storage, shared API, and engine chat contract.

Impact areas reviewed:

  • Rust storage message create/defaults
  • Message swipe sidecar persistence and materialization
  • Generic storage create command boundary
  • Shared API message create wrapper
  • Catalog create-message hook and optimistic row
  • Engine chat create schema

Boundary notes:

  • Engine schema remains React-free and does not import feature, store, Tauri, or shared API adapters.
  • Feature code continues using the focused shared storage API wrapper; no new raw invokeTauri or remote fetch calls were added.
  • Embedded and remote runtime behavior stay aligned because /api/invoke dispatches storage_create through storage_create_inner, the same command path as embedded Tauri.
  • Rust storage remains the authoritative persistence default; the TypeScript wrapper mirrors the shape for caller consistency.

Pressure points touched:

  • None of ModeSurface, GameSurface, shared mode UI orchestration, src-tauri/src/lib.rs command registration, or import modules were touched.

Validation

  • Matching validation command passes locally (for example pnpm typecheck, pnpm build, pnpm check:architecture, pnpm check:docs, or full pnpm check when warranted)
  • Full pnpm check passes before PR push/handoff
  • Human/manual validation completed by contributor or reviewer

Manual verification notes

  • cargo test --manifest-path src-tauri/Cargo.toml default_extra --lib passed: 2 tests.
  • cargo test --manifest-path src-tauri/Cargo.toml create_message_preserves_provided_extra_when_defaulting_missing_leaves --lib passed: 1 test.
  • pnpm typecheck passed.
  • cargo check --manifest-path src-tauri/Cargo.toml --workspace passed.
  • pnpm check:architecture passed.
  • pnpm check passed.
  • Durable test rationale: this fixes a known regression in #2272 where normal message creation could silently miss legacy MessageExtra leaves. Existing proof was insufficient because the incomplete fix was marked as not fully addressed. The committed tests are narrow storage-owner tests beside existing message create and sidecar persistence coverage.

Feature Discoverability

Check exactly one:

  • Updated src/features/shell/discovery/ because this PR adds or materially changes a user-discoverable feature, workflow, setting, mode, panel, import path, agent, media capability, or advanced tool.
  • N/A because this PR is only a bugfix, refactor, test, docs, internal wiring, visual polish, copy edit, or compatibility fix and does not add a new thing users need to find.

Reason:

  • Storage compatibility bugfix only; no new user-discoverable feature or workflow was added.

Docs and release impact

  • No docs changes needed
  • Updated README.md
  • Updated CONTRIBUTING.md
  • Updated docs/developer/
  • Updated repo skills or AGENTS.md
  • Confirmed this PR does not restore old staging/package-workspace/release claims

UI evidence

Not applicable; this is a storage-contract compatibility fix with no visible UI change.

Summary by CodeRabbit

  • New Features

    • Added support for message metadata through a new extra field with default values including display text, generation status, token count, and generation info.
    • Added support for message swipe tracking with active swipe index and swipe count.
  • Tests

    • Added comprehensive test coverage for message creation and default field initialization.

🔄 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/2460 **Author:** [@Xelvanis](https://github.com/Xelvanis) **Created:** 6/6/2026 **Status:** ✅ Merged **Merged:** 6/6/2026 **Merged by:** [@Xelvanis](https://github.com/Xelvanis) **Base:** `refactor` ← **Head:** `fix/2272-message-extra-defaults` --- ### 📝 Commits (4) - [`abac60c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/abac60c8e4628904b34042caa37d613fdfeb8647) fix message extra defaults on create - [`6459416`](https://github.com/Pasta-Devs/Marinara-Engine/commit/645941698dc291d744d29e9330a88269375b1e44) fix message create validation gaps - [`d0da541`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d0da54178f5b4534da73e068b0d4ef223417fcd0) fix active swipe create inheritance - [`4777583`](https://github.com/Pasta-Devs/Marinara-Engine/commit/47775835a05f0b14bd93c263d024d1288d7aed93) fix message create validation holes ### 📊 Changes **8 files changed** (+588 additions, -26 deletions) <details> <summary>View changed files</summary> 📝 `src-tauri/src/commands/storage/commands/entities.rs` (+73 -1) 📝 `src-tauri/src/commands/storage/contracts.rs` (+2 -1) 📝 `src-tauri/src/commands/storage/message_swipes.rs` (+305 -4) 📝 `src-tauri/src/commands/storage/shared.rs` (+129 -0) 📝 `src/engine/contracts/schemas/chat.schema.ts` (+23 -7) 📝 `src/features/catalog/chats/hooks/use-chats.ts` (+16 -8) 📝 `src/shared/api/storage-api.ts` (+36 -4) 📝 `src/shared/lib/slash-commands.ts` (+4 -1) </details> ### 📄 Description ## Linked issue Closes #2272 ## Why this change - Message creation still missed the legacy `MessageExtra` default leaves when callers omitted `extra`. - The remaining gap affected the shared API and embedded/remote storage create contract while active-swipe seed and edit sync still needed to stay intact. ## What changed - Registered `messages.extra` as a Rust create default and merge `displayText`, `isGenerated`, `tokenCount`, and `generationInfo` without overwriting provided values. - Routed direct message sidecar creates through the same entity-default path so generic `storage_create`, direct Rust create callers, and remote `/api/invoke` stay aligned. - Updated the TypeScript create schema, shared API default builder, and catalog optimistic create row to preserve richer create payloads while sending the legacy default shape. - Added focused Rust coverage for create default extra, initial sidecar swipe persistence, role-based `isGenerated`, and preservation of richer `extra` values. ## Refactor impact Primary owner: Rust storage, shared API, and engine chat contract. Impact areas reviewed: - Rust storage message create/defaults - Message swipe sidecar persistence and materialization - Generic storage create command boundary - Shared API message create wrapper - Catalog create-message hook and optimistic row - Engine chat create schema Boundary notes: - Engine schema remains React-free and does not import feature, store, Tauri, or shared API adapters. - Feature code continues using the focused shared storage API wrapper; no new raw `invokeTauri` or remote fetch calls were added. - Embedded and remote runtime behavior stay aligned because `/api/invoke` dispatches `storage_create` through `storage_create_inner`, the same command path as embedded Tauri. - Rust storage remains the authoritative persistence default; the TypeScript wrapper mirrors the shape for caller consistency. Pressure points touched: - None of `ModeSurface`, `GameSurface`, shared mode UI orchestration, `src-tauri/src/lib.rs` command registration, or import modules were touched. ## Validation - [x] Matching validation command passes locally (for example `pnpm typecheck`, `pnpm build`, `pnpm check:architecture`, `pnpm check:docs`, or full `pnpm check` when warranted) - [x] Full `pnpm check` passes before PR push/handoff - [ ] Human/manual validation completed by contributor or reviewer ### Manual verification notes - `cargo test --manifest-path src-tauri/Cargo.toml default_extra --lib` passed: 2 tests. - `cargo test --manifest-path src-tauri/Cargo.toml create_message_preserves_provided_extra_when_defaulting_missing_leaves --lib` passed: 1 test. - `pnpm typecheck` passed. - `cargo check --manifest-path src-tauri/Cargo.toml --workspace` passed. - `pnpm check:architecture` passed. - `pnpm check` passed. - Durable test rationale: this fixes a known regression in #2272 where normal message creation could silently miss legacy `MessageExtra` leaves. Existing proof was insufficient because the incomplete fix was marked as not fully addressed. The committed tests are narrow storage-owner tests beside existing message create and sidecar persistence coverage. ## Feature Discoverability Check exactly one: - [ ] Updated `src/features/shell/discovery/` because this PR adds or materially changes a user-discoverable feature, workflow, setting, mode, panel, import path, agent, media capability, or advanced tool. - [x] N/A because this PR is only a bugfix, refactor, test, docs, internal wiring, visual polish, copy edit, or compatibility fix and does not add a new thing users need to find. Reason: - Storage compatibility bugfix only; no new user-discoverable feature or workflow was added. ## Docs and release impact - [x] No docs changes needed - [ ] Updated `README.md` - [ ] Updated `CONTRIBUTING.md` - [ ] Updated `docs/developer/` - [ ] Updated repo skills or `AGENTS.md` - [x] Confirmed this PR does not restore old staging/package-workspace/release claims ## UI evidence Not applicable; this is a storage-contract compatibility fix with no visible UI change. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added support for message metadata through a new `extra` field with default values including display text, generation status, token count, and generation info. * Added support for message swipe tracking with active swipe index and swipe count. * **Tests** * Added comprehensive test coverage for message creation and default field initialization. <!-- 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-22 04:17:50 +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#5615
No description provided.