fix(oclite): add text streaming and session error handling (#142)#144
Merged
fix(oclite): add text streaming and session error handling (#142)#144
Conversation
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
- Add type safety: explicit string check for delta/text content - Add fallback: use part.text when delta undefined - Clear streaming state before error messages to prevent accumulation - Throw explicit error when SDK not ready instead of silent failure - Add error handling in handleSubmit for sendMessage failures
- Add isStreaming guard to prevent concurrent sendMessage calls - Prevents second message from clearing first message's streaming text - Improve error message context: "Failed to send message" instead of generic "Error" - Add isStreaming to useCallback dependencies for proper closure
- Fix LLM response not rendering (session.status idle was clearing text) - Filter user message echo from streaming area - Optimize plugin startup with background version checks - Clean up debug logging
d297a98 to
bed6289
Compare
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.
Fixes #142
Problem
oclite TUI was non-functional due to:
Solution
Initial Implementation (Commit 1: 2d9a593)
Text Streaming Handler (
useSDKEvents.ts)message.part.updatedevents withpart.type === "text"STREAM_TEXTaction for UI updatesSession Init Error Handling (
App.tsx)Race Condition Guard (
App.tsx)Adversarial Review Fixes (Commit 2: 2054f21)
Type Safety (
useSDKEvents.ts)typeof content === "string" && content.length > 0checkDelta Fallback (
useSDKEvents.ts)event.properties.delta ?? part.textfor both incremental and full updatesMemory Leak Prevention (
App.tsx)CLEAR_STREAMINGbefore error messagesExplicit Error Throwing (
useSDKEvents.ts+App.tsx)sendMessagethrows explicit error instead of silent returnhandleSubmitcatches and displays errors to userTesting
Manual Testing Required
~/bin/ocliteand send a messageFiles Changed
packages/opencode/src/cli/ink/hooks/useSDKEvents.tspackages/opencode/src/cli/ink/App.tsx