Registry Mirror
Skip to content

Conversation

@randomm

@randomm randomm commented Feb 5, 2026

Copy link
Copy Markdown
Owner

Fixes #142

Problem

oclite TUI was non-functional due to:

  1. Missing text streaming event handler
  2. Session init errors swallowed silently
  3. Race condition when submitting messages before session ready
  4. Silent failures in event handling

Solution

Initial Implementation (Commit 1: 2d9a593)

  1. Text Streaming Handler (useSDKEvents.ts)

    • Added handler for message.part.updated events with part.type === "text"
    • Dispatches STREAM_TEXT action for UI updates
  2. Session Init Error Handling (App.tsx)

    • Wrapped session initialization in try/catch
    • Displays user-visible error messages
  3. Race Condition Guard (App.tsx)

    • Checks session.id exists before sending messages
    • Shows "Waiting for session to initialize..." message

Adversarial Review Fixes (Commit 2: 2054f2110)

  1. Type Safety (useSDKEvents.ts)

    • Added explicit typeof content === "string" && content.length > 0 check
    • Prevents runtime errors from unexpected types
  2. Delta Fallback (useSDKEvents.ts)

    • Uses event.properties.delta ?? part.text for both incremental and full updates
    • Handles cases where SDK doesn't send deltas
  3. Memory Leak Prevention (App.tsx)

    • Calls CLEAR_STREAMING before error messages
    • Prevents error accumulation in streaming state
  4. Explicit Error Throwing (useSDKEvents.ts + App.tsx)

    • sendMessage throws explicit error instead of silent return
    • handleSubmit catches and displays errors to user

Testing

  • ✅ Type checking: All packages pass
  • ✅ Unit tests: 1298 pass, 0 fail
  • ✅ Binary build: Successful
  • ✅ CI: Standards and tests passing

Manual Testing Required

  • Run ~/bin/oclite and send a message
  • Verify response text streams to the UI
  • Verify errors display properly

Files Changed

  • packages/opencode/src/cli/ink/hooks/useSDKEvents.ts
  • packages/opencode/src/cli/ink/App.tsx

@github-actions

github-actions Bot commented Feb 5, 2026

Copy link
Copy Markdown

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant