Skip to content

Hotfix progress template selector#1098

Merged
duckduckhero merged 9 commits intomainfrom
hotfix-progress-template-selector
Jul 7, 2025
Merged

Hotfix progress template selector#1098
duckduckhero merged 9 commits intomainfrom
hotfix-progress-template-selector

Conversation

@duckduckhero
Copy link
Contributor

No description provided.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 7, 2025

📝 Walkthrough

Walkthrough

The changes remove the invalidation of the "llm-connection" query from the template selection logic and update the enhancement mutation hook to freshly determine the LLM connection status before mutation. The hook now uses the most up-to-date LLM connection type for all conditional logic and progress reporting.

Changes

File(s) Change Summary
apps/desktop/src/components/editor-area/floating-button.tsx Removed invalidation of the "llm-connection" query from the template selection handler.
apps/desktop/src/components/editor-area/index.tsx Modified useEnhanceMutation to freshly determine and use the LLM connection type before mutation, updating related conditional logic.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant FloatingButton
    participant EditorArea
    participant QueryClient
    participant LLMConnection

    User->>FloatingButton: Selects template
    FloatingButton->>EditorArea: Calls handleEnhanceWithTemplate(templateId)
    EditorArea->>QueryClient: Invalidate "llm-connection" query
    Note right of QueryClient: (Step removed in floating-button)
    EditorArea->>LLMConnection: Fetch current LLM connection type
    LLMConnection-->>EditorArea: Returns connection type ("HyprLocal" or other)
    EditorArea->>EditorArea: Update actualIsLocalLlm state
    EditorArea->>LLMConnection: Proceed with enhancement mutation using fresh status
Loading

Possibly related PRs

  • Fixed refetch logic  #1095: Reversed the addition of "llm-connection" query invalidation in floating-button.tsx, directly related to the main PR's removal of that logic.
  • Template Selector Merge  #1089: Added template selection UI and related callbacks, including LLM connection status integration in the same files affected by this PR.
✨ 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:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in 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.

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: 1

🧹 Nitpick comments (4)
apps/desktop/src/components/editor-area/index.tsx (4)

295-296: Consider architectural implications of duplicate state management.

Maintaining actualIsLocalLlm state alongside the existing llmConnectionQuery creates duplicate sources of truth. This pattern can lead to synchronization issues and increased complexity.

Consider whether the fresh fetching approach is necessary, or if there's a more elegant solution using existing React Query patterns.


420-421: Revise comment to explain "why" instead of "what".

The comment explains what the code does rather than why it's necessary, which violates the coding guidelines.

- // Use fresh value for tools
+ // Ensure tools configuration matches current LLM connection type

434-435: Revise comment to explain "why" instead of "what".

The comment explains what the code does rather than why it's necessary, which violates the coding guidelines.

- // Use fresh value for provider options  
+ // Ensure provider options match current LLM connection type

456-457: Revise comment to explain "why" instead of "what".

The comment explains what the code does rather than why it's necessary, which violates the coding guidelines.

- // Use fresh value for progress updates
+ // Progress updates only available for local LLM connections
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d5872ba and c30d803.

📒 Files selected for processing (2)
  • apps/desktop/src/components/editor-area/floating-button.tsx (0 hunks)
  • apps/desktop/src/components/editor-area/index.tsx (7 hunks)
💤 Files with no reviewable changes (1)
  • apps/desktop/src/components/editor-area/floating-button.tsx
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{js,ts,tsx,rs}`: 1. No error handling. 2. No unused imports, variables, or functions. 3. For comments, keep it minimal. It should be about "Why", not "What".

**/*.{js,ts,tsx,rs}: 1. No error handling.
2. No unused imports, variables, or functions.
3. For comments, keep it minimal. It should be about "Why", not "What".

⚙️ Source: CodeRabbit Configuration File

List of files the instruction was applied to:

  • apps/desktop/src/components/editor-area/index.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: ci (macos, macos-latest)
  • GitHub Check: ci (windows, windows-latest)
🔇 Additional comments (2)
apps/desktop/src/components/editor-area/index.tsx (2)

481-486: Good consistency using internal state.

Using actualIsLocalLlm in the callbacks ensures consistency with the value determined during mutation execution, which is the correct approach.


497-497: Correct conditional return logic.

The conditional return of progress based on actualIsLocalLlm ensures that progress is only exposed when relevant (local LLM connections), which is the appropriate behavior.

Comment on lines +321 to +329
await queryClient.invalidateQueries({ queryKey: ["llm-connection"] });
await new Promise(resolve => setTimeout(resolve, 100));

const { type } = await connectorCommands.getLlmConnection();
const freshIsLocalLlm = type === "HyprLocal";

setActualIsLocalLlm(freshIsLocalLlm);

if (freshIsLocalLlm) {
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Address hardcoded timeout and consider architectural improvements.

The hardcoded 100ms timeout is arbitrary and may not be sufficient for query invalidation to complete. Additionally, invalidating queries inside mutation functions is generally an anti-pattern that can lead to race conditions.

Consider refactoring to:

  1. Use a more deterministic approach than hardcoded timeouts
  2. Move query invalidation to onSuccess/onError callbacks
  3. Add error handling for the fresh LLM connection fetch
- await queryClient.invalidateQueries({ queryKey: ["llm-connection"] });
- await new Promise(resolve => setTimeout(resolve, 100));
- 
- const { type } = await connectorCommands.getLlmConnection();
- const freshIsLocalLlm = type === "HyprLocal";
- 
- setActualIsLocalLlm(freshIsLocalLlm);
+ try {
+   const { type } = await connectorCommands.getLlmConnection();
+   const freshIsLocalLlm = type === "HyprLocal";
+   setActualIsLocalLlm(freshIsLocalLlm);
+ } catch (error) {
+   console.error("Failed to fetch LLM connection:", error);
+   // Fallback to existing state
+ }

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In apps/desktop/src/components/editor-area/index.tsx around lines 321 to 329,
replace the hardcoded 100ms timeout after queryClient.invalidateQueries with a
more deterministic approach such as awaiting the query invalidation promise if
available or restructuring the logic to avoid relying on delays. Move the query
invalidation call out of the mutation function into appropriate onSuccess or
onError callbacks to prevent race conditions. Additionally, add error handling
around the call to connectorCommands.getLlmConnection to gracefully handle
failures and avoid unhandled exceptions.

@duckduckhero duckduckhero merged commit a453748 into main Jul 7, 2025
5 checks passed
@ComputelessComputer ComputelessComputer deleted the hotfix-progress-template-selector branch December 14, 2025 15:21
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.

1 participant