feat(PromptInput): restore user message to textarea after provider errors#5629
Draft
janet-e4 wants to merge 1 commit into
Draft
feat(PromptInput): restore user message to textarea after provider errors#5629janet-e4 wants to merge 1 commit into
janet-e4 wants to merge 1 commit into
Conversation
…rors
When the LLM backend returns an abort/error response (e.g. "Ollama service
could not be reached"), the user's typed message was silently lost because
clearPromptInputDraft() and setMessageEmit("") fire before the API call
completes. On error there was no recovery path.
This adds savePromptInputDraft() to usePromptInputStorage and hooks it into
the fetchReply error path in ChatContainer: when the stream returns
type:"abort", the original message is restored to the textarea and written
back to localStorage so the user can retry without re-typing.
The existing draft-autosave flow (usePromptInputStorage hook, debounced
writes, page-refresh restore) is unchanged.
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
janet-e4
added a commit
to janet-e4/anything-llm
that referenced
this pull request
May 15, 2026
Comprehensive documentation pass — every fork doc verified against the live deployment and corrected: - README: reframed as an independent project (tracks upstream only for security, not features); fixed stale "localStorage drafts" claim, the embedding model name, and the divergence baseline. - DEPLOYMENT: removed non-existent SIG_KEY/SIG_SALT env vars; corrected GENERIC_OPEN_AI_MAX_TOKENS (4096, not 8192); added the missing Qdrant corpus setup and the explicit 5-bind-mount table. - SECURITY: corrected the telemetry mechanism (forced DISABLE_TELEMETRY env flag, not a code no-op); added the upstream security-sync policy. - UPGRADING (both files): fixed the wrong "native is 384-dim" claim (it is 768-dim) and removed references to a non-existent collection and agent skill; split fork-repo (rebase mechanics) vs deployment runbook. - Added docs/PROVENANCE.md: full origin + sources record — every fork commit traced to its reason, the NAS voice-spec source, PR Mintplex-Labs#5629, the Qdrant corpus origin, retained upstream components, MIT license. - Added .upstream-sync baseline marker (anchors the security-sync scan). - Corrected the Z-Health corpus count (41,048 = 41,041 + 7) and the verified-retrieval example across the docs. The upstream-security-sync process is documented as a Claude Code skill + agent kept at ~/Desktop/anythingllm-fork-maintenance/ (outside the repo). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When the LLM backend returns an error response (e.g. the provider is unreachable), the user's typed message is silently lost. This happens because:
clearPromptInputDraft()fires inhandleSubmitbefore the API callsetMessageEmit("")clears the textarea immediately afterThe user sees "Could not respond to message" with an empty input box and must re-type their entire message to retry.
Solution
Added
savePromptInputDraft(storageKey, value)tousePromptInputStorage— a counterpart to the existingclearPromptInputDraft. InChatContainer, thechatHandlerpassed tomultiplexStreamnow tracks whether the stream ended withtype: "abort". If it did, aftermultiplexStreamresolves:setMessageEmit(promptMessage.userMessage)restores the text to the textareasavePromptInputDraft(storageKey, message)writes it back to localStorageThe user's message reappears in the input ready to retry — no re-typing needed.
Changes
frontend/src/hooks/usePromptInputStorage.js— add exportedsavePromptInputDraft(storageKey, value)(mirrors existingclearPromptInputDraft, 15 lines)frontend/src/components/WorkspaceChat/ChatContainer/index.jsx— importsavePromptInputDraft; wrapchatHandlerinfetchReplyto detecttype: "abort"; restore message after stream resolves on error (14 lines)No new dependencies. No changes to existing autosave/restore behavior (page-refresh drafts, debounced writes, thread/workspace scoping).
Test steps
Affected providers
Provider-agnostic — triggers on any
type: "abort"stream response regardless of which LLM backend is configured.