Skip to content

feat(wren-ui): Add Question-SQL Pairs guide#1387

Merged
fredalai merged 2 commits intomainfrom
feature/sql-pairs-guide
Mar 13, 2025
Merged

feat(wren-ui): Add Question-SQL Pairs guide#1387
fredalai merged 2 commits intomainfrom
feature/sql-pairs-guide

Conversation

@fredalai
Copy link
Copy Markdown
Contributor

@fredalai fredalai commented Mar 11, 2025

Description

  • Add Question-SQL Pairs guide

UI screenshots/video

2025-03-12.11.59.46.mov
2025-03-12.12.01.12.mov

Manage Question-SQL Pairs

截圖 2025-03-12 上午11 53 18

Save to Knowledge

截圖 2025-03-12 中午12 00 03

Summary by CodeRabbit

  • New Features

    • Introduced interactive guides that offer dynamic prompts, action buttons, and visual cues to enhance content handling and saving.
    • Added a new threaded navigation route for improved user workflows.
    • Integrated tracking attributes on answer previews and results to enrich contextual interactivity.
  • Refactor

    • Streamlined the guide playback process for a more intuitive and consistent learning experience.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 11, 2025

Walkthrough

The changes introduce two new interactive guides for creating and saving Question-SQL pairs in the learning module. New guide functions are added with asynchronous behavior and dynamic DOM observation. A styled icon component is introduced to enhance visual elements. The router-based control flow for playing guides is refactored using a mapping object. Additionally, new enum entries are defined for guide types, and several UI components are updated with data attributes for guide identification. A new route for thread handling is also added to the path enum.

Changes

File(s) Change Summary
wren-ui/src/components/learning/guide/stories.tsx Added playQuestionSQLPairsGuide and playSaveToKnowledgeGuide functions with popover and observer logic; introduced a styled RobotIcon; updated makeStoriesPlayer to handle new guide cases.
wren-ui/src/components/learning/guide/utils.ts Added new enum entries QUESTION_SQL_PAIRS_GUIDE and SAVE_TO_KNOWLEDGE under the knowledge section.
wren-ui/src/components/learning/index.tsx Refactored guide playback by mapping router paths to asynchronous functions; consolidated conditionals and updated dependency array.
wren-ui/src/components/pages/home/promptThread/AnswerResult.tsx,
wren-ui/src/components/pages/home/promptThread/TextBasedAnswer.tsx,
wren-ui/src/components/pages/home/promptThread/index.tsx
Added data-guideid attributes to UI elements to assist with guide tracking/identification.
wren-ui/src/utils/enum/path.ts Added a new enum member Thread with the value '/home/[id]' to support dynamic routing.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Router
    participant Controller as Learning Guide Controller
    participant Guide as Guide Function
    participant Driver
    participant UI

    User->>Router: Navigate to a new route
    Router->>Controller: Notify route change
    Controller->>Guide: Look up and trigger guide function based on path
    Guide->>Driver: Verify driver initialization and state
    Guide->>UI: Render popover with guide instructions
    UI-->>User: Display dynamic guide elements (managed by observers)
Loading

Suggested labels

module/ui

Suggested reviewers

  • onlyjackfrost
  • wwwy3y3

Poem

I'm a little rabbit, hopping through the code,
New guides and routes lighten up my abode.
Popovers and observers dance on the screen,
Each data attribute makes the journey keen.
With carrots of code and a whisker-twitch smile,
I celebrate these changes, mile after mile!
🥕🐇 Happy coding!

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 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.

@fredalai fredalai force-pushed the feature/sql-pairs-ui branch 2 times, most recently from cac40e2 to 0bffbcc Compare March 12, 2025 03:04
@fredalai fredalai force-pushed the feature/sql-pairs-guide branch from e8fbd30 to 37acd9b Compare March 12, 2025 03:53
@fredalai fredalai marked this pull request as ready for review March 12, 2025 04:03
@fredalai fredalai force-pushed the feature/sql-pairs-guide branch from 37acd9b to e01f2b7 Compare March 12, 2025 06:25
Base automatically changed from feature/sql-pairs-ui to main March 13, 2025 02:44
@fredalai fredalai force-pushed the feature/sql-pairs-guide branch from e01f2b7 to dd305db Compare March 13, 2025 02:45
@fredalai fredalai merged commit 323c4db into main Mar 13, 2025
7 of 8 checks passed
@fredalai fredalai deleted the feature/sql-pairs-guide branch March 13, 2025 02:48
Copy link
Copy Markdown
Contributor

@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 (2)
wren-ui/src/components/learning/guide/stories.tsx (2)

367-416: playQuestionSQLPairsGuide flow is straightforward and helpful.

Your approach to presenting an overview popover with relevant images and instructions looks good.
However, at lines 410-411, consider optional chains for more concise code:

- dispatcher?.onDone && dispatcher.onDone();
+ dispatcher?.onDone?.();
🧰 Tools
🪛 Biome (1.9.4)

[error] 410-411: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


418-536: playSaveToKnowledgeGuide effectively uses observers to handle dynamic DOM.

This advanced setup to wait for elements in the viewport is well-crafted.
At lines 466-467, likewise, you could switch to an optional chain:

- dispatcher?.onDone && dispatcher.onDone();
+ dispatcher?.onDone?.();
🧰 Tools
🪛 Biome (1.9.4)

[error] 466-467: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5f61684 and dd305db.

⛔ Files ignored due to path filters (1)
  • wren-ui/public/images/learning/question-sql-pairs.png is excluded by !**/*.png
📒 Files selected for processing (7)
  • wren-ui/src/components/learning/guide/stories.tsx (4 hunks)
  • wren-ui/src/components/learning/guide/utils.ts (1 hunks)
  • wren-ui/src/components/learning/index.tsx (2 hunks)
  • wren-ui/src/components/pages/home/promptThread/AnswerResult.tsx (1 hunks)
  • wren-ui/src/components/pages/home/promptThread/TextBasedAnswer.tsx (1 hunks)
  • wren-ui/src/components/pages/home/promptThread/index.tsx (1 hunks)
  • wren-ui/src/utils/enum/path.ts (1 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
wren-ui/src/components/learning/guide/stories.tsx

[error] 410-411: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


[error] 466-467: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (go)
🔇 Additional comments (10)
wren-ui/src/components/pages/home/promptThread/AnswerResult.tsx (1)

276-276: Excellent addition of data-guideid attribute for interactive guide integration

The data-guideid="save-to-knowledge" attribute has been added to the "Save to Knowledge" button, providing a targeted anchor point for the new Question-SQL Pairs guide functionality. This allows the guide system to specifically identify and highlight this button when instructing users how to save question-SQL pairs.

wren-ui/src/utils/enum/path.ts (1)

4-4: New path enum entry for thread routes

The addition of Thread = '/home/[id]' to the Path enum properly extends the application's routing system to handle dynamic thread paths. This change supports the new Question-SQL Pairs guide by enabling navigation to specific thread instances.

wren-ui/src/components/pages/home/promptThread/TextBasedAnswer.tsx (1)

180-183: Appropriate data-guideid for preview data element

Adding the data-guideid="text-answer-preview-data" attribute to this div enables the guide system to reference and highlight the preview data section when explaining how to interpret query results in the Question-SQL Pairs guide.

wren-ui/src/components/pages/home/promptThread/index.tsx (1)

101-104: Smart conditional guideid implementation for last answer result

The conditional data-guideid attribute that only applies to the last answer in a thread (isLastThreadResponse ? "last-answer-result" : undefined) is a clever approach. This allows the guide to specifically target the most recent answer when demonstrating the Question-SQL Pairs functionality, while ignoring previous answers in the thread.

wren-ui/src/components/learning/guide/utils.ts (1)

25-29: Enum extension looks good.

Adding these enumerations under the new "// knowledge" section cleanly organizes the guide types. No issues found.

wren-ui/src/components/learning/index.tsx (2)

265-317: Router-based guide playback is well-structured.

Using an object to map paths to async functions keeps the code clean and extensible. Consider verifying any partial route matches if sub-routes need to support these guides in the future.

Also applies to: 319-319


335-360: Good job enhancing the Learning UI section.

The collapsing UI pattern for the learning sidebar is readable and helps users see their learning progress. The approach is straightforward and consistent with the rest of the code.

wren-ui/src/components/learning/guide/stories.tsx (3)

5-7: Imports align well with new components.

Bringing in both styled-components and RobotSVG freshens up the guide's visuals effectively.


24-26: Use of nextTick is appropriate.

Delaying guide playback helps ensure UI elements render before steps begin, preventing errors.


53-57: New case for QUESTION_SQL_PAIRS_GUIDE is correct.

This aligns with the newly added enum value and ties in cleanly with the makeStoriesPlayer() architecture.

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.

2 participants