Skip to content

feat: ai flow chat prompt and UX improvements #5942

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 15 commits into from
Jun 24, 2025

Conversation

hugocasa
Copy link
Collaborator

@hugocasa hugocasa commented Jun 13, 2025

Important

Enhances AI flow chat prompts and user experience with new components, improved flow management, and refined AI interaction handling.

  • AI Chat Enhancements:
    • Introduced AIChangesWarningModal.svelte for warning users about pending AI changes.
    • Added ModuleAcceptReject.svelte for accepting or rejecting AI module actions.
    • Updated AIChatManager.svelte.ts to handle AI chat interactions more effectively, including new methods for managing AI changes.
  • Flow Management:
    • Enhanced FlowBuilder.svelte to handle AI changes with new warning and confirmation logic.
    • Updated FlowModuleSchemaMap.svelte and related components to support AI-driven module actions.
    • Improved FlowPreviewButtons.svelte to disable actions when AI changes are pending.
  • UI and UX Improvements:
    • Modified PropPicker.svelte and VirtualItem.svelte to integrate AI module action indicators.
    • Enhanced FlowGraphV2.svelte to better visualize flow changes and AI interactions.
    • Updated utils.ts to include a debouncing utility for improved performance.

This description was created by Ellipsis for 2408c92. You can customize this summary. It will automatically update as commits are pushed.

Copy link

cloudflare-workers-and-pages bot commented Jun 13, 2025

Deploying windmill with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2408c92
Status: ✅  Deploy successful!
Preview URL: https://191115f0.windmill.pages.dev
Branch Preview URL: https://hc-ai-flow-chat-prompt-and-u.windmill.pages.dev

View logs

@hugocasa hugocasa marked this pull request as ready for review June 19, 2025 12:29
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

Caution

Changes requested ❌

Reviewed everything up to b00c55d in 2 minutes and 37 seconds. Click for details.
  • Reviewed 2197 lines of code in 26 files
  • Skipped 0 files when reviewing.
  • Skipped posting 8 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. frontend/src/lib/components/FlowGraphV2.svelte:478
  • Draft comment:
    The attribute --background-color={false} appears in the component properties (line 479). This is unexpected since CSS custom properties typically expect a color value, not a boolean. Please verify if this was intended or remove it if it’s a leftover.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
2. frontend/src/lib/components/VirtualItem.svelte:57
  • Draft comment:
    The derived value for the AI module action is determined using the component's label (line 57). Using a label may result in collisions if it isn’t a unique identifier. Consider using a dedicated unique ID (for example, a stored module ID) for fetching the AI action.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
3. frontend/src/lib/components/propertyPicker/PropPicker.svelte:46
  • Draft comment:
    The reactive assignment $: $pickablePropertiesFiltered = pickableProperties directly sets a derived store from props. Directly assigning to a derived store can lead to unexpected update behavior. Consider refactoring this logic so that the derived store is computed from pickableProperties without direct reassignment.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
4. frontend/src/lib/components/flows/map/FlowModuleSchemaMap.svelte:79
  • Draft comment:
    The function insertNewModuleAtIndex uses push(history, flowStore.val) to save the current state to history (line 79). Be cautious that pushing the entire flow state on every insertion might lead to performance or memory issues in very large flows. Consider limiting the history size or performing a differential save if feasible.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
5. frontend/src/lib/components/copilot/chat/flow/core.ts:463
  • Draft comment:
    Typo: The variable name 'setFlowInputsSchemaSchema' seems redundant. Should it be 'setFlowInputsSchema'? Please verify and correct if necessary.
  • Reason this comment was not posted:
    Comment was on unchanged code.
6. frontend/src/lib/components/flows/map/FlowErrorHandlerItem.svelte:53
  • Draft comment:
    Typographical note: The svelte-ignore directive here uses underscores (a11y_click_events_have_key_events). Typically, these directives use hyphens (e.g., a11y-click-events-have-key-events). Please confirm if the change is intentional.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 10% vs. threshold = 50% This appears to be a deliberate change from hyphens to underscores in the svelte-ignore directives. Since this is a Svelte-specific syntax, we should be very confident about whether this is actually an issue before keeping the comment. Without knowing the Svelte compiler's requirements or preferences for these directives, we can't be certain this is actually a problem. The code likely still works with either syntax. I might be underestimating the importance of consistent directive syntax across the codebase. There could be linting rules or team conventions I'm not aware of. However, per the review rules, we should not keep comments unless we have strong evidence they are correct. This seems more like a style preference question than a clear issue. Delete this comment as it's speculative and we don't have strong evidence that the underscore syntax is actually incorrect.
