8000 chore(cli): update components UI and add update command by akhileshrangani4 · Pull Request #167 · tambo-ai/tambo · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

chore(cli): update components UI and add update command #167

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 3 commits into from
Mar 22, 2025

Conversation

akhileshrangani4
Copy link
Contributor
@akhileshrangani4 akhileshrangani4 commented Mar 20, 2025
  • Renamed chat-thread to thread-content and chat-input to message-input.
  • Added update command to CLI for updating existing components.
  • Enhanced handleAuthentication to prompt for API key replacement if it already exists.
  • Added choice for users to choose from components when using full-send command

Summary by CodeRabbit

  • New Features

    • Introduced a new CLI command for updating components.
    • Simplified commands for project initialization and component management.
    • Added new components: MessageInput, ThreadContent, MessageSuggestions, ThreadHistory, and enhanced ControlBar functionality.
  • Bug Fixes

    • Improved error handling and user prompts during component updates and initialization.
  • Documentation

    • Updated command usage and examples for project initialization and component management.
  • Refactor

    • Renamed messaging interface elements for improved clarity and consistency.
    • Enhanced installation feedback with clearer log messages and dynamic prompts for component selection.
    • Updated dependencies in configuration files to reflect new component names.

- Renamed `chat-thread` to `thread-content` and `chat-input` to `message-input`.
- Added `update` command to CLI for updating existing components.
- Enhanced `handleAuthentication` to prompt for API key replacement if it already exists.
- Added choice for users to choose from components when using `full-send` command
Copy link
coderabbitai bot commented Mar 20, 2025

Walkthrough

The changes update the CLI commands and documentation by simplifying initialization and adding an update command. The component names have been refactored in both CLI logic and registry files—from “chat-thread” and “chat-input” to “thread-content” and “message-input.” Updates also include modifications to configuration files, forced update logic in component installation, API key management, and related type declarations. These modifications affect command usage, file handling, and exported entities across the codebase.

Changes

File(s) Change Summary
cli/README.md, cli/src/cli.ts, cli/src/commands/init.ts, cli/src/commands/update.ts Updated CLI commands and documentation: simplified full setup command, renamed add command, added update command with confirmation, and modified provider setup and API key handling.
cli/src/commands/add/component.ts, cli/src/commands/add/types.ts Modified component installation: added forceUpdate flag to copy files even if they already exist and updated logging to reflect installation versus update.
cli/src/registry/{chat-input,chat-thread,control-bar,message-input,message-thread-collapsible,message-thread-full,message-thread-panel,thread-content} and cli/src/types/components.d.ts Renamed exported components and configuration: replaced chat-thread/chat-input with thread-content/message-input across components, config files, and type definitions.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant CLI as CLI Application
    participant Upd as UpdateHandler
    participant FS as File System

    U->>CLI: Execute "npx tambo update message [--legacy-peer-deps]"
    CLI->>Upd: Check component existence in registry
    Upd-->>CLI: Return status (exists or not)
    CLI->>FS: Verify local component file existence
    FS-->>CLI: Confirm file availability
    CLI->>U: Prompt for update confirmation
    U->>CLI: Confirm update action
    CLI->>Upd: Call reinstall with forceUpdate enabled
    Upd-->>CLI: Return success or error
    CLI->>U: Log completion message
Loading

Possibly related PRs

  • chore: show renderedComponent in Message component #160: The changes in the main PR are related to the updates in the Message component's props and functionality, which align with the modifications made in the retrieved PR that also enhances the Message component by adding a new message prop.

Poem

I'm a little rabbit, hopping through the code,
Skipping over changes, lightening up the load.
Commands now updated, components renamed in flight,
Code paths refreshed—everything's looking right.
With ASCII hops and a curious, merry cheer,
I celebrate these changes—oh, so dear!
🐰 Happy coding in our new twilight!

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the chore label Mar 20, 2025
Copy link
@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
cli/src/commands/update.ts (1)

33-44: Verify component existence in project.

The implementation correctly checks if the component exists in the local project before attempting to update it.

However, consider using a file existence check that's more flexible with file extensions (.tsx, .jsx, .ts, .js) as components might have different extensions:

-const componentPath = path.join(componentDir, `${componentName}.tsx`);
+// Check for any of the common extensions
+const possibleExtensions = ['.tsx', '.jsx', '.ts', '.js'];
+const componentExists = possibleExtensions.some(ext => 
+  fs.existsSync(path.join(componentDir, `${componentName}${ext}`))
+);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3f66819 and 83c1501.

📒 Files selected for processing (23)
  • cli/README.md (5 hunks)
  • cli/src/cli.ts (4 hunks)
  • cli/src/commands/add/component.ts (2 hunks)
  • cli/src/commands/add/types.ts (1 hunks)
  • cli/src/commands/init.ts (3 hunks)
  • cli/src/commands/update.ts (1 hunks)
  • cli/src/registry/chat-input/index.tsx (0 hunks)
  • cli/src/registry/chat-thread/index.tsx (0 hunks)
  • cli/src/registry/control-bar/config.json (1 hunks)
  • cli/src/registry/control-bar/control-bar.tsx (3 hunks)
  • cli/src/registry/message-input/config.json (1 hunks)
  • cli/src/registry/message-input/index.tsx (1 hunks)
  • cli/src/registry/message-input/message-input.tsx (5 hunks)
  • cli/src/registry/message-thread-collapsible/config.json (1 hunks)
  • cli/src/registry/message-thread-collapsible/message-thread-collapsible.tsx (2 hunks)
  • cli/src/registry/message-thread-full/config.json (1 hunks)
  • cli/src/registry/message-thread-full/message-thread-full.tsx (2 hunks)
  • cli/src/registry/message-thread-panel/config.json (1 hunks)
  • cli/src/registry/message-thread-panel/message-thread-panel.tsx (3 hunks)
  • cli/src/registry/thread-content/config.json (1 hunks)
  • cli/src/registry/thread-content/index.tsx (1 hunks)
  • cli/src/registry/thread-content/thread-content.tsx (3 hunks)
  • cli/src/types/components.d.ts (2 hunks)
💤 Files with no reviewable changes (2)
  • cli/src/registry/chat-thread/index.tsx
  • cli/src/registry/chat-input/index.tsx
🧰 Additional context used
🧬 Code Definitions (8)
cli/src/registry/message-thread-collapsible/message-thread-collapsible.tsx (1)
cli/src/types/components.d.ts (2) (2)
  • ThreadContent (34-36)
  • MessageInput (45-47)
cli/src/registry/message-thread-full/message-thread-full.tsx (3)
cli/src/types/components.d.ts (2) (2)
  • ThreadContent (34-36)
  • MessageInput (45-47)
cli/src/registry/thread-content/thread-content.tsx (1) (1)
  • ThreadContent (94-94)
cli/src/registry/message-input/message-input.tsx (1) (1)
  • MessageInput (100-100)
cli/src/registry/control-bar/control-bar.tsx (1)
cli/src/types/components.d.ts (2) (2)
  • MessageInput (45-47)
  • ThreadContent (34-36)
cli/src/commands/update.ts (1)
cli/src/commands/add/component.ts (1) (1)
  • installSingleComponent (13-120)
cli/src/types/components.d.ts (2)
cli/src/registry/thread-content/thread-content.tsx (2) (2)
  • ThreadContentProps (32-35)
  • ThreadContent (94-94)
cli/src/registry/message-input/message-input.tsx (2) (2)
  • MessageInputProps (32-36)
  • MessageInput (100-100)
cli/src/cli.ts (1)
cli/src/commands/update.ts (1) (1)
  • handleUpdateComponent (18-80)
cli/src/registry/thread-content/thread-content.tsx (2)
cli/src/registry/thread-content/index.tsx (2) (2)
  • ThreadContentProps (1-1)
  • ThreadContent (1-1)
cli/src/types/components.d.ts (2) (2)
  • ThreadContentProps (30-33)
  • ThreadContent (34-36)
