[PR #1839] [MERGED] Fix haptic command safeguards #5309

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

📋 Pull Request Information

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

Base: refactor ← Head: fix/issue-1800-haptic-safeguards


📝 Commits (3)

  • 949ffb7 Fix haptic command safeguards
  • fb74740 Keep command prompts quiet by default
  • dc17a05 Refresh PR checks

📊 Changes

9 files changed (+230 additions, -17 deletions)

View changed files

📝 src-tauri/src/commands/storage/integrations/haptic.rs (+86 -11)
📝 src/engine/capabilities/integrations.ts (+2 -0)
📝 src/engine/generation/agent-runner.ts (+51 -1)
➕ src/engine/generation/connected-commands.test.ts (+61 -0)
📝 src/engine/generation/connected-commands.ts (+11 -0)
📝 src/engine/modes/chat/commands/character-commands.ts (+2 -2)
📝 src/features/runtime/generation/hooks/use-generate.ts (+13 -1)
📝 src/shared/api/haptics-api.ts (+2 -2)
📝 src/shared/api/integration-gateway.ts (+2 -0)

📄 Description

Linked issue

Closes #1800

Why this change

  • Haptic output could still execute from hidden generated tags or haptic-agent results without re-checking the chat's haptic controls and live device state.
  • The Rust haptic runtime also needed to preserve safer legacy-style behavior for mixed-device commands and managed duration stop timers.

What changed

  • Gates hidden [haptic: ...] commands behind both metadata.characterCommands and metadata.enableHapticFeedback, with regression coverage for each enabled/disabled combination.
  • Preserves the existing conversation command prompt default: command instructions stay quiet unless characterCommands is explicitly enabled, while haptic execution still re-checks both chat controls before running.
  • Adds haptic status/connect methods to the shared integration gateway so engine haptic agents can auto-connect with the chat Intiface URL and receive connected device names/capabilities.
  • Skips haptic-agent execution/replay when haptic feedback is disabled or no connected devices are available.
  • Restores constrict parsing for hidden haptic tags.
  • Updates the Rust haptic command path to return partial-success results, avoid failing all targets on the first incompatible device, and replace/clear per-target duration stop timers.

Refactor impact

Primary owner:

Engine generation and Rust haptic integration runtime.

Impact areas reviewed:

  • src/engine/generation/connected-commands.ts
  • src/engine/generation/agent-runner.ts
  • src/features/runtime/generation/hooks/use-generate.ts
  • src/shared/api/integration-gateway.ts
  • src-tauri/src/commands/storage/integrations/haptic.rs

Boundary notes:

  • Engine code depends only on the haptic gateway contract, not React, raw Tauri calls, or feature internals.
  • Feature replay remains in the runtime generation hook and calls the focused shared API gateway.
  • Privileged device execution, partial success, rate limiting, and timer management remain in Rust.
  • Haptics remain Tauri-local; this PR does not add a remote/browser haptics transport.

Pressure points touched:

  • Runtime generation haptic agent result handling.
  • Engine connected-command execution.
  • Tauri haptic integration command handling.

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

Codex-run proof:

  • Before fix, pnpm exec vitest run src/engine/generation/connected-commands.test.ts failed 3 of 4 haptic gate cases because hidden haptic commands executed when one or both gates were disabled.
  • After fix, pnpm exec vitest run src/engine/generation/connected-commands.test.ts passed.
  • pnpm exec vitest run src/engine/generation/prompt-assembly.test.ts src/engine/generation/connected-commands.test.ts passed after preserving the prompt default.
  • pnpm test passed.
  • pnpm typecheck passed.
  • pnpm check:architecture passed.
  • cargo check --manifest-path src-tauri/Cargo.toml --workspace passed.
  • cargo test --manifest-path src-tauri/Cargo.toml haptic --lib passed.
  • pnpm check passed.
  • The Marinara proof gate passed locally against the verification artifact.
  • Bunny review pass completed before opening this draft.

Manual limitations:

  • Physical Intiface/haptic hardware QA was not available in this environment, so real-device vibration/rotation/constriction behavior and mixed real-device partial success were not manually observed.
  • inflate was not restored. Local Buttplug Rust 10.0.2 sources have OutputType::Inflate commented out and no ClientDeviceOutputCommand::Inflate variant, so restoring it needs a separate dependency/API decision.

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:

  • Bugfix for existing haptics behavior; no new discoverable 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 (if applicable)

N/A; this is backend/engine/Rust haptic behavior. Proof is command-output based, with physical hardware QA called out above as unavailable.


🔄 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/1839 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 6/1/2026 **Status:** ✅ Merged **Merged:** 6/1/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `refactor` ← **Head:** `fix/issue-1800-haptic-safeguards` --- ### 📝 Commits (3) - [`949ffb7`](https://github.com/Pasta-Devs/Marinara-Engine/commit/949ffb77f0b6272a4d46a5bfc578dc399478dbc8) Fix haptic command safeguards - [`fb74740`](https://github.com/Pasta-Devs/Marinara-Engine/commit/fb747409cf8d399cb972c676631957bb35aa21cf) Keep command prompts quiet by default - [`dc17a05`](https://github.com/Pasta-Devs/Marinara-Engine/commit/dc17a053a1a7a8391ed8b61892b5197073860063) Refresh PR checks ### 📊 Changes **9 files changed** (+230 additions, -17 deletions) <details> <summary>View changed files</summary> 📝 `src-tauri/src/commands/storage/integrations/haptic.rs` (+86 -11) 📝 `src/engine/capabilities/integrations.ts` (+2 -0) 📝 `src/engine/generation/agent-runner.ts` (+51 -1) ➕ `src/engine/generation/connected-commands.test.ts` (+61 -0) 📝 `src/engine/generation/connected-commands.ts` (+11 -0) 📝 `src/engine/modes/chat/commands/character-commands.ts` (+2 -2) 📝 `src/features/runtime/generation/hooks/use-generate.ts` (+13 -1) 📝 `src/shared/api/haptics-api.ts` (+2 -2) 📝 `src/shared/api/integration-gateway.ts` (+2 -0) </details> ### 📄 Description <!-- Target branch: `refactor`. Change the base to `refactor` before submitting unless a maintainer explicitly asked for another base. --> <!-- Keep all checkboxes unchecked until a human has actually verified them. --> ## Linked issue <!-- Every user-facing PR should reference a feature request or issue report when practical. --> Closes #1800 ## Why this change <!-- What user problem, bug, refactor goal, or maintenance need does this solve? --> - Haptic output could still execute from hidden generated tags or haptic-agent results without re-checking the chat's haptic controls and live device state. - The Rust haptic runtime also needed to preserve safer legacy-style behavior for mixed-device commands and managed duration stop timers. ## What changed <!-- List the key changes in this PR. --> - Gates hidden `[haptic: ...]` commands behind both `metadata.characterCommands` and `metadata.enableHapticFeedback`, with regression coverage for each enabled/disabled combination. - Preserves the existing conversation command prompt default: command instructions stay quiet unless `characterCommands` is explicitly enabled, while haptic execution still re-checks both chat controls before running. - Adds haptic status/connect methods to the shared integration gateway so engine haptic agents can auto-connect with the chat Intiface URL and receive connected device names/capabilities. - Skips haptic-agent execution/replay when haptic feedback is disabled or no connected devices are available. - Restores `constrict` parsing for hidden haptic tags. - Updates the Rust haptic command path to return partial-success results, avoid failing all targets on the first incompatible device, and replace/clear per-target duration stop timers. ## Refactor impact Primary owner: Engine generation and Rust haptic integration runtime. Impact areas reviewed: - `src/engine/generation/connected-commands.ts` - `src/engine/generation/agent-runner.ts` - `src/features/runtime/generation/hooks/use-generate.ts` - `src/shared/api/integration-gateway.ts` - `src-tauri/src/commands/storage/integrations/haptic.rs` Boundary notes: - Engine code depends only on the haptic gateway contract, not React, raw Tauri calls, or feature internals. - Feature replay remains in the runtime generation hook and calls the focused shared API gateway. - Privileged device execution, partial success, rate limiting, and timer management remain in Rust. - Haptics remain Tauri-local; this PR does not add a remote/browser haptics transport. Pressure points touched: - Runtime generation haptic agent result handling. - Engine connected-command execution. - Tauri haptic integration command handling. ## Validation <!-- Check only what you personally ran or manually verified. Treat unchecked items as explicit TODOs. --> <!-- Do not submit *.test.ts or *.test.tsx files as PR proof; cite existing checks, command output, app/browser/Tauri verification, or manual notes instead. --> - [ ] 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 <!-- Describe exact commands and manual steps, including typecheck/build/docs/architecture/Rust/browser/remote-runtime checks when they apply. If an AI agent filled this out, verify it yourself before ticking boxes. --> Codex-run proof: - Before fix, `pnpm exec vitest run src/engine/generation/connected-commands.test.ts` failed 3 of 4 haptic gate cases because hidden haptic commands executed when one or both gates were disabled. - After fix, `pnpm exec vitest run src/engine/generation/connected-commands.test.ts` passed. - `pnpm exec vitest run src/engine/generation/prompt-assembly.test.ts src/engine/generation/connected-commands.test.ts` passed after preserving the prompt default. - `pnpm test` passed. - `pnpm typecheck` passed. - `pnpm check:architecture` passed. - `cargo check --manifest-path src-tauri/Cargo.toml --workspace` passed. - `cargo test --manifest-path src-tauri/Cargo.toml haptic --lib` passed. - `pnpm check` passed. - The Marinara proof gate passed locally against the verification artifact. - Bunny review pass completed before opening this draft. Manual limitations: - Physical Intiface/haptic hardware QA was not available in this environment, so real-device vibration/rotation/constriction behavior and mixed real-device partial success were not manually observed. - `inflate` was not restored. Local Buttplug Rust 10.0.2 sources have `OutputType::Inflate` commented out and no `ClientDeviceOutputCommand::Inflate` variant, so restoring it needs a separate dependency/API decision. ## 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: - Bugfix for existing haptics behavior; no new discoverable 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 (if applicable) N/A; this is backend/engine/Rust haptic behavior. Proof is command-output based, with physical hardware QA called out above as unavailable. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:15:07 +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#5309
No description provided.