[PR #1258] [MERGED] Fix LLM stream cancel target and logging #5006

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/1258
Author: @Xelvanis
Created: 5/26/2026
Status: ✅ Merged
Merged: 5/27/2026
Merged by: @Xelvanis

Base: refactor ← Head: fix/log-llm-cancel-failures


📝 Commits (2)

  • 313a9bf fix llm stream cancel visibility
  • ebaab1a Merge remote-tracking branch 'origin/refactor' into fix/log-llm-cancel-failures

📊 Changes

6 files changed (+389 additions, -13 deletions)

View changed files

➕ src/shared/api/llm-api.test.ts (+150 -0)
📝 src/shared/api/llm-api.ts (+6 -4)
➕ src/shared/api/llm-cancel-logging.test.ts (+52 -0)
➕ src/shared/api/llm-cancel-logging.ts (+71 -0)
➕ src/shared/api/remote-runtime.test.ts (+95 -0)
📝 src/shared/api/remote-runtime.ts (+15 -9)

📄 Description

Linked issue

Closes #1257

Why this change

LLM stream cancellation had two related failure paths:

  • Remote stream cancellation resolved the Remote Runtime URL again at abort time, so changing the setting while a stream was active could send cancel to the wrong runtime.
  • Local and remote cancel failures were swallowed, which made failed or misrouted cancellation hard to diagnose.

What changed

  • Capture the remote runtime target once when a remote LLM stream starts.
  • Reuse that captured target for both the stream request and the cancel request.
  • Preserve best-effort cancellation semantics while logging sanitized cancel failure details.
  • Treat non-OK remote cancel responses as visible cancel failures for logging.
  • Add focused tests for local cancel failure/success, remote cancel failure/success, missing remote target, and target-drift behavior.

Refactor impact

Primary owner:

Shared API wrapper and remote runtime routing.

Impact areas reviewed:

  • src/shared/api/llm-api.ts
  • src/shared/api/remote-runtime.ts
  • LLM stream cancellation lifecycle
  • Remote runtime target resolution
  • Sanitized debug logging for failed cancellation

Boundary notes:

This stays in the shared API adapter layer. It does not change engine product rules, React feature UI, Rust command implementations, provider transport, storage, or the HTTP route contract.

Pressure points touched:

None. No ModeSurface, GameSurface, shared mode UI, Rust command registration, or import modules changed.

Validation

  • pnpm check passes locally
  • pnpm typecheck passes locally
  • pnpm build passes locally
  • pnpm check:architecture passes locally
  • pnpm check:docs passes locally
  • cargo check --manifest-path src-tauri/Cargo.toml --workspace passes locally
  • Rust clippy/tests were run for Rust behavior changes
  • Browser or Tauri app manual verification completed
  • Playwright, screenshot, or recording evidence added for UI changes
  • Remote runtime smoke checked when relevant

Manual verification notes

Commands run locally:

  • pnpm test -- src/shared/api/llm-api.test.ts src/shared/api/remote-runtime.test.ts src/shared/api/llm-cancel-logging.test.ts
  • pnpm test
  • pnpm typecheck
  • pnpm check:architecture
  • pnpm build
  • git diff --check

pnpm build passed with existing Vite code-splitting/chunk-size warnings. Those warnings are tracked separately in the local chore list and are not introduced by this PR.

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

No docs or changelog update was made. This repo branch does not have CHANGELOG.md, and the change is a shared API bugfix without user-facing copy changes.

UI evidence

N/A. No visible UI behavior changed.

Summary by CodeRabbit

  • New Features

    • Added support for canceling LLM streams on remote runtimes.
  • Bug Fixes

    • Improved error handling and logging when stream cancellation fails.
    • Enhanced abort handling consistency across local and remote streaming scenarios.
  • Tests

    • Added comprehensive test coverage for stream cancellation behavior and error reporting.

Review Change Stack


🔄 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/1258 **Author:** [@Xelvanis](https://github.com/Xelvanis) **Created:** 5/26/2026 **Status:** ✅ Merged **Merged:** 5/27/2026 **Merged by:** [@Xelvanis](https://github.com/Xelvanis) **Base:** `refactor` ← **Head:** `fix/log-llm-cancel-failures` --- ### 📝 Commits (2) - [`313a9bf`](https://github.com/Pasta-Devs/Marinara-Engine/commit/313a9bf37971efbea985ff01cc5367a0b8beadde) fix llm stream cancel visibility - [`ebaab1a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ebaab1abaf72c4e281648ee23603b30a6c8576f3) Merge remote-tracking branch 'origin/refactor' into fix/log-llm-cancel-failures ### 📊 Changes **6 files changed** (+389 additions, -13 deletions) <details> <summary>View changed files</summary> ➕ `src/shared/api/llm-api.test.ts` (+150 -0) 📝 `src/shared/api/llm-api.ts` (+6 -4) ➕ `src/shared/api/llm-cancel-logging.test.ts` (+52 -0) ➕ `src/shared/api/llm-cancel-logging.ts` (+71 -0) ➕ `src/shared/api/remote-runtime.test.ts` (+95 -0) 📝 `src/shared/api/remote-runtime.ts` (+15 -9) </details> ### 📄 Description ## Linked issue Closes #1257 ## Why this change LLM stream cancellation had two related failure paths: - Remote stream cancellation resolved the Remote Runtime URL again at abort time, so changing the setting while a stream was active could send cancel to the wrong runtime. - Local and remote cancel failures were swallowed, which made failed or misrouted cancellation hard to diagnose. ## What changed - Capture the remote runtime target once when a remote LLM stream starts. - Reuse that captured target for both the stream request and the cancel request. - Preserve best-effort cancellation semantics while logging sanitized cancel failure details. - Treat non-OK remote cancel responses as visible cancel failures for logging. - Add focused tests for local cancel failure/success, remote cancel failure/success, missing remote target, and target-drift behavior. ## Refactor impact Primary owner: Shared API wrapper and remote runtime routing. Impact areas reviewed: - `src/shared/api/llm-api.ts` - `src/shared/api/remote-runtime.ts` - LLM stream cancellation lifecycle - Remote runtime target resolution - Sanitized debug logging for failed cancellation Boundary notes: This stays in the shared API adapter layer. It does not change engine product rules, React feature UI, Rust command implementations, provider transport, storage, or the HTTP route contract. Pressure points touched: None. No `ModeSurface`, `GameSurface`, shared mode UI, Rust command registration, or import modules changed. ## Validation <!-- Checkboxes intentionally left unchecked for human verification per repo workflow. Commands actually run are listed below. --> - [x] `pnpm check` passes locally - [x] `pnpm typecheck` passes locally - [x] `pnpm build` passes locally - [x] `pnpm check:architecture` passes locally - [x] `pnpm check:docs` passes locally - [x] `cargo check --manifest-path src-tauri/Cargo.toml --workspace` passes locally - [ ] Rust clippy/tests were run for Rust behavior changes - [x] Browser or Tauri app manual verification completed - [ ] Playwright, screenshot, or recording evidence added for UI changes - [x] Remote runtime smoke checked when relevant ### Manual verification notes Commands run locally: - `pnpm test -- src/shared/api/llm-api.test.ts src/shared/api/remote-runtime.test.ts src/shared/api/llm-cancel-logging.test.ts` - `pnpm test` - `pnpm typecheck` - `pnpm check:architecture` - `pnpm build` - `git diff --check` `pnpm build` passed with existing Vite code-splitting/chunk-size warnings. Those warnings are tracked separately in the local chore list and are not introduced by this PR. ## Docs and release impact - [x] 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 No docs or changelog update was made. This repo branch does not have `CHANGELOG.md`, and the change is a shared API bugfix without user-facing copy changes. ## UI evidence N/A. No visible UI behavior changed. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added support for canceling LLM streams on remote runtimes. * **Bug Fixes** * Improved error handling and logging when stream cancellation fails. * Enhanced abort handling consistency across local and remote streaming scenarios. * **Tests** * Added comprehensive test coverage for stream cancellation behavior and error reporting. <!-- review_stack_entry_start --> [![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/Pasta-Devs/Marinara-Engine/pull/1258?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack) <!-- review_stack_entry_end --> <!-- 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:12:25 +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#5006
No description provided.