cli/src/registry/message-thread-panel/message-thread-panel.tsx (1)
cli/src/types/components.d.ts (2) (2)
  • ThreadContent (34-36)
  • MessageInput (45-47)
🔇 Additional comments (54)
cli/src/types/components.d.ts (1)

9-10: Type declarations are consistently updated.

The type declarations have been updated to reflect the component renames from "ChatThread" to "ThreadContent" and "ChatInput" to "MessageInput", including JSDoc comments, module paths, interface names, and component references. This keeps the type declarations in sync with the implementation changes.

Also applies to: 29-30, 34-35, 39-40, 45-46

cli/src/registry/thread-content/thread-content.tsx (1)

10-10: Consistent renaming from ChatThread to ThreadContent

The changes effectively rename all references from ChatThread to ThreadContent throughout the file, including variables, interfaces, component names, and JSDoc documentation. The renaming improves clarity by better describing the component's purpose as content of a thread rather than a chat thread.

Also applies to: 29-29, 32-34, 37-37, 45-45, 92-92, 94-94

cli/src/registry/message-input/index.tsx (1)

1-1: Clean export of renamed MessageInput component

This new export file correctly exports the renamed MessageInput component and its props type, following the component renaming pattern established in this PR. This maintains a clean public API for consuming components.

cli/src/registry/thread-content/index.tsx (1)

1-1: Clean export of renamed ThreadContent component

This new export file correctly exports the renamed ThreadContent component and its props type, following the component renaming pattern established in this PR. This maintains a clean public API for consuming components.

cli/src/commands/add/types.ts (1)

15-15: Addition of forceUpdate option supports the new update command

The new optional forceUpdate boolean property is a good addition to the InstallComponentOptions interface. This enables the implementation of the update command functionality by allowing the CLI to overwrite existing component files when needed.

cli/src/registry/message-thread-panel/config.json (1)

5-5: Component dependencies updated correctly.

The "requires" field has been updated to reference the renamed components "thread-content" and "message-input" instead of the previous "chat-thread" and "chat-input", which aligns with the component renaming initiative in this PR.

cli/src/registry/control-bar/config.json (1)

5-5: Component dependencies updated correctly.

The "requires" field has been updated to reference the renamed components "thread-content" and "message-input" instead of the previous "chat-thread" and "chat-input", maintaining consistency with the component renaming across the application.

cli/src/registry/message-thread-collapsible/config.json (1)

5-5: Component dependencies updated correctly.

The "requires" field has been updated to reference the renamed components "thread-content" and "message-input" instead of the previous "chat-thread" and "chat-input", consistent with the component renaming pattern throughout the codebase.

cli/src/registry/message-thread-full/config.json (1)

5-5: Component dependencies updated correctly.

The "requires" field has been updated to reference the renamed components "thread-content" and "message-input" instead of the previous "chat-thread" and "chat-input", maintaining consistency with the overall component renaming strategy.

cli/src/registry/message-thread-collapsible/message-thread-collapsible.tsx (3)

6-7: Updated imports to use renamed components.

The imports have been correctly updated to use the renamed components: ThreadContent instead of ChatThread and MessageInput instead of ChatInput, which aligns with the component renaming initiative in this PR.


56-56: Updated to use ThreadContent component.

The component usage has been correctly updated to use <ThreadContent /> instead of the previous <ChatThread />.


59-59: Updated to use MessageInput component.

The component usage has been correctly updated to use <MessageInput contextKey={contextKey} /> instead of the previous <ChatInput contextKey={contextKey} />, and the contextKey prop is properly passed to maintain functionality.

cli/src/registry/message-thread-full/message-thread-full.tsx (3)

6-7: Component import names updated correctly.

The imports have been updated from ChatThread to ThreadContent and from ChatInput to MessageInput, aligning with the component renaming described in the PR objectives.


58-58: Component usage updated correctly.

The ChatThread component has been properly replaced with ThreadContent while maintaining the same props.


62-65: Component usage updated correctly.

The ChatInput component has been properly replaced with MessageInput while maintaining the same props structure and functionality.

cli/src/commands/add/component.ts (2)

105-105: Added support for forced component updates.

The condition has been enhanced to also copy files when the forceUpdate flag is true, which is necessary for implementing the update command mentioned in the PR objectives.


116-118: Improved user feedback for component operations.

The logging statement now differentiates between "Updated" and "Installed" based on the forceUpdate flag, providing clearer feedback to users about the operation performed.

cli/src/registry/message-thread-panel/message-thread-panel.tsx (3)

5-6: Component import names updated correctly.

The imports have been updated from ChatThread to ThreadContent and from ChatInput to MessageInput, aligning with the component renaming described in the PR objectives.


39-40: Component usage and type annotation updated correctly.

The ChatThread component has been properly replaced with ThreadContent, and the ref callback parameter is now explicitly typed as HTMLDivElement, which aligns with the component's type definition in components.d.ts.


52-52: Component usage updated correctly.

The ChatInput component has been properly replaced with MessageInput while maintaining the same contextKey prop.

cli/src/registry/control-bar/control-bar.tsx (3)

6-7: Component import names updated correctly.

The imports have been updated from ChatThread to ThreadContent and from ChatInput to MessageInput, aligning with the component renaming described in the PR objectives.


57-60: Component usage updated correctly.

The ChatInput component has been properly replaced with MessageInput while maintaining the same props structure and functionality.


68-68: Component usage updated correctly.

The ChatThread component has been properly replaced with ThreadContent.

cli/src/cli.ts (4)

7-7: Correctly adds import for the new update command handler.

The import statement for the update command handler is properly added, maintaining consistency with other command imports.


23-23: Clear documentation for the new update command.

The update command is properly documented in the CLI help text with a clear description of its purpose.


33-35: Examples added for the update command.

Usage examples for the update command are properly documented, including the version with the --legacy-peer-deps flag.


82-95: Well-implemented update command handler.

The implementation of the update command handler follows the same pattern as the existing add command, with proper error handling and user feedback.

cli/src/commands/init.ts (7)

62-63: Improved .env.local file handling.

API key is now properly appended to the newly created .env.local file.


67-67: Enhanced regex pattern for API key detection.

The regex pattern now includes the global and multiline flags (/gm), which is appropriate for correctly identifying the API key in various file formats.


71-90: Improved user experience with confirmation prompt.

A confirmation prompt has been added when an existing API key is detected, giving users the option to keep their existing key. This is a good user experience improvement.


95-99: Logical flow improvement for API key handling.

The code now clearly distinguishes between replacing an existing key and appending a new one, making the logic easier to follow.


132-150: Enhanced component selection with descriptive options.

The previously static list has been replaced with a more user-friendly component selection mechanism that includes descriptions, helping users make more informed choices.


152-165: Interactive component selection implementation.

The implementation of the interactive component selection using inquirer is well-structured, with proper validation to ensure at least one component is selected.


168-168: Updated installation flow for dynamically selected components.

The code now properly iterates through the user-selected components rather than using a predefined list.

cli/src/commands/update.ts (6)

8-11: Clear interface definition for update options.

The UpdateComponentOptions interface is well-defined and consistent with the options used in other commands.


13-21: Well-documented function signature.

The function signature includes clear JSDoc comments explaining the purpose and parameters.


24-31: Appropriate validation for component existence in registry.

The code properly checks if the component exists in the registry before proceeding, providing a clear error message if not found.


46-61: Good user experience with confirmation prompt.

The implementation properly prompts the user for confirmation before overriding an existing component, with a clear warning message and a default of "false" for safety.


63-73: Effective use of existing functionality.

The implementation reuses the existing installSingleComponent function with the forceUpdate option, which is an efficient approach. The success message is clear and informative.


74-79: Proper error handling.

The error handling is comprehensive and includes a clear error message with the process exit on failure.

cli/README.md (7)

10-10: Simplified command for full-send initialization.

The command has been simplified from npx tambo init --full-send to npx tambo full-send, improving user experience.


36-36: Updated documentation for full-send command.

Documentation consistently reflects the simplified command.


47-48: Updated component name in example.

The example now uses the updated component name convention.


50-56: Documentation for the new update command.