7. frontend/src/lib/components/flows/map/FlowErrorHandlerItem.svelte:54
  • Draft comment:
    Typographical note: The svelte-ignore directive here uses underscores (a11y_no_static_element_interactions). Typically, these directives use hyphens (e.g., a11y-no-static-element-interactions). Please confirm if this change was intentional.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 10% vs. threshold = 50% This is a change in the diff, but it's not clear if this is actually an issue. The comment is speculative, asking to "confirm if this change was intentional" rather than definitively stating it's wrong. Without knowing Svelte's official standards or if this would cause any actual problems, we shouldn't make assumptions. I might be missing official Svelte documentation that specifies the correct format. The change could potentially break something. Even if there is a preferred format, this is likely something that would be caught by linting if it was actually problematic. The comment is asking for confirmation rather than stating a definitive issue. Delete this comment as it's speculative and asks for confirmation rather than pointing out a definitive issue. If this was problematic, it would likely be caught by build tools.
8. frontend/src/lib/components/flows/map/VirtualItem.svelte:77
  • Draft comment:
    The class attribute on line 77 appears to be incomplete and possibly contains a typo. It currently reads: 'class="flex flex-row gap-1 justify-between {center'. It looks like there might be missing closing braces or additional text to properly finish the interpolation. Please verify and fix the intended class string.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.

Workflow ID: wflow_XPLRW9RbgbSw3nCr

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

@rubenfiszel
Copy link
Contributor

/ai review the PR please

Copy link
Contributor

claude bot commented Jun 19, 2025

Claude finished @rubenfiszel's task —— View job


PR Code Review for AI Flow Chat Enhancements ✅

Completed comprehensive review of the PR for code quality, bugs, security issues, and best practices.

Todo List

  • Analyze PR scope and key changes
  • Review new AI-related components (AIChangesWarningModal, ModuleAcceptReject)
  • Review core AI flow chat functionality changes
  • Review UI/UX improvements and tool interaction changes
  • Check for security issues and performance problems
  • Cross-reference with existing ellipsis-dev review comments
  • Provide comprehensive review feedback

Review Summary

This PR introduces significant improvements to the AI flow chat functionality with better change management, diff visualization, and user experience. I've identified several issues that should be addressed:

Positive Aspects

  1. Excellent Architecture: The new AI changes management system is well-designed with clear separation of concerns
  2. Good UX: The accept/reject pattern for AI changes provides clear user control
  3. Proper Integration: The ModuleAcceptReject component is cleanly integrated into existing flow components
  4. Diff Visualization: The diff drawer integration enhances the review process for AI changes

⚠️ Issues Found

Critical Issues

  1. Typo in System Prompt (frontend/src/lib/components/copilot/chat/flow/core.ts:679)

    // Current (incorrect):
    Both modules only support a script or rawscript step. You cannot nest modules using foorloop/branchone/branchall.
    
    // Should be:
    Both modules only support a script or rawscript step. You cannot nest modules using forloop/branchone/branchall.
  2. Missing Word in System Prompt (frontend/src/lib/components/copilot/chat/flow/core.ts:683)

    // Current (incomplete):
    If the user needs a resource as flow input, you should the property type in the schema...
    
    // Should be:
    If the user needs a resource as flow input, you should set the property type in the schema...

