8000 feat: implement useTamboStreamStatus hook with generation vs prop streaming distinction by michaelmagan · Pull Request #581 · tambo-ai/tambo · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: implement useTamboStreamStatus hook with generation vs prop streaming distinction #581
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 1, 2025

Conversation

michaelmagan
Copy link
Collaborator

Add useTamboStreamStatus hook that exposes per-prop and global streaming status for tambo-ai components, properly distinguishing between generation streaming and component props streaming.

Key features:

  • Global StreamStatus interface with isPending, isStreaming, isSuccess, isError flags
  • Per-prop PropStatus interface for individual prop streaming states
  • Boolean lifecycle following specification (Init → First token → Mid-stream → Done → Error)
  • Derivation rules: isPending (no generation + all props), isStreaming (generation OR any prop), isSuccess (complete + all props), isError (any error)
  • SSR guard that throws during SSR/SSG with clear error message
  • Proper distinction between generation streaming (GenerationStage.STREAMING_RESPONSE) and prop content streaming
  • Comprehensive error handling and propagation
  • Strong TypeScript generics for type safety
  • Reset logic when generation restarts
  • Full unit test coverage for all lifecycle phases and error cases

Resolves #580

Generated with Claude Code

…eaming distinction

Add useTamboStreamStatus hook that exposes per-prop and global streaming status for tambo-ai components, properly distinguishing between generation streaming and component props streaming.

Key features:
- Global StreamStatus interface with isPending, isStreaming, isSuccess, isError flags
- Per-prop PropStatus interface for individual prop streaming states  
- Boolean lifecycle following specification (Init → First token → Mid-stream → Done → Error)
- Derivation rules: isPending (no generation + all props), isStreaming (generation OR any prop), isSuccess (complete + all props), isError (any error)
- SSR guard that throws during SSR/SSG with clear error message
- Proper distinction between generation streaming (GenerationStage.STREAMING_RESPONSE) and prop content streaming
- Comprehensive error handling and propagation
- Strong TypeScript generics for type safety
- Reset logic when generation restarts
- Full unit test coverage for all lifecycle phases and error cases

Resolves #580

Co-authored-by: michael magan <michaelmagan@users.noreply.github.com>
Copy link
vercel bot commented Jun 20, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
showcase ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 1, 2025 8:10pm

@michaelmagan
Copy link
Collaborator Author

@claude

assume that generationStage is at the thread level.

once the component is finished streaming these status should stay fixed for that component.

confirm 100% that is the case.

Copy link
Contributor
claude bot commented Jun 20, 2025

Claude finished @michaelmagan's task —— View job


Analyzing useTamboStreamStatus Hook Status Persistence

Verifying that component streaming status stays fixed after completion:

  • Read hook implementation to understand status management
  • Read test file to understand expected behavior
  • Analyze status persistence logic after streaming completion
  • Confirm whether status stays fixed for completed components

Analysis Results: ❌ Status Does NOT Stay Fixed

The Answer: I cannot confirm 100% that status stays fixed for completed components. The current implementation resets component status when the thread-level generationStage changes.

Key Issues Found:

  1. Reset Logic (use-tambo-stream-status.tsx:50-54):

    useEffect(() => {
      if (generationStage === GenerationStage.IDLE || generationStage === GenerationStage.CHOOSING_COMPONENT) {
        setPropTracking({});  // ❌ Resets ALL component tracking state
      }
    }, [generationStage]);
  2. Test Confirms Reset Behavior (use-tambo-stream-status.test.tsx:377-411):

    • Test explicitly verifies that successful props reset to pending when generation restarts
    • Expected behavior: isSuccess: trueisPending: true when gener 8000 ationStage changes

Current vs Expected Behavior:

Current Implementation:

  • ✅ Props correctly reach isSuccess: true when generationStage === COMPLETE
  • ❌ Props reset to isPending: true when thread moves to next generation (IDLE/CHOOSING_COMPONENT)

Your Requirement:

  • ✅ Props should reach isSuccess: true when streaming completes
  • ✅ Props should stay fixed at isSuccess: true for that component permanently

Recommendation:

The hook needs modification to preserve component-level status independently of thread-level generationStage changes. Consider tracking completion state per component/message ID rather than resetting on thread state changes.


@michaelmagan
Copy link
Collaborator Author

@claude
npm run prettier-check fails

fix by npm run format

Copy link
Contributor
claude bot commented Jun 20, 2025

Claude finished @michaelmagan's task —— View job


✅ Prettier Formatting Issues Fixed

Successfully applied prettier formatting fixes to resolve npm run prettier-check failures.

Prettier Config Applied:

  • 80 character line width
  • 2 space indentation
  • Double quotes
  • Trailing commas
  • Semicolons required

Completed Tasks:

  • Check current repo status and verify formatting issues
  • Fix formatting issues in use-tambo-stream-status.tsx
  • Fix formatting issues in use-tambo-stream-status.test.tsx
  • Fix formatting issues in other modified files
  • Commit formatting changes to PR branch

Fixed Issues:

  • Long lines broken at 80 characters
  • Proper trailing commas added
  • Consistent spacing and indentation
  • JSDoc comments properly formatted
  • Function parameters properly wrapped

Commit: 095b1c6 - Format code with prettier

The PR should now pass npm run prettier-check. All formatting issues have been resolved.


- Fix line length issues (80 character limit)
- Add proper trailing commas
- Improve JSDoc comment formatting
- Ensure consistent spacing and indentation
- Break long function parameters across lines

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: michael magan <michaelmagan@users.noreply.github.com>
…aming (#614)

Co-authored-by: michael magan <magan@tambo.co>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Alec Flett <flett@tambo.co>
@MichaelMilstead MichaelMilstead marked this pull request as ready for review July 1, 2025 20:11
@MichaelMilstead MichaelMilstead merged commit dae15ca into main Jul 1, 2025
7 checks passed
@MichaelMilstead MichaelMilstead deleted the claude/issue-580-20250620_034720 branch July 1, 2025 20:16
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.

useTamboStreamStatus — expose streaming readiness flags for tambo-ai components
2 participants
0