Clear documentation has been added for the new update command, including an example of its usage.


65-66: Updated component names in documentation.

Component names have been updated from chat-thread to thread-content and chat-input to message-input to reflect the changes in the codebase.


112-112: Updated import path for TamboProvider.

The import statement has been updated from tambo-ai/react to @tambo-ai/react, reflecting changes in the package structure.


116-116: Simplified TamboProvider usage.

The TamboProvider component usage has been simplified by removing the tamboUrl prop.

cli/src/registry/message-input/config.json (1)

2-2: Component naming update looks good!

The changes correctly implement the renaming from "chat-input" to "message-input" as specified in the PR objectives. Both the component name and file references have been consistently updated in the config file.

Also applies to: 8-9

cli/src/registry/thread-content/config.json (1)

2-2: Consistent renaming implemented correctly

The component has been properly renamed from "chat-thread" to "thread-content" throughout the configuration file, aligning with the PR objectives. All file references have been updated accordingly.

Also applies to: 8-9

cli/src/registry/message-input/message-input.tsx (5)

9-9: Variable renamed to match component name

The styling variant variable has been correctly renamed from chatInputVariants to messageInputVariants to maintain consistency with the component renaming.


28-29: Interface and JSDoc updates are consistent

The interface has been properly renamed from ChatInputProps to MessageInputProps, and all related JSDoc comments have been updated to reflect the new naming convention.

Also applies to: 32-35


38-39: Component renaming complete

The component has been consistently renamed from ChatInput to MessageInput throughout the file, including the component declaration, display name, and export statement.

Also applies to: 98-100


67-67: Updated className assignment

The className assignment now correctly uses the renamed messageInputVariants function, maintaining consistency with the component renaming.


50-53:

❓ Verification inconclusive

Verify submit function parameter format

The submit function call has been modified to take an object with contextKey and streamResponse properties rather than direct parameters. Please ensure this matches the expected signature of the submit function from useTamboThreadInput to avoid runtime errors.


🏁 Script executed:

#!/bin/bash
# Check how the submit function is defined in useTamboThreadInput
# Look for the implementation in node_modules or imported files

echo "Searching for useTamboThreadInput implementation..."
rg -A 10 "useTamboThreadInput" --type ts --type tsx

Length of output: 192


I'm not seeing the expected output from the first script due to a filetype issue with "tsx". To get a proper verification of the submit function signature in the implementation of useTamboThreadInput, let's run a refined search that includes both .ts and .tsx files using ripgrep's built-in TypeScript support.

Try running the following shell script:

This should help us locate the implementation where the submit function is defined so we can check its parameter format. Once you’ve run this and confirmed that the submit function indeed expects an object with contextKey and streamResponse properties, we can update the review comment accordingly.


🏁 Script executed:

#!/bin/bash
echo "Searching for the definition of useTamboThreadInput (and its submit function signature) in TypeScript files..."
rg -A 20 "export function useTamboThreadInput" -t typescript

Length of output: 450


Action: Manually Verify the submit Function Signature

  • The updated call in cli/src/registry/message-input/message-input.tsx passes an object containing contextKey and streamResponse: true to submit.
  • Automated attempts to locate and inspect the implementation of the useTamboThreadInput hook (which provides the submit function) did not yield conclusive output.
  • Please manually verify that the submit function’s signature indeed expects an object with contextKey and streamResponse properties to avoid any potential runtime issues.

Copy link
@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (14)
cli/src/registry/message/config.json (1)

3-9: Consider pinning versions for reproducible builds.

Currently, the dependencies listed here do not include explicit version pins. This can lead to potential version drift and unexpected breaking changes. If stability is a priority, consider specifying exact versions or version ranges.

cli/src/registry/thread-history/thread-history.tsx (3)

39-47: Implement createThread logic or track TODO.

The handleNewThread function includes a TODO comment for creating a new thread. Currently, it just switches to a non-existent thread ID. This may lead to confusion or errors at runtime if not addressed soon.

Do you want help drafting a proper createThread implementation or opening a follow-up issue?


57-61: Evaluate potential collision with other keyboard shortcuts.

Alt+Shift+N might clash with native browser or OS shortcuts in certain locales. Consider letting users configure this binding or verifying it doesn't collide with other shortcuts.


126-147: Graceful fallback for empty threads.

The loading/error/empty states are handled well. As a future improvement, consider displaying a quick prompt or CTA for creating a new thread when none are found, so the user can see next steps more confidently.

cli/src/registry/message-input/message-input.tsx (1)

39-82: Robust error handling.

The try/catch block correctly resets the input on errors, but consider introducing more user-friendly error states, like re-trying logic or specialized error messaging for known failure cases.

cli/src/types/utils.d.ts (4)

60-95: Clarify the onSelect event type for better keyboard handling.
While defining onSelect as (event: React.MouseEvent) => void covers mouse interactions, it may inadvertently omit keyboard-based triggers. Consider broadening event type support to ensure accessibility and accurate typing (e.g., (event: React.MouseEvent | React.KeyboardEvent) => void).


97-107: Fine-tune the react-markdown component type definitions.
Currently, components is typed as Record<string, React.ComponentType<any>>. Providing more specific props for each custom component would enhance type safety and help prevent runtime errors.


109-122: Consider refining react-syntax-highlighter props.
The style and PreTag props are defined broadly, which may be sufficient, but specifying a narrower type (e.g., using known syntax-highlighter style objects) can improve clarity and type safety.


124-127: Replace any with more specific style definitions.
For the oneLight and vscDarkPlus exports, consider providing a structured type or constant interface to leverage TypeScript’s capabilities for auto-completion and error checking.

cli/src/registry/message-thread-collapsible/message-thread-collapsible.tsx (4)

4-4: Ensure consistent styling imports.

The import of useRef and useEffect from "react" is appropriate, but confirm all relevant hooks (e.g., useState, useCallback) are consistently imported from the same source for clarity.


30-41: Refine OS detection logic.

Using navigator.platform can be imprecise, as some browsers may not set it or could misreport. For more robust OS detection, consider an alternative approach (e.g., user agent checks or a library). If you only need the “mac vs. non-mac” toggle, this may be acceptable for now.


42-55: Shortcut handling is helpful but consider allowing user customization.

Toggling the collapsible via ⌘K / Ctrl+K is convenient. As a potential improvement, consider a user-configurable shortcut or a settings page so that advanced users can override the default key binding if needed.


130-139: Consider rearranging or abstracting child UI blocks.

Including ThreadContent, MessageSuggestions, and MessageInput in a single flex container is straightforward, but consider extracting them into well-defined subcomponents for better maintainability, especially if this logic grows. This helps avoid monolithic components.

cli/src/registry/message-suggestions.tsx/message-suggestions.tsx (1)

24-29: Consider using a more robust OS detection method.

While the current OS detection works, consider using a more comprehensive approach or a library like detect-browser for more reliable platform detection.

-  React.useEffect(() => {
-    const isMacOS =
-      typeof navigator !== "undefined" &&
-      navigator.platform.toUpperCase().includes("MAC");
-    setIsMac(isMacOS);
-  }, []);
+  React.useEffect(() => {
+    // navigator.platform is deprecated
+    const isMacOS = typeof navigator !== "undefined" && (
+      navigator.userAgent.includes("Mac") || 
+      (navigator.platform && navigator.platform.toUpperCase().includes("MAC"))
+    );
+    setIsMac(isMacOS);
+  }, []);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a8341fc and b5ba758.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (25)
  • cli/src/registry/control-bar/config.json (1 hunks)
  • cli/src/registry/control-bar/control-bar.tsx (4 hunks)
  • cli/src/registry/input-fields/input-fields.tsx (1 hunks)
  • cli/src/registry/message-input/config.json (1 hunks)
  • cli/src/registry/message-input/message-input.tsx (1 hunks)
  • cli/src/registry/message-suggestions.tsx/config.json (1 hunks)
  • cli/src/registry/message-suggestions.tsx/index.tsx (1 hunks)
  • cli/src/registry/message-suggestions.tsx/message-suggestions.tsx (1 hunks)
  • cli/src/registry/message-thread-collapsible/config.json (1 hunks)
  • cli/src/registry/message-thread-collapsible/message-thread-collapsible.tsx (3 hunks)
  • cli/src/registry/message-thread-full/config.json (1 hunks)
  • cli/src/registry/message-thread-full/message-thread-full.tsx (2 hunks)
  • cli/src/registry/message-thread-panel/config.json (1 hunks)
  • cli/src/registry/message-thread-panel/message-thread-panel.tsx (2 hunks)
  • cli/src/registry/message/config.json (1 hunks)
  • cli/src/registry/message/markdownComponents.tsx (1 hunks)
  • cli/src/registry/message/message.tsx (3 hunks)
  • cli/src/registry/thread-content/config.json (1 hunks)
  • cli/src/registry/thread-content/thread-content.tsx (5 hunks)
  • cli/src/registry/thread-history/config.json (1 hunks)
  • cli/src/registry/thread-history/index.tsx (1 hunks)
  • cli/src/registry/thread-history/thread-history.tsx (1 hunks)
  • cli/src/registry/thread-list/thread-list.tsx (1 hunks)
  • cli/src/types/components.d.ts (2 hunks)
  • cli/src/types/utils.d.ts (1 hunks)
✅ Files skipped from review due to trivial changes (5)
  • cli/src/registry/thread-history/index.tsx
  • cli/src/registry/thread-history/config.json
  • cli/src/registry/thread-list/thread-list.tsx
  • cli/src/registry/input-fields/input-fields.tsx
  • cli/src/registry/message-suggestions.tsx/config.json
🚧 Files skipped from review as they are similar to previous changes (4)
  • cli/src/registry/message-thread-panel/config.json
  • cli/src/registry/message-thread-collapsible/config.json
  • cli/src/registry/control-bar/control-bar.tsx
  • cli/src/registry/control-bar/config.json
🧰 Additional context used
🧬 Code Definitions (7)
cli/src/registry/message/markdownComponents.tsx (2)
cli/src/types/components.d.ts (1) (1)
  • createMarkdownComponents (62-64)
cli/src/types/utils.d.ts (4) (4)
  • Components (105-105)
  • SyntaxHighlighter (121-121)
  • oneLight (125-125)
  • vscDarkPlus (126-126)
cli/src/registry/message/message.tsx (2)
cli/src/types/components.d.ts (3) (3)
  • Message (25-27)
  • MessageProps (18-24)
  • createMarkdownComponents (62-64)
cli/src/registry/message/markdownComponents.tsx (1) (1)
  • createMarkdownComponents (30-128)
cli/src/registry/message-thread-panel/message-thread-panel.tsx (9)
cli/src/types/components.d.ts (4) (4)
  • ThreadHistory (74-76)
  • ThreadContent (35-37)
  • MessageSuggestions (56-58)
  • MessageInput (46-48)
cli/src/registry/thread-history/index.tsx (1) (1)
  • ThreadHistory (1-1)
cli/src/registry/thread-history/thread-history.tsx (1) (1)
  • ThreadHistory (20-168)
cli/src/registry/thread-content/thread-content.tsx (1) (1)
  • ThreadContent (98-98)
cli/src/registry/thread-content/index.tsx (1) (1)
  • ThreadContent (1-1)
cli/src/registry/message-suggestions.tsx/index.tsx (1) (1)
  • MessageSuggestions (2-2)
cli/src/registry/message-suggestions.tsx/message-suggestions.tsx (1) (1)
  • MessageSuggestions (13-133)
cli/src/registry/message-input/message-input.tsx (1) (1)
  • MessageInput (149-149)
cli/src/registry/message-input/index.tsx (1) (1)
  • MessageInput (1-1)
cli/src/registry/message-suggestions.tsx/message-suggestions.tsx (2)
cli/src/registry/message-suggestions.tsx/index.tsx (2) (2)
  • MessageSuggestionsProps (3-3)
  • MessageSuggestions (2-2)
cli/src/types/components.d.ts (2) (2)
  • MessageSuggestionsProps (52-55)
  • MessageSuggestions (56-58)
cli/src/registry/message-thread-full/message-thread-full.tsx (8)
cli/src/registry/thread-history/index.tsx (1) (1)
  • ThreadHistory (1-1)
cli/src/registry/thread-history/thread-history.tsx (1) (1)
  • ThreadHistory 8000 (20-168)
cli/src/registry/thread-content/thread-content.tsx (1) (1)
  • ThreadContent (98-98)
cli/src/registry/thread-content/index.tsx (1) (1)
  • ThreadContent (1-1)
cli/src/registry/message-suggestions.tsx/index.tsx (1) (1)
  • MessageSuggestions (2-2)
cli/src/registry/message-suggestions.tsx/message-suggestions.tsx (1) (1)
  • MessageSuggestions (13-133)
cli/src/registry/message-input/message-input.tsx (1) (1)
  • MessageInput (149-149)
cli/src/registry/message-input/index.tsx (1) (1)
  • MessageInput (1-1)
cli/src/registry/thread-content/thread-content.tsx (2)
cli/src/types/components.d.ts (2) (2)
  • ThreadContentProps (31-34)
  • ThreadContent (35-37)
cli/src/registry/thread-content/index.tsx (2) (2)
  • ThreadContentProps (1-1)
  • ThreadContent (1-1)
cli/src/registry/message-thread-collapsible/message-thread-collapsible.tsx (9)
cli/src/types/components.d.ts (4) (4)
  • ThreadHistory (74-76)
  • ThreadContent (35-37)
  • MessageSuggestions (56-58)
  • MessageInput (46-48)
cli/src/registry/thread-history/index.tsx (1) (1)
  • ThreadHistory (1-1)
cli/src/registry/thread-history/thread-history.tsx (1) (1)
  • ThreadHistory (20-168)
cli/src/registry/thread-content/thread-content.tsx (1) (1)
  • ThreadContent (98-98)
cli/src/registry/thread-content/index.tsx (1) (1)
  • ThreadContent (1-1)
cli/src/registry/message-suggestions.tsx/index.tsx (1) (1)
  • MessageSuggestions (2-2)
cli/src/registry/message-suggestions.tsx/message-suggestions.tsx (1) (1)
  • MessageSuggestions (13-133)
cli/src/registry/message-input/message-input.tsx (1) (1)
  • MessageInput (149-149)
cli/src/registry/message-input/index.tsx (1) (1)
  • MessageInput (1-1)
🔇 Additional comments (39)
cli/src/registry/message-input/config.json (1)

1-12: Looks good for a new config file.

The JSON structure is clear and the dependencies are well defined. No issues found.

cli/src/registry/message/config.json (2)

10-10: Check for devDependency necessity.

Verify if @types/react-syntax-highlighter is needed in all environments. If it’s only used in local development, this is fine, but removing it if unused can reduce clutter.


16-19: New file reference looks correct.

The newly added markdownComponents file is properly defined here. Ensure the path remains valid if the project structure changes.

cli/src/registry/message-input/message-input.tsx (1)

84-91: Keyboard shortcut detection.

Your approach for detecting Cmd/Ctrl + Enter is correct and well-scoped. Good job ensuring default actions (e.g., newlines) don’t interfere. This should greatly enhance user experience.

cli/src/registry/message-suggestions.tsx/index.tsx (1)

1-4: LGTM: Export statements are clear and straightforward.
These exports neatly expose the MessageSuggestions component and its props, improving maintainability and discoverability throughout the codebase.

cli/src/registry/thread-content/config.json (1)

1-12: Configuration file added successfully.

This new config.json appears consistent with the updated naming conventions, referencing the thread-content name and file. The "requires" field and "dependencies" array look well-structured, and there's no immediate concern regarding dependencies.

cli/src/registry/message/markdownComponents.tsx (2)

30-82: Warn about navigator.clipboard.writeText availability in non-HTTPS contexts.

Using navigator.clipboard within the client can fail in insecure environments (non-HTTPS). Ensure you handle any potential errors gracefully or document that the feature requires a secure context.