Code Quality Issues

  1. Event Binding Inconsistency (frontend/src/lib/components/flows/map/FlowErrorHandlerItem.svelte:110)
    The event handler uses onclick instead of Svelte's standard on:click:

    <!-- Current: -->
    onclick={() => {
    
    <!-- Should be (for consistency): -->
    on:click={() => {
  2. Potential Performance Issue (frontend/src/lib/components/FlowAIChat.svelte:488-494)
    The $effect that cleans up affectedModules could be optimized. Consider debouncing or using a more efficient cleanup mechanism for large flows:

    $effect(() => {
      // This runs on every module change - could be expensive
      const untrackedAffectedModules = untrack(() => affectedModules)
      for (const id of Object.keys(untrackedAffectedModules)) {
        if (!allModuleIds.includes(id)) {
          delete affectedModules[id]
        }
      }
    })

Security/Robustness Issues

  1. Error Handling in Tool Processing (frontend/src/lib/components/copilot/chat/shared.ts:74-78)
    The current error handling masks important details:
    } catch (err) {
      console.error(err)
      result = 'Error while calling tool, MUST tell the user to check the browser console for more details...'
    }
    Consider adding more specific error context while still being secure.

Code Organization Issues

  1. Module Variable Name (frontend/src/lib/components/copilot/chat/flow/core.ts:463)
    There appears to be a variable name issue. The ellipsis review mentioned setFlowInputsSchemaSchema - this should be verified and corrected if needed.

🔧 Recommendations

  1. Fix the typos in the system prompts immediately as they affect AI behavior
  2. Standardize event handling - decide whether to use on:click or onclick consistently
  3. Add error boundaries around AI change operations to prevent crashes
  4. Consider adding loading states for longer AI operations
  5. Add unit tests for the new AI change management logic
  6. Document the AI change workflow for other developers

🎯 Code Quality Score: 7.5/10

The code is well-structured and functional, but the typos and inconsistencies prevent it from being excellent. The architecture choices are sound and the feature implementation is comprehensive.

Minor Suggestions

  • Consider extracting magic strings like 'Input', 'preprocessor', 'failure' into constants
  • The aiModuleActionToBgColor function could benefit from TypeScript's satisfies operator for better type safety
  • Consider adding JSDoc comments to the new public interfaces

This is a solid PR that significantly enhances the AI flow chat experience. Once the identified issues are addressed, it will be ready for merge.


hugocasa and others added 2 commits June 19, 2025 15:30
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

Important

Looks good to me! 👍

Reviewed 4af307c in 49 seconds. Click for details.
  • Reviewed 13 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. frontend/src/lib/components/copilot/chat/flow/core.ts:683
  • Draft comment:
    Typo fix: Inserted missing 'set' to clarify the instruction ('should set the property type').
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50% This comment is purely informative, pointing out a typo fix. It doesn't provide a suggestion or ask for clarification on the code itself. It doesn't align with the rules for useful comments.

Workflow ID: wflow_uwYk3irieEZyWRUX

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

Important

Looks good to me! 👍

Reviewed dc84154 in 1 minute and 33 seconds. Click for details.
  • Reviewed 59 lines of code in 3 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. frontend/src/lib/components/copilot/chat/flow/FlowAIChat.svelte:237
  • Draft comment:
    Added the 'summary' property to inlineScript. Ensure that step.summary is always defined and validated upstream since it's now required.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50% The comment is asking the author to ensure that a property is defined and validated upstream. This falls under the rule of not asking the author to ensure behavior is intended or tested. The comment does not provide a specific suggestion or point out a specific issue with the code.
2. frontend/src/lib/components/copilot/chat/flow/core.ts:83
  • Draft comment:
    Updated the summary description to specify ‘3-5 words’. Consider enforcing a maximum length if appropriate.
  • Reason this comment was not posted:
    Comment looked like it was already resolved.
3. frontend/src/lib/components/flows/map/FlowModuleSchemaMap.svelte:102
  • Draft comment:
    Changed destructuring to include 'summary' from inlineScript and pass it to createInlineScriptModule. Verify that inlineScript always provides a valid summary.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50% The comment is asking the PR author to verify that inlineScript always provides a valid summary. This falls under the rule of not asking the author to ensure behavior is intended or to double-check things. Therefore, this comment should be removed.

Workflow ID: wflow_v9UgCdg3bvQjrsjR

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

@hugocasa hugocasa force-pushed the hc/ai-flow-chat-prompt-and-ux-improvements branch from dc84154 to 2dc8099 Compare June 23, 2025 08:54
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

Caution

Changes requested ❌

Reviewed 2dc8099 in 1 minute and 44 seconds. Click for details.
  • Reviewed 149 lines of code in 3 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. frontend/src/lib/components/FlowPreviewContent.svelte:281
  • Draft comment:
    Good improvement: the additional check using aiChatManager.flowAiChatHelpers ensures that removed modules don’t trigger a restart. Consider extracting the condition into a well‐named variable for clarity.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
2. frontend/src/lib/components/flows/header/FlowPreviewButtons.svelte:55
  • Draft comment:
    The derived store 'upToDisabled' now also checks if getModuleAction(selectedId) returns 'removed'. This guards against performing up-to tests on removed modules. The pattern is consistent, though consider adding inline comments if not obvious to future maintainers.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None

Workflow ID: wflow_n0q8FNM47CNKdWqp

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

<div
class={twMerge('flex flex-col w-full', deletable && action === 'removed' ? 'opacity-50' : '')}
>
{deletable}
Copy link
Contributor

Choose a reason for hiding this comment

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

The modification now conditions the opacity style on 'deletable && action === "removed"'. However, the literal {deletable} is output inside the div, which may unintentionally render a boolean value. Likely a leftover debugging statement.

Suggested change
{deletable}

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

Important

Looks good to me! 👍

Reviewed fbb3ac1 in 2 minutes and 36 seconds. Click for details.
  • Reviewed 304 lines of code in 9 files
  • Skipped 0 files when reviewing.
  • Skipped posting 5 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. frontend/src/lib/utils.ts:711
  • Draft comment:
    Possible typo in the pluralize function: the template literal for the customPlural branch has an extra '}' which might cause an incorrect output.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
2. frontend/src/lib/utils.ts:465
  • Draft comment:
    The else clause in removeKeysWithEmptyValues is redundant. The arrow function uses ': {}' which has no effect. Consider removing it for clarity.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
3. frontend/src/lib/components/ModuleTest.svelte:110
  • Draft comment:
    Avoid using the non-null assertion (!) on testModulesState[modId]. Ensure proper initialization to prevent runtime errors if the state is undefined.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 10% vs. threshold = 50% The code uses the nullish coalescing operator to ensure testModulesState[modId] exists with default values. The non-null assertion is actually safe here because we just initialized the object. The suggestion to remove it doesn't add any safety since we know the object exists. The original code is actually fine. Could there be a race condition where testModulesState[modId] becomes null between lines 110 and 112? Could there be other code modifying this state? No race condition is possible here because this is all synchronous code within a single onMount callback. The assignment and access happen atomically. The comment should be deleted because the non-null assertion is actually safe here - we just initialized the object with default values one line above.
4. frontend/src/lib/components/ResourcePicker.svelte:47
  • Draft comment:
    Consider removing or disabling debug console.log statements before production; they may clutter output.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
5. frontend/src/lib/components/apps/editor/settingsPanel/DecisionTreeGraphEditor.svelte:102
  • Draft comment:
    The debounced function 'debouncedNodes' is used to update renderCount and refresh nodes. Consider renaming it to better reflect its purpose (e.g. 'debounceRenderUpdate') for improved code clarity.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 20% vs. threshold = 50% The current name 'debouncedNodes' is somewhat descriptive as it relates to debouncing node updates. While 'debounceRenderUpdate' might be marginally more descriptive, the benefit is minimal. The function is simple, local in scope, and its purpose is clear from the implementation. This feels like a nitpick that doesn't meaningfully improve code quality. The suggested name might be technically more accurate since it updates both nodes and renderCount. The current name only captures part of what the function does. While technically true, the current name is sufficient for its context and the change would provide minimal value. The function is small and its purpose is clear from its implementation. Delete this comment as it suggests a minor rename that doesn't meaningfully improve code clarity or maintainability.

Workflow ID: wflow_p7C3AlsidU6Mv8nD

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

Important

Looks good to me! 👍

Reviewed 2408c92 in 41 seconds. Click for details.
  • Reviewed 27 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. frontend/src/lib/components/Editor.svelte:1522
  • Draft comment:
    Good cleanup: disposing aiChatEditorHandler with optional chaining. Verify that 'clear()' is the intended method for resource cleanup.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
2. frontend/src/lib/components/InputTransformForm.svelte:338
  • Draft comment:
    Optional chaining (arg?.value and arg?.expr) protects against undefined arg. This reactive statement now safely tracks changes.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None

Workflow ID: wflow_G49kPggCZykXrGpt

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

@rubenfiszel rubenfiszel merged commit 5722014 into main Jun 24, 2025
7 checks passed
@rubenfiszel rubenfiszel deleted the hc/ai-flow-chat-prompt-and-ux-improvements branch June 24, 2025 07:29
@github-actions github-actions bot locked and limited conversation to collaborators Jun 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants