Skip to content

Conversation

@andreashimin
Copy link
Contributor

@andreashimin andreashimin commented Mar 27, 2025

Description

  • minimized when answer tab appear
  • show understanding when intention finished
  • add preload thread to reduce blank page
  • implement show sql pair asking on preparation

Summary by CodeRabbit

  • New Features
    • Enhanced candidate results with integrated SQL pair support, providing updated step indicators and visual cues when a matching SQL pair is used.
    • Introduced a new timeline step that instantly notifies users of SQL pair processing, ensuring quicker feedback.
    • Improved thread creation by preloading data for a smoother navigation experience.
    • Updated result views now offer continuous, clear status feedback during processing.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 27, 2025

Walkthrough

The changes update both the client and server sides as well as UI components to integrate SQL pair support throughout the application. New fields and enum members related to SQL pairs are added to GraphQL types and fragments, while server models, resolvers, and adaptors are enhanced to include SQL pair identifiers and fetching logic. Additionally, UI components are updated to change display logic and prop naming, and a lazy query is introduced in the Home page to preload thread data after creation.

Changes

File(s) Change Summary
wren-ui/src/apollo/client/graphql/__types__.ts, .../graphql/home.generated.ts, .../graphql/home.ts Added optional sqlPair property to result candidate types, a new SQL_PAIR enum member, and updated fragments/queries to include detailed SQL pair subfields.
wren-ui/src/apollo/server/adaptors/wrenAIAdaptor.ts, .../server/models/adaptor.ts, .../server/resolvers/askingResolver.ts, .../server/schema.ts Introduced a new sqlpairId property, added SQL_PAIR enum values for candidate types, and enhanced resolvers/adaptors to retrieve and include SQL pair details in responses.
wren-ui/src/components/pages/home/preparation/PreparationStatus.tsx, .../preparation/PreparationSteps.tsx, .../preparation/index.tsx, .../preparation/step/SQLPairFinished.tsx Modified UI logic to check for SQL pair existence, refactored prop naming from isAnswerFinished to minimized, and added new components (SQLPairTimelineSteps, SQLPairFinished) to display SQL pair status.
wren-ui/src/components/pages/home/prompt/Result.tsx, .../promptThread/AnswerResult.tsx Updated component rendering by replacing a null return with an Understanding component and simplified prop passing by substituting isAnswerFinished with minimized.
wren-ui/src/pages/home/index.tsx Introduced a new lazy query (useThreadLazyQuery) to preload thread data before navigating to the newly created thread.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant HomePage
    participant GraphQLServer
    participant Router
    User->>HomePage: Initiate thread creation
    HomePage->>GraphQLServer: Execute createThread mutation
    GraphQLServer-->>HomePage: Return threadId
    HomePage->>GraphQLServer: Execute lazy query (useThreadLazyQuery)
    GraphQLServer-->>HomePage: Return thread data
    HomePage->>Router: Navigate to thread URL
Loading
sequenceDiagram
    participant Resolver
    participant SQLPairRepository
    Resolver->>SQLPairRepository: findOneBy({ id: sqlpairId })
    SQLPairRepository-->>Resolver: Return SQLPair data
    Resolver-->>Client: Return candidate including sqlPair
Loading

Possibly related PRs

Poem

I'm a rabbit with hops so bright,
Dancing amidst changes in code tonight.
SQL pairs now join the festive spree,
With enums and queries in perfect harmony.
I nibble on bugs and rejoice in delight! 🐰✨

✨ 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 plan to trigger planning for file edits and PR creation.
  • @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.

Copy link
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 (3)
wren-ui/src/components/pages/home/prompt/Result.tsx (1)

162-163: Updated IntentionFinished to maintain understanding feedback

The component now returns the Understanding component instead of null, providing continuous visual feedback to users. This implements the "Understanding Feedback" requirement from the PR objectives.

While functionally correct, consider making the component name more representative of its behavior since "IntentionFinished" now always shows the "Understanding" UI state.

-const IntentionFinished = (props: Props) => {
+// This component handles when the intention is finished but we still want to show the understanding UI
+const IntentionFinishedWithFeedback = (props: Props) => {
wren-ui/src/pages/home/index.tsx (1)

126-128: Effective thread preloading before navigation.

Preloading the thread data before navigation is an excellent optimization that should help prevent blank pages during transitions. The async/await pattern ensures proper sequencing of operations.

However, consider adding error handling for the preloadThread operation:

-      await preloadThread({ variables: { threadId } });
-      router.push(Path.Home + `/${threadId}`);
+      try {
+        await preloadThread({ variables: { threadId } });
+        router.push(Path.Home + `/${threadId}`);
+      } catch (preloadError) {
+        console.error('Thread preload failed:', preloadError);
+        // Still navigate to preserve functionality if preload fails
+        router.push(Path.Home + `/${threadId}`);
+      }
wren-ui/src/components/pages/home/preparation/PreparationSteps.tsx (1)

143-153: New component for SQL pair timeline steps.

The SQLPairTimelineSteps component implements a specialized timeline for SQL pair scenarios, following the same pattern as other timeline variants in this file.

Consider adding a comment above this component to explain its purpose, similar to how you might have documentation for the other timeline components.

+// Timeline steps to show when using a question-SQL pair
function SQLPairTimelineSteps(props: Props) {
  const { className } = props;

  return (
    <Timeline className={className}>
      <Timeline.Item dot={fileDone}>
        <SQLPairFinished />
      </Timeline.Item>
    </Timeline>
  );
}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 75a6233 and 67326e4.

📒 Files selected for processing (14)
  • wren-ui/src/apollo/client/graphql/__types__.ts (1 hunks)
  • wren-ui/src/apollo/client/graphql/home.generated.ts (7 hunks)
  • wren-ui/src/apollo/client/graphql/home.ts (1 hunks)
  • wren-ui/src/apollo/server/adaptors/wrenAIAdaptor.ts (1 hunks)
  • wren-ui/src/apollo/server/models/adaptor.ts (2 hunks)
  • wren-ui/src/apollo/server/resolvers/askingResolver.ts (1 hunks)
  • wren-ui/src/apollo/server/schema.ts (1 hunks)
  • wren-ui/src/components/pages/home/preparation/PreparationStatus.tsx (1 hunks)
  • wren-ui/src/components/pages/home/preparation/PreparationSteps.tsx (5 hunks)
  • wren-ui/src/components/pages/home/preparation/index.tsx (1 hunks)
  • wren-ui/src/components/pages/home/preparation/step/SQLPairFinished.tsx (1 hunks)
  • wren-ui/src/components/pages/home/prompt/Result.tsx (1 hunks)
  • wren-ui/src/components/pages/home/promptThread/AnswerResult.tsx (1 hunks)
  • wren-ui/src/pages/home/index.tsx (3 hunks)
🧰 Additional context used
🧬 Code Definitions (2)
wren-ui/src/pages/home/index.tsx (1)
wren-ui/src/apollo/client/graphql/home.generated.ts (1)
  • useThreadLazyQuery (457-460)
wren-ui/src/apollo/client/graphql/__types__.ts (1)
wren-ui/src/apollo/server/repositories/sqlPairRepository.ts (1)
  • SqlPair (4-11)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (go)
🔇 Additional comments (24)
wren-ui/src/apollo/server/schema.ts (2)

574-574: Added SQL_PAIR enum value to support SQL pair candidates

The new SQL_PAIR enum value correctly extends the ResultCandidateType enum to support SQL pair-based candidates, aligning with the PR objectives to show SQL pair asking functionality.


581-581: Added sqlPair field to ResultCandidate type

This field appropriately extends the ResultCandidate type to include an associated SqlPair object, which is necessary for the system to reference and display SQL pair information in the UI.

wren-ui/src/components/pages/home/preparation/step/SQLPairFinished.tsx (1)

1-16: New component to display SQL pair matching status

The SQLPairFinished component provides clear feedback to the user when a matching SQL pair is found, addressing the PR objective to show SQL pair asking during the preparation phase.

Implementation is simple and effective, using appropriate styling classes for visual consistency.

wren-ui/src/apollo/server/adaptors/wrenAIAdaptor.ts (1)

714-714: Added sqlpairId property to transform method

The addition of the sqlpairId property in the transformAskResult method correctly handles the SQL pair identifier from the candidate object, ensuring it's properly converted to a number type or set to null when not present.

This change works well with the GraphQL schema updates and enables the resolver to fetch the complete SQL pair object when needed.

wren-ui/src/apollo/server/resolvers/askingResolver.ts (2)

651-653: Added SQL pair lookup for enhanced response data

The implementation correctly retrieves the SQL pair object using the repository when a sqlpairId is present, paralleling the existing pattern for view objects.


658-658: Included sqlPair in the response object

This change properly includes the retrieved SQL pair in the returned candidate object, completing the data flow from the adapter through to the GraphQL response.

wren-ui/src/components/pages/home/preparation/PreparationStatus.tsx (1)

59-63: Enhanced finished status logic to include SQL pairs

The condition now accounts for both view presence (showView) and SQL pair presence (showSqlPair), making the UI correctly report "1 step" in either case. This improvement aligns with the PR objectives to show SQL pair asking during preparation.

wren-ui/src/apollo/client/graphql/home.ts (1)

71-76: Added SQL pair support to CommonAskingTask fragment

This addition enables GraphQL queries to fetch SQL pair data (id, question, sql, projectId) from candidates, which is essential for implementing the SQL pair asking functionality mentioned in the PR objectives.

wren-ui/src/apollo/client/graphql/__types__.ts (2)

1089-1089: Added sqlPair field to ResultCandidate type

This type enhancement allows candidates to include SQL pair data, which supports the SQL pair asking feature. The optional nature of the field (using Maybe<>) ensures backward compatibility.


1096-1096: Added SQL_PAIR to ResultCandidateType enum

This enum addition complements the sqlPair field by providing a dedicated type identifier for SQL pair candidates, enabling proper type discrimination in the application logic.

wren-ui/src/apollo/server/models/adaptor.ts (2)

91-96: Well-documented extension of the AskCandidateType enum.

The addition of SQL_PAIR to the AskCandidateType enum is clearly documented with a comment explaining that when this type is used, the sqlpairId will be returned. This is a good practice that helps maintain code clarity.


124-124: Good addition of sqlpairId to match the enum extension.

The addition of the optional sqlpairId property to the AskResult type properly complements the SQL_PAIR enum value added above. This ensures type safety when working with SQL pair candidates.

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

241-242: Improved prop naming with minimized instead of isAnswerFinished.

The change from isAnswerFinished to minimized makes the prop naming more descriptive of its actual purpose - controlling whether the preparation component is minimized. This improvement makes the code more maintainable and self-documenting.

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

102-104: Good implementation of thread preloading with lazy query.

Setting up the lazy query with cache-and-network fetch policy is appropriate for preloading thread data, as it will both check the cache and fetch from the network to ensure data freshness.

wren-ui/src/components/pages/home/preparation/index.tsx (3)

18-18: Good prop renaming for better semantics.

Changing from isAnswerFinished to minimized makes the prop name clearer and more descriptive of its actual function in controlling the component's expanded/collapsed state.


22-23: Clean update of props destructuring.

The props destructuring has been properly updated to match the renamed prop.


28-30: Improved state management with minimized prop.

Using the minimized prop to control the active state of the Preparation component is more intuitive than the previous approach. This change also simplifies the component's logic by directly tying the visual state to the minimized prop.

wren-ui/src/components/pages/home/preparation/PreparationSteps.tsx (5)

10-10: New import for SQL pair support.

The addition of the SQLPairFinished component import supports the new SQL pair functionality mentioned in the PR objectives.


51-51: Prop name change from isAnswerFinished to minimized.

This prop name change aligns with the PR objective to minimize the answer tab when it appears. The new name more clearly represents the state being a UI display property rather than a process state.


64-67: Added SQL pair detection and improved step visibility logic.

The new showSqlPair variable correctly detects the presence of a SQL pair in the first candidate of the asking task. The visibility logic for the preparation steps has been simplified by removing unnecessary conditions.


79-79: Renamed wrapping condition to match new prop name.

The renamed condition from !isAnswerFinished to !minimized maintains consistent naming throughout the component, matching the prop change on line 51.


83-83: Added conditional rendering for SQL pair timeline.

This line implements the SQL pair functionality mentioned in the PR objectives, displaying a specialized timeline when a SQL pair is detected.

wren-ui/src/apollo/client/graphql/home.generated.ts (2)

14-14: Added sqlPair field to GraphQL fragments and queries.

The SQL pair field has been consistently added to all relevant GraphQL fragments and queries. This ensures that SQL pair data is properly fetched and made available throughout the application, supporting the new SQL pair functionality mentioned in the PR objectives.

Also applies to: 16-16, 30-30, 42-42, 49-49, 85-85, 101-101, 174-174, 181-181, 188-188, 196-196


258-263: Added sqlPair object type with required fields.

The sqlPair object includes all necessary fields for proper functioning:

  • id: For unique identification
  • question: The original question associated with the SQL
  • sql: The SQL query itself
  • projectId: To associate with the correct project

These fields align with the expected structure in a well-designed GraphQL schema.

@wwwy3y3 wwwy3y3 merged commit 84cf701 into main Mar 27, 2025
6 checks passed
@wwwy3y3 wwwy3y3 deleted the feat/enhancement branch March 27, 2025 10:44
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.

4 participants