Could you confirm whether the app environment enforces HTTPS and handle fallback for environments (like local development over HTTP) where clipboard APIs might be restricted?


83-128: Great usage of styled Markdown components.

Each Markdown element is clearly mapped to a styled component. This approach ensures consistency and maintainability. The logic for headings, lists, blockquotes, links, and tables adheres to best practices, providing readable styling out of the box.

cli/src/registry/message-thread-collapsible/message-thread-collapsible.tsx (4)

6-9: Renaming references aligns with the PR objectives.

Replacing ChatThread with ThreadContent and ChatInput with MessageInput matches the new naming convention. Good job maintaining consistent naming across imports.


11-12: Confirm package usage.

The useTambo hook and XIcon import look correct. Verify that the associated versions (@tambo-ai/react and lucide-react) meet your project’s requirements and that no additional peer dependencies are needed.


99-107: Smart UI approach to toggle between “Use AI” and “Conversations.”

Conditionally rendering ThreadHistory is an elegant solution. This helps reduce clutter when the collapsible is closed. Great job ensuring these components remain separate, encouraging modular design.


109-125: Graceful close button behavior.

Good approach to stopping event propagation to prevent toggling the collapsible from the parent trigger. The close button with XIcon neatly closes the collapsible without interfering with the rest of the layout.

cli/src/registry/message-thread-full/message-thread-full.tsx (4)

6-9: Component imports updated to match the new naming conventions.

The import statements have been appropriately updated to use the new component names (ThreadContent, MessageInput) and added new components (MessageSuggestions, ThreadHistory) that enhance the message thread functionality.


53-55: UI improvements with better header layout and terminology.

The header has been improved by:

  1. Changing from "Chat with tambo" to "Use AI" for a more generic AI interaction model
  2. Adding the ThreadHistory component for better thread management
  3. Using a flex layout with justify-between for better spacing

These changes enhance usability and align with modern UI practices.


59-61: Scrollbar styling improved for better visual appearance.

The scrollbar styling has been enhanced with specific WebKit styles, making it more visually appealing while maintaining functionality.


61-66: Components properly replaced with improved naming and additional functionality.

The replacement of ChatThread with ThreadContent and ChatInput with MessageInput, along with the addition of MessageSuggestions, creates a more intuitive and feature-rich message interface. The naming is now more descriptive of the actual functionality.

cli/src/registry/message-suggestions.tsx/message-suggestions.tsx (2)

1-133: Well-implemented new MessageSuggestions component with keyboard accessibility.

The new MessageSuggestions component is a valuable addition that:

  1. Provides intelligent suggestions with keyboard shortcuts
  2. Has platform-specific handling (Mac vs Windows/Linux)
  3. Includes collapsible UI with proper toggle functionality
  4. Implements proper cleanup in useEffect hooks
  5. Has clear visual design with good accessibility features

The implementation is clean, well-structured, and follows React best practices with proper use of hooks and event handlers.


31-54: Ensure keyboard event handling doesn't conflict with other shortcuts.

The current implementation uses modifier keys (Ctrl+Alt or Cmd+Alt) which might conflict with other system or browser shortcuts.

Please verify that these key combinations don't conflict with common browser or system shortcuts across different platforms. Additionally, consider adding some visual indication or tooltip to help users discover these shortcuts.

cli/src/registry/message-thread-panel/message-thread-panel.tsx (5)

6-9: Component imports updated to match the new naming conventions.

The import statements have been appropriately updated to align with the renamed components (ThreadContent, MessageInput) and added new components (MessageSuggestions, ThreadHistory).


29-33: Well-implemented resizing functionality with state management.

The panel resizing functionality is well implemented with:

  1. State management for width
  2. Reference for tracking resizing state
  3. Proper use of useRef to avoid unnecessary rerenders

34-47: Auto-scroll functionality improves user experience.

The addition of auto-scroll functionality that keeps the conversation view at the latest message is an excellent UX improvement. The implementation properly uses cleanup for timeouts and has appropriate behavior.


49-70: Resize event handlers properly implemented with cleanup.

The mouse event handlers for resizing are well implemented with:

  1. Proper event cleanup to prevent memory leaks
  2. Bounds checking to keep width within reasonable limits (300-800px)
  3. Good use of useCallback for optimizing event handlers

87-96: UI components positioned logically with improved header.

The layout has been improved with a better header arrangement, including proper title and thread history management. The content area now has appropriate styling for scrolling and padding.

cli/src/registry/message/message.tsx (6)

4-8: Security improvement by using ReactMarkdown instead of sanitizeHtml.

Replacing sanitizeHtml with ReactMarkdown is a good security improvement and provides better rendering capabilities for markdown content.


59-59: Added isLoading property improves user feedback.

The addition of the isLoading property enhances the UI by providing visual feedback during message processing.


67-71: Performance optimization with useMemo for content processing.

The implementation of useMemo for content processing is a good performance optimization, especially for potentially large content strings or arrays.


73-96: Well-implemented loading state with animated indicators.

The loading state implementation with animated dots provides excellent visual feedback to users. The conditional rendering is clean and only applies to assistant messages.


108-111: Improved message attribution with role labels.

Adding role labels ("You" or "Tambo AI") above each message improves clarity in the conversation thread and helps users distinguish between their messages and AI responses.


117-126: Proper implementation of ReactMarkdown with custom components.

The implementation of ReactMarkdown with custom components from createMarkdownComponents() ensures consistent styling and proper rendering of markdown content.

cli/src/registry/thread-content/thread-content.tsx (6)

5-7: Import changes look good.

The imports have been updated to include necessary components and utilities for the renamed ThreadContent component.


9-9: Consistent renaming from ChatThread to ThreadContent.

The renaming of chatThreadVariants to threadContentVariants and the interface from ChatThreadProps to ThreadContentProps aligns with the PR objectives. The renamed interface maintains the same structure and functionality.

Also applies to: 31-33


36-40: Enhanced component with loading state detection.

The component has been properly renamed and now includes loading state detection through the generationStage from the useTambo hook. This is a good improvement that enhances the user experience by providing visual feedback during message generation.


48-57: Improved message content handling with loading state.

The message rendering logic has been enhanced to:

  1. Detect when messages are loading based on the generation stage
  2. Handle different content formats (array, string)
  3. Provide appropriate fallbacks for empty messages

This implementation provides a better user experience by properly handling the loading state of messages.


83-83: Message component props updated for loading state.

The Message component now receives the properly formatted content and a loading indicator flag. This works well with the enhanced rendering logic to improve the user experience.

Also applies to: 86-86


96-98: Component metadata and exports updated for consistency.

The displayName and exports have been updated to reflect the new component name, maintaining consistency throughout the codebase.

cli/src/types/components.d.ts (4)

23-23: Added isLoading property to MessageProps.

The addition of the optional isLoading property aligns with the changes in thread-content.tsx where this property is now being passed to the Message component. This is a good enhancement that supports the loading state visualization.


30-37: Renamed module declaration from chat-thread to thread-content.

The module declaration has been updated to reflect the component renaming from ChatThread to ThreadContent. The interface and component type declarations have been correspondingly updated, maintaining consistency across the codebase.


51-87: Added type declarations for new components.

The addition of type declarations for MessageSuggestions, markdownComponents, ThreadHistory, and ThreadList enhances the type safety of the codebase. These declarations follow the established patterns in the file and will help prevent type errors when using these components.


40-49:

❓ Verification inconclusive

Potential breaking change in MessageInputProps.

