Skip to content

Fix prompt re-submission #392

Merged
tanzhenxin merged 2 commits into
QwenLM:mainfrom
Mingholy:fix/allow-query-abort
Aug 20, 2025
Merged

Fix prompt re-submission #392
tanzhenxin merged 2 commits into
QwenLM:mainfrom
Mingholy:fix/allow-query-abort

Conversation

@Mingholy

Copy link
Copy Markdown
Collaborator

TLDR

Fix issue where canceling requests prevents sending subsequent requests in some cases.

Dive Deeper

Cancelling a request before the first token received does not reset isSubmittingQueryRef, causing the subsequent prompts not to be sent to LLM.

isSubmittingQueryRef will intercept queries until the query is processed as expected or cancelled when streaming. A GeminiEventType.UserCancelled event will be emitted if the user aborts the request, ONLY IF the actual stream is generated, then isSubmittingQueryRef is reset, and the user is able to make subsequent queries.

In some cases where TTFT is long, isSubmittingQueryRef is not reset as expected, causing the issue described above.

Reviewer Test Plan

Before:

  1. Send a large prompt and press escape before the first token received;
  2. Input and resend, nothing is sent to the API.
    After:
    Cancel at will, re-send at will.

Testing Matrix

🍏 🪟 🐧
npm run
npx
Docker
Podman - -
Seatbelt - -

Linked issues / bugs

@Mingholy Mingholy requested a review from tanzhenxin August 20, 2025 08:15
@github-actions

Copy link
Copy Markdown
Contributor

📋 Review Summary

This PR addresses an issue where canceling requests prevents sending subsequent requests in some cases. The fix correctly resets the isSubmittingQueryRef flag when a request is cancelled, ensuring that users can send new prompts even after canceling a previous request before the first token is received.

🔍 General Feedback

The change is minimal and targeted, addressing a specific issue without introducing unnecessary complexity. The implementation correctly identifies that the isSubmittingQueryRef flag needs to be reset when a user cancels a request, which prevents the UI from getting into a stuck state.

🎯 Specific Feedback

🟢 Medium

  • File: packages/cli/src/ui/hooks/useGeminiStream.ts:192 - While the fix is correct, it would be beneficial to add a comment explaining why this line is needed. This will help future developers understand the purpose of this specific line, especially given that the isSubmittingQueryRef is also reset in other parts of the code (e.g., in the finally block of submitQuery).

✅ Highlights

  • The fix is minimal and directly addresses the reported issue
  • Good test plan provided in the PR description with clear before/after scenarios
  • The change follows the existing code patterns and conventions

@tanzhenxin

Copy link
Copy Markdown
Collaborator

lgtm!

@tanzhenxin tanzhenxin merged commit a7c8c4c into QwenLM:main Aug 20, 2025
34 of 37 checks passed
DragonnZhang pushed a commit that referenced this pull request Apr 30, 2026
# v0.7.4 — Custom Endpoints & Session Branching Overhaul

---

## Features

- **Custom endpoint support** — connect any OpenAI-compatible provider via Pi SDK's `registerProvider`, with protocol selector, base URL input, and model registration. Fixes [#329](craft-ai-agents/craft-agents-oss#329) (479d6d25)

## Improvements

- **Custom endpoint UX** — protocol selector now appears before the base URL input, and edit-state persistence works reliably across setup routing (aac754d7, d94d36bd, 40b53170)
- **CustomEndpointApi cleanup** — deduplicated type definition, extracted `InitMessage`, and fixed model registration replace bug (8f770f62)

## Bug Fixes

- **Session branching overhaul** — completely reworked the branch/fork flow to eliminate preflight failures, CWD mismatches, and stuck sessions. Branches now fork on first user message instead of during preflight, conversation is properly trimmed at the branch point, and `spawn_session` names appear correctly in the sidebar. Fixes [#392](craft-ai-agents/craft-agents-oss#392) (a9358817, 1cb1d11c, d337e288, e54f58f0, 0d40bb7e, 7bd83366, 36f46f88, e8db3e2a, and 10 more commits)
- **Branch cutoff reliability** — Pi and Claude branch cutoffs now use sidecar turn anchors and lineage guards, with proper fallback when UUIDs are missing (ebf0fba7, 20f1dc35, 82b19359, 4bfac3a0)
- **Windows: duplicate messages on branch** — Windows `fs.watch()` fires aggressively for atomic writes, causing the ConfigWatcher to re-broadcast session metadata and duplicate messages. Fixed with ID-based dedup in `appendMessage()`, self-triggered event suppression via signature comparison, and increased debounce to 300ms on Windows (65c959f8)
- **Windows: empty branch messages** — branch messages were saved with hardcoded source session paths instead of portable `{{SESSION_PATH}}` tokens, causing path resolution failures on Windows. Fixed by re-tokenizing paths from source → branch directory during message copy (1ab2c9b8)
- **Model switching mid-session** — `ClaudeAgent.setModel` now correctly calls `super.setModel` to update the internal model reference, fixing cases where model changes didn't take effect. Partially addresses [#390](craft-ai-agents/craft-agents-oss#390) (abd1fa4a)
- **JSON file link crash** — clicking JSON file links for non-existent files no longer crashes the app (bfcb875d)
- **Empty text block cache_control** — stripped `cache_control` from empty text blocks in Anthropic API requests, preventing validation errors (4ad37ff3)
- **Automation send-timeout** — increased send-timeout for the daily discussion points workflow to prevent premature timeouts (669c83cb)

---
xaelistic pushed a commit to xaelistic/qwen-code that referenced this pull request Jun 7, 2026
xaelistic pushed a commit to xaelistic/qwen-code that referenced this pull request Jun 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants