Skip to content

feat(conversation): hide SQL blocks by default based on user preference#393

Open
Yash-1511 wants to merge 1 commit intoRamiAwar:mainfrom
Yash-1511:feat/384-hide-sql-default
Open

feat(conversation): hide SQL blocks by default based on user preference#393
Yash-1511 wants to merge 1 commit intoRamiAwar:mainfrom
Yash-1511:feat/384-hide-sql-default

Conversation

@Yash-1511
Copy link
Copy Markdown

Closes #384

Description

This PR implements the feature to allow users to hide SQL code blocks by default in their conversation view, controlled by a user setting (hide_sql_preference).

Previously, even if the hide_sql_preference was set to true, SQL blocks might not hide as expected. This was because the dialect information, used to identify SQL blocks, was not consistently available, particularly for results of type SQL_QUERY_STRING_RESULT where the backend doesn't currently supply the dialect.

Changes Made

  1. frontend/src/components/Conversation/Message.tsx:

    • The hideSqlPreference (from profile?.hide_sql_preference) is correctly passed to MessageResultRenderer.
  2. frontend/src/components/Conversation/MessageResultRenderer.tsx:

    • The result.type is now passed as a resultType prop to the CodeBlock component. This allows CodeBlock to infer the nature of the content even if dialect is missing.
  3. frontend/src/components/Conversation/CodeBlock.tsx:

    • The CodeBlock component now accepts the resultType prop.
    • The logic to determine if a block should be minimized by default (minimized state) has been updated:
      • It now checks hideSqlByDefault.
      • It considers a block to be SQL if either dialect?.toLowerCase() === "sql" OR if (resultType === "SQL_QUERY_STRING_RESULT" and dialect is undefined). This ensures SQL blocks are correctly identified for hiding even when the backend doesn't explicitly provide the dialect.

How to Test

  1. Enable the preference:
    • Navigate to your user profile settings.
    • Ensure the setting to "Hide SQL by default" (or similar, based on hide_sql_preference) is enabled/checked.
  2. Verify in conversation:
    • Go to a conversation or start a new one that generates SQL query strings.
    • Expected: The SQL code block should appear minimized/hidden by default.
    • You should still be able to manually expand the SQL code block.
  3. Disable the preference:
    • Navigate back to your user profile settings.
    • Ensure the setting to "Hide SQL by default" is disabled/unchecked.
  4. Verify in conversation:
    • Return to the conversation or generate a new SQL query.
    • Expected: The SQL code block should now appear fully visible by default.

@RamiAwar
Copy link
Copy Markdown
Owner

RamiAwar commented Aug 7, 2025

I think I already added this 😁

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.

Hide SQL Blocks by default based on user settings

2 participants