The contextKey property has been changed from string | null | undefined (optional) to string | undefined (required but can be undefined). This could be a breaking change for consumers that:

  1. Previously passed null as the value
  2. Omitted the property entirely (since it's no longer optional)

Verify that all consumers of this component have been updated to handle this change.

Also applies to: 44-44


🏁 Script executed:

#!/bin/bash
# Search for uses of MessageInput/ChatInput component to verify usage patterns
echo "Searching for MessageInput/ChatInput component usage patterns..."
rg -A 2 -B 2 "<(Message|Chat)Input" --type tsx --type jsx

Length of output: 226


Attention: Potential Breaking Change in MessageInputProps

In cli/src/types/components.d.ts (lines 40–49), the contextKey property has been updated from an optional string | null | undefined to string | undefined. This update may break existing consumers that:

  • Previously passed null as the value.
  • Relied on omitting the property (thanks to its optional status).

An initial attempt to verify usage via a search for TSX files returned an error (unrecognized file type: tsx), so automated verification was inconclusive. Please perform a manual check (or update the search script to handle TSX files correctly) to ensure that all consumers of MessageInput (and similarly, ChatInput if applicable) handle the new type correctly.

Comment on lines +31 to +35
export interface MessageInputProps
extends React.HTMLAttributes<HTMLFormElement> {
variant?: VariantProps<typeof messageInputVariants>["variant"];
contextKey: string | undefined;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Clarify required vs. optional status of contextKey.

The MessageInputProps interface declares contextKey: string | undefined;, yet the doc comment says it's for routing messages. If it’s truly required for message routing, consider enforcing a non-undefined type.

Comment on lines +5 to +10
"requires": [
"thread-content",
"message-input",
"message-suggestions",
"thread-history"
],
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Verify the renamed dependencies in other files.
Updating "requires" from older component names to "thread-content", "message-input", "message-suggestions", and "thread-history" appears consistent with the overall refactor. Ensure related references are correctly updated to avoid runtime errors.

Below is an optional script that searches for references to the old components and verifies consistency with the new names:


🏁 Script executed:

#!/bin/bash
# Description: Search for old "chat-thread"/"chat-input" references and confirm new dependencies.

rg "chat-thread|chat-input" -A 2
rg "thread-content|message-input|message-suggestions|thread-history" -A 2

Length of output: 9464


Action Required: Update Legacy Showcase Imports

The registry configuration update in cli/src/registry/message-thread-full/config.json correctly replaces the older dependency names with "thread-content", "message-input", "message-suggestions", and "thread-history". However, our search revealed that a few showcase files still reference the legacy components:

  • showcase/src/components/tabs/threads.tsx: Uses ChatThread and ChatInput imports.
  • showcase/src/components/tabs/messages.tsx: Uses ChatThread and ChatInput imports.
  • showcase/src/components/tabs/examples.tsx: Uses ChatThread and ChatInput imports.

Please verify whether these showcase files should also be updated to use the new naming conventions (e.g., replacing ChatThread with the updated component name, if applicable) to avoid any runtime inconsistencies.

Comment on lines +13 to +28
const looksLikeCode = (text: string): boolean => {
const codeIndicators = [
/^import\s+/m,
/^function\s+/m,
/^class\s+/m,
/^const\s+/m,
/^let\s+/m,
/^var\s+/m,
/[{}[\]();]/,
/^\s*\/\//m,
/^\s*\/\*/m,
/=>/,
/^export\s+/m,
];
return codeIndicators.some((pattern) => pattern.test(text));
};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Validate looksLikeCode heuristics for broader language coverage.

The regex patterns in looksLikeCode focus primarily on JavaScript/TypeScript syntax features. If you expect to handle additional programming languages, consider broadening or dynamically determining regex patterns to reduce false positives or coverage gaps.

Comment on lines +63 to +76
useEffect(() => {
if (scrollContainerRef.current && thread?.messages?.length) {
const timeoutId = setTimeout(() => {
if (scrollContainerRef.current) {
scrollContainerRef.current.scrollTo({
top: scrollContainerRef.current.scrollHeight,
behavior: "smooth",
});
}
}, 100);

return () => clearTimeout(timeoutId);
}
}, [thread?.messages]);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Check performance with large message histories.

Scrolling to the bottom on message updates is user-friendly. However, if the message list grows very large, frequent re-renders could cause performance hiccups. Consider virtualization strategies or pagination if the messages are numerous.

- Added loading states to messages.
- Added components for suggestions and thread history.
- Enabled keyboard shortcuts for sending messages.
- Improved scrolling for new messages.
- Updated dependencies and config files.
@akhileshrangani4 akhileshrangani4 force-pushed the akhilesh/cli-improvements branch from 67f5b4a to 1c49d4f Compare March 22, 2025 00:09
Copy link
@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (9)
cli/src/registry/thread-history/thread-history.tsx (4)

30-38: Consider using a more modern approach for platform detection

The navigator.platform API is deprecated. While it works in most browsers, consider using a more future-proof method like userAgentData or a library for platform detection.

  React.useEffect(() => {
    const isMacOS =
      typeof navigator !== "undefined" &&
-     navigator.platform.toUpperCase().includes("MAC");
+     /Mac|iPod|iPhone|iPad/.test(navigator.userAgent);
    setIsMac(isMacOS);
  }, []);

49-50: Enhance error logging for better debugging

The current error logging is minimal and might not provide enough context for debugging issues.

      } catch (error) {
-       console.error("Failed to create new thread:", error);
+       console.error("Failed to create new thread:", error instanceof Error ? error.message : error);
      }

79-80: Enhance error logging for better debugging

Similar to the previous comment, consider improving error logging here as well.

    } catch (error) {
-     console.error("Failed to switch thread:", error);
+     console.error("Failed to switch thread:", error instanceof Error ? error.message : error);
    }

157-159: Consider more user-friendly thread identification

Currently, threads are identified by the first 8 characters of their UUID, which may not be meaningful to users.

Consider using a more descriptive naming convention, such as timestamps or allowing users to name their threads. If that's not possible, you might want to add a tooltip showing the full thread ID for reference.

  <span className="truncate max-w-[180px]">
-   {`Thread ${thread.id.substring(0, 8)}`}
+   {thread.name || `Thread ${new Date(thread.createdAt).toLocaleString()}`}
  </span>
cli/src/registry/message-suggestions.tsx/message-suggestions.tsx (3)

31-54: Consider isolating keyboard event listeners to prevent conflicts

The global keyboard event listeners might interfere with other components. Consider a more isolated approach.

Also, error handling should be added to the async accept call.

  React.useEffect(() => {
    if (!suggestions || suggestions.length === 0) return;

    const handleKeyDown = (event: KeyboardEvent) => {
+     // Only handle events when this component is focused or visible
+     if (!isVisible) return;
      
      const modifierPressed = isMac
        ? event.metaKey && event.altKey
        : event.ctrlKey && event.altKey;

      if (modifierPressed) {
        const keyNum = parseInt(event.key);
        if (!isNaN(keyNum) && keyNum > 0 && keyNum <= suggestions.length) {
          event.preventDefault();
          const suggestionIndex = keyNum - 1;
-         accept({ suggestion: suggestions[suggestionIndex] });
+         accept({ suggestion: suggestions[suggestionIndex] }).catch(err => {
+           console.error('Failed to accept suggestion:', err);
+         });
        }
      }
    };

    document.addEventListener("keydown", handleKeyDown);

    return () => {
      document.removeEventListener("keydown", handleKeyDown);
    };
  }, [suggestions, accept, isMac, isVisible]);

104-106: Add error handling to async click handler

The click handler is async but doesn't handle potential errors from the accept function.

-             () => await accept({ suggestion })}
+             () => {
+              try {
+                await accept({ suggestion });
+              } catch (err) {
+                console.error('Failed to accept suggestion:', err);
+              }
+            }}

117-121: Add error handling to submit button async call

Similar to the previous issue, this async event handler should include error handling.

                 => {
                  e.stopPropagation();
-                 accept({ suggestion, shouldSubmit: true });
+                 accept({ suggestion, shouldSubmit: true }).catch(err => {
+                   console.error('Failed to submit suggestion:', err);
+                 });
                }}
cli/src/registry/message-thread-panel/message-thread-panel.tsx (1)

49-70: Resizing functionality uses proper event handling

The resize implementation is well-structured with proper event management and cleanup.

Consider adding a resize indicator for better user experience.

      <div
-       className="absolute left-0 top-0 bottom-0 w-1 cursor-ew-resize hover:bg-gray-300 transition-colors"
+       className="absolute left-0 top-0 bottom-0 w-1 cursor-ew-resize hover:bg-gray-300 transition-colors flex items-center justify-center"
        
-     />
+     >
+       {isResizing.current && (
+         <div className="h-10 w-1 bg-primary rounded-full"></div>
+       )}
+     </div>
cli/src/registry/message/message.tsx (1)

97-133: Improved message rendering with ReactMarkdown

The message rendering has been enhanced with:

  • Clear role indication
  • Proper handling of different content types
  • ReactMarkdown for better formatting
  • Appropriate whitespace handling

Consider extracting the role label to a separate component for better maintainability.

-            <div className="text-sm mb-1 opacity-50">
-              {role === "user" ? "You" : "Tambo AI"}
-            </div>
+            <RoleLabel role={role} />

// Then add elsewhere in the file:
// const RoleLabel = ({ role }: { role: "user" | "assistant" }) => (
//   <div className="text-sm mb-1 opacity-50">
//     {role === "user" ? "You" : "Tambo AI"}
//   </div>
// );
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b5ba758 and 1c49d4f.

📒 Files selected for processing (25)
  • cli/src/registry/control-bar/config.json (1 hunks)
  • cli/src/registry/control-bar/control-bar.tsx (4 hunks)
  • cli/src/registry/input-fields/input-fields.tsx (1 hunks)
  • cli/src/registry/message-input/config.json (1 hunks)
  • cli/src/registry/message-input/message-input.tsx (1 hunks)
  • cli/src/registry/message-suggestions.tsx/config.json (1 hunks)
  • cli/src/registry/message-suggestions.tsx/index.tsx (1 hunks)
  • cli/src/registry/message-suggestions.tsx/message-suggestions.tsx (1 hunks)
  • cli/src/registry/message-thread-collapsible/config.json (1 hunks)
  • cli/src/registry/message-thread-collapsible/message-thread-collapsible.tsx (3 hunks)
  • cli/src/registry/message-thread-full/config.json (1 hunks)
  • cli/src/registry/message-thread-full/message-thread-full.tsx (2 hunks)
  • cli/src/registry/message-thread-panel/config.json (1 hunks)
  • cli/src/registry/message-thread-panel/message-thread-panel.tsx (2 hunks)
  • cli/src/registry/message/config.json (1 hunks)
  • cli/src/registry/message/markdownComponents.tsx (1 hunks)
  • cli/src/registry/message/message.tsx (3 hunks)
  • cli/src/registry/thread-content/config.json (1 hunks)
  • cli/src/registry/thread-content/thread-content.tsx (5 hunks)
  • cli/src/registry/thread-history/config.json (1 hunks)
  • cli/src/registry/thread-history/index.tsx (1 hunks)
  • cli/src/registry/thread-history/thread-history.tsx (1 hunks)
  • cli/src/registry/thread-list/thread-list.tsx (1 hunks)
  • cli/src/types/components.d.ts (2 hunks)
  • cli/src/types/utils.d.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (16)
  • cli/src/registry/message-suggestions.tsx/index.tsx
  • cli/src/registry/thread-list/thread-list.tsx
  • cli/src/registry/thread-history/index.tsx
  • cli/src/registry/thread-history/config.json
  • cli/src/registry/message-thread-full/config.json
  • cli/src/registry/input-fields/input-fields.tsx
  • cli/src/registry/message-suggestions.tsx/config.json
  • cli/src/registry/message-thread-panel/config.json
  • cli/src/registry/message-input/config.json
  • cli/src/registry/message/markdownComponents.tsx
  • cli/src/registry/control-bar/config.json
  • cli/src/registry/message-thread-collapsible/config.json
  • cli/src/registry/thread-content/config.json
  • cli/src/registry/message-input/message-input.tsx
  • cli/src/registry/thread-content/thread-content.tsx
  • cli/src/registry/message/config.json
🧰 Additional context used
🧬 Code Definitions (5)
cli/src/registry/control-bar/control-bar.tsx (1)
cli/src/types/components.d.ts (2) (2)
  • MessageInput (46-48)
  • ThreadContent (35-37)
cli/src/registry/message-suggestions.tsx/message-suggestions.tsx (2)
cli/src/registry/message-suggestions.tsx/index.tsx (2) (2)
  • MessageSuggestionsProps (3-3)
  • MessageSuggestions (2-2)
cli/src/types/components.d.ts (2) (2)
  • MessageSuggestionsProps (52-55)
  • MessageSuggestions (56-58)
cli/src/registry/message-thread-panel/message-thread-panel.tsx (9)
cli/src/types/components.d.ts (4) (4)
  • ThreadHistory (74-76)
  • ThreadContent (35-37)
  • MessageSuggestions (56-58)
  • MessageInput (46-48)
cli/src/registry/thread-history/index.tsx (1) (1)
  • ThreadHistory (1-1)
cli/src/registry/thread-history/thread-history.tsx (1) (1)
  • ThreadHistory (20-168)
cli/src/registry/thread-content/thread-content.tsx (1) (1)
  • ThreadContent (98-98)
cli/src/registry/thread-content/index.tsx (1) (1)
  • ThreadContent (1-1)
cli/src/registry/message-suggestions.tsx/index.tsx (1) (1)
  • MessageSuggestions (2-2)
cli/src/registry/message-suggestions.tsx/message-suggestions.tsx (1) (1)
  • MessageSuggestions (13-133)
cli/src/registry/message-input/message-input.tsx (1) (1)
  • MessageInput (149-149)
cli/src/registry/message-input/index.tsx (1) (1)
  • MessageInput (1-1)
cli/src/registry/message-thread-collapsible/message-thread-collapsible.tsx (9)
cli/src/types/components.d.ts (4) (4)
  • ThreadHistory (74-76)
  • ThreadContent (35-37)
  • MessageSuggestions (56-58)
  • MessageInput (46-48)
cli/src/registry/thread-history/index.tsx (1) (1)
  • ThreadHistory (1-1)
cli/src/registry/thread-history/thread-history.tsx (1) (1)
  • ThreadHistory (20-168)
cli/src/registry/thread-content/thread-content.tsx (1) (1)
  • ThreadContent (98-98)
cli/src/registry/thread-content/index.tsx (1) (1)
  • ThreadContent (1-1)
cli/src/registry/message-suggestions.tsx/index.tsx (1) (1)
  • MessageSuggestions (2-2)
cli/src/registry/message-suggestions.tsx/message-suggestions.tsx (1) (1)
  • MessageSuggestions (13-133)
cli/src/registry/message-input/message-input.tsx (1) (1)
  • MessageInput (149-149)
cli/src/registry/message-input/index.tsx (1) (1)
  • MessageInput (1-1)
cli/src/registry/message-thread-full/message-thread-full.tsx (8)
cli/src/registry/thread-history/index.tsx (1) (1)
  • ThreadHistory (1-1)
cli/src/registry/thread-history/thread-history.tsx (1) (1)
  • ThreadHistory (20-168)
cli/src/registry/thread-content/thread-content.tsx (1) (1)
  • ThreadContent (98-98)
cli/src/registry/thread-content/index.tsx (1) (1)
  • ThreadContent (1-1)
cli/src/registry/message-suggestions.tsx/index.tsx (1) (1)
  • MessageSuggestions (2-2)
cli/src/registry/message-suggestions.tsx/message-suggestions.tsx (1) (1)
  • MessageSuggestions (13-133)
cli/src/registry/message-input/message-input.tsx (1) (1)
  • MessageInput (149-149)
cli/src/registry/message-input/index.tsx (1) (1)
  • MessageInput (1-1)
🔇 Additional comments (43)
cli/src/registry/thread-history/thread-history.tsx (3)

1-18: Well-structured component interface with comprehensive props

The component interface is clearly defined with appropriate props that allow for customization. The extension of React's HTMLAttributes ensures proper typing for HTML div attributes.


45-50: TODO comment indicates incomplete implementation

There's a TODO comment indicating that this code will be updated when createThread is implemented. This suggests the current implementation is temporary.

Please verify when the createThread implementation will be completed. The current implementation appears to call switchCurrentThread with an empty string and false parameter, which may not be the intended behavior for creating a new thread.


88-166: Well-implemented UI with proper accessibility considerations

The dropdown implementation using Radix UI demonstrates a good approach to accessibility. The component properly handles loading, error, and empty states, and includes keyboard shortcuts for better user experience.

cli/src/types/components.d.ts (8)

9-10: Component naming updates aligned with PR objectives.

The file description has been updated to reflect the renamed components: "ThreadContent" and "MessageInput" replacing the previous "ChatThread" and "ChatInput", consistent with the PR objectives.


23-23: Good addition of isLoading flag for better UX.

The optional isLoading boolean property on the MessageProps interface will allow for displaying loading states in the UI, enhancing the user experience.


30-38: Component renamed from ChatThread to ThreadContent.

The component has been correctly renamed with its corresponding props interface, maintaining the same structure while improving naming clarity.


40-49: Component renamed from ChatInput to MessageInput.

The component has been correctly renamed with its corresponding props interface. The contextKey property type has been fixed from string | null | undefined to string | undefined, addressing a previous review comment.


51-59: Good addition of MessageSuggestions component.

This new component will enhance the user experience by providing suggestions during message composition.


61-65: Useful addition of markdown component factory.

The createMarkdownComponents function will allow for theme-aware markdown rendering throughout the application.


67-77: Good addition of ThreadHistory component.

This component will enable users to navigate through conversation history, enhancing the application's usability. The required contextKey property ensures proper thread identification.


79-87: Useful addition of ThreadList component.

This component complements the ThreadHistory, providing a standardized way to display multiple threads.

cli/src/types/utils.d.ts (4)

60-95: Good addition of Radix UI dropdown menu type definitions.

The type definitions for Radix UI dropdown menu components provide proper TypeScript support, improving developer experience with autocompletion and type checking. The components include Root, Trigger, Portal, Content, Item, and Separator with their respective props.


97-107: Beneficial addition of React Markdown type definitions.

Adding type definitions for ReactMarkdown enables proper TypeScript integration for markdown rendering, which is essential for displaying formatted message content.


109-122: Good addition of syntax highlighter type definitions.

The type definitions for the syntax highlighter components will enable proper code formatting in messages, enhancing readability for code-focused conversations.


124-127: Good addition of syntax highlighter style definitions.

Including type definitions for syntax highlighter styles ensures both light and dark theme support for code snippets.

cli/src/registry/control-bar/control-bar.tsx (5)

4-9: Updated imports to use renamed components.

The imports have been appropriately updated to use the renamed components (ThreadContent and MessageInput) and additional hooks for the new scrolling functionality.


27-42: Good addition of auto-scrolling functionality.

This enhancement improves the user experience by automatically scrolling to the latest messages when new content is added to the thread. The implementation uses a timeout to ensure the scroll happens after the DOM has been updated.


65-65: Accessibility improvement with outline-none class.

Adding the outline-none class to the Dialog.Content improves the visual appearance while maintaining keyboard navigation capabilities.


74-74: Component replaced with MessageInput.

The ChatInput component has been correctly replaced with the renamed MessageInput component, maintaining the same props and functionality.


78-83: Enhanced scroll container with ref and styling.

The scroll container has been improved with a ref for auto-scrolling and appropriate styling for better usability.

cli/src/registry/message-thread-collapsible/message-thread-collapsible.tsx (7)

4-12: Updated imports to use renamed components and add new functionality.

The imports have been appropriately updated to use the renamed components (ThreadContent and MessageInput) along with new components (ThreadHistory and MessageSuggestions) and icons for the enhanced UI.


30-40: Good addition of OS detection for keyboard shortcuts.

The implementation now detects if the user is on macOS to display the appropriate keyboard shortcut symbol (⌘ or Ctrl), enhancing usability across different platforms.


42-58: Enhanced keyboard shortcut handling.

The implementation adds a keyboard shortcut (Cmd+K or Ctrl+K) to toggle the collapsible component, improving accessibility and usability. The shortcut text is displayed dynamically based on the detected operating system.


59-61: Added callback for thread changes.

This callback ensures the collapsible component opens when a thread is selected, providing a better user experience.


63-76: Check performance with large message histories.

Scrolling to the bottom on message updates is user-friendly. However, if the message list grows very large, frequent re-renders could cause performance hiccups. Consider virtualization strategies or pagination if the messages are numerous.


99-126: Enhanced UI with thread history and close button.

The UI has been significantly improved with:

  1. Dynamic title display based on the collapsible state
  2. Integration of the ThreadHistory component for thread navigation
  3. Context-aware keyboard shortcut display
  4. A dedicated close button for better usability

These changes enhance both aesthetics and functionality.


130-139: Improved content area with ThreadContent and MessageSuggestions.

The content area has been enhanced with:

  1. A scrollable container with a proper ref for auto-scrolling
  2. ThreadContent component for displaying the conversation
  3. MessageSuggestions component for providing intelligent suggestions
  4. MessageInput component for user input

This comprehensive layout provides better organization and user experience.

cli/src/registry/message-thread-full/message-thread-full.tsx (4)

6-9: Component import updates align with component renaming effort

The imports have been correctly updated to use the new component names:

  • ThreadContent replaces ChatThread
  • MessageInput replaces ChatInput
  • New components MessageSuggestions and ThreadHistory have been added

These changes align with the PR objectives to rename components.


53-56: Header layout updated with thread history

The header has been improved with:

  • Better layout using flex between items
  • Updated text from "Chat with tambo" to "Use AI"
  • Added ThreadHistory component for improved thread management

59-62: Improved scrollbar styling and component replacement

The scrollbar styling has been added for better visual appearance, and ThreadContent correctly replaces the previous ChatThread component.


63-66: Added new MessageSuggestions component and updated input

The MessageSuggestions component has been properly added to provide suggestions functionality, and MessageInput correctly replaces ChatInput for improved naming consistency.

cli/src/registry/message-suggestions.tsx/message-suggestions.tsx (3)

8-11: Well-defined props interface for MessageSuggestions

The props interface is clearly defined with appropriate extensions and optional properties.


13-22: Clean implementation of component state and hooks

The component properly initializes with the useTamboSuggestions hook and maintains appropriate state for visibility and platform detection.


24-29: Platform detection for keyboard shortcuts

The OS detection logic is well-implemented to provide the appropriate keyboard shortcut indicators based on the user's platform.

cli/src/registry/message-thread-panel/message-thread-panel.tsx (5)

6-10: Component imports updated for naming consistency

The imports have been updated to match the renamed components and new additions, consistent with other files.


29-33: State and refs properly defined for panel functionality

The component now correctly maintains state for panel width and uses refs to track resizing state and container references.


34-47: Auto-scroll implementation for new messages

The scroll functionality is well-implemented to ensure new messages are visible.


87-96: Updated component structure with new names

The header has been correctly updated with ThreadHistory component and proper styling.


97-100: Added MessageSuggestions and updated MessageInput

The addition of MessageSuggestions and replacement of ChatInput with MessageInput aligns with the component renaming effort.

cli/src/registry/message/message.tsx (4)

4-8: Updated imports for enhanced rendering capabilities

The imports have been updated to include React, markdown components, and ReactMarkdown for better content rendering.


59-59: Added isLoading prop to MessageProps

The MessageProps interface has been extended with an optional isLoading property to support loading states.


67-71: Added content sanitization with useMemo

The useMemo implementation for content sanitization is well-done, handling different content types appropriately.


73-95: Loading state with animated dots for assistant messages

The loading state implementation with animated dots provides a good user experience.

@akhileshrangani4 akhileshrangani4 changed the title chore(cli): rename chat components and add update command chore(cli): update components UI and add update command Mar 22, 2025
@akhileshrangani4 akhileshrangani4 merged commit a675c7d into main Mar 22, 2025
6 checks passed
@akhileshrangani4 akhileshrangani4 deleted the akhilesh/cli-improvements branch March 22, 2025 05:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0