diff options
Diffstat (limited to '.rules')
| -rw-r--r-- | .rules/changelog/2026-03/24/11.md | 10 | ||||
| -rw-r--r-- | .rules/changelog/2026-03/24/12.md | 24 |
2 files changed, 34 insertions, 0 deletions
diff --git a/.rules/changelog/2026-03/24/11.md b/.rules/changelog/2026-03/24/11.md new file mode 100644 index 0000000..f7e2fef --- /dev/null +++ b/.rules/changelog/2026-03/24/11.md @@ -0,0 +1,10 @@ +# Changelog — 2026-03-24 #11 + +## Fix: Remove empty streaming bubble before approval prompts + +### Problem +When the AI called a tool requiring user approval (e.g., `delete_file`), an empty assistant streaming bubble with the 3-dots loading indicator appeared above the approval prompt. This was confusing because the approval prompt is the active UI element and the empty bubble served no purpose. + +### Changes + +- **`src/chat-view.ts`** — Updated the `onApprovalRequest` callback in `handleSend()` to remove the current streaming bubble from the DOM (and null out `currentBubble`) when the bubble is empty, before showing the approval prompt. The next loop iteration creates a fresh bubble for the model's subsequent response. diff --git a/.rules/changelog/2026-03/24/12.md b/.rules/changelog/2026-03/24/12.md new file mode 100644 index 0000000..14e0070 --- /dev/null +++ b/.rules/changelog/2026-03/24/12.md @@ -0,0 +1,24 @@ +# Changelog — 2026-03-24 #12 + +## Refactor: Deduplicate chat agent loop in ollama-client.ts + +### Problem +The three chat functions (`sendChatMessage`, `sendChatMessageStreamingMobile`, `sendChatMessageStreamingDesktop`) duplicated the system prompt injection, tool-calling agent loop, tool execution, and approval handling logic. Any change (e.g., updating the system prompt) required editing all three in lockstep. + +### Changes + +- **`src/ollama-client.ts`** + - Extracted `chatAgentLoop()` — a single shared function for system prompt injection, the iterative tool-calling loop, tool execution with approval, and message history management. + - Introduced `ChatRequestStrategy` type — a callback that performs a single HTTP request and returns `{ content, toolCalls }`. + - Extracted `TOOL_SYSTEM_PROMPT` constant — the system prompt now lives in one place. + - `sendChatMessage` now creates an inline strategy using `requestUrl` (non-streaming) and delegates to `chatAgentLoop`. + - `sendChatMessageStreaming` selects between `buildMobileStrategy` or `buildDesktopStreamingStrategy` based on platform, then delegates to `chatAgentLoop`. + - `buildMobileStrategy` — extracted from the former `sendChatMessageStreamingMobile`. + - `buildDesktopStreamingStrategy` — extracted from the former `sendChatMessageStreamingDesktop`. + +- **`src/chat-view.ts`** + - Updated `onApprovalRequest` callback to remove the empty streaming bubble before showing the approval prompt (from earlier fix). + +### Also included (from prior uncommitted fix) +- System prompt updated to inform the model that some tools require user approval and to ask why if the user declines. +- Empty streaming bubble is removed before showing approval prompts (delete file, etc.). |
