Skip to content

Conversation

@acon96
Copy link
Contributor

@acon96 acon96 commented Jun 19, 2025

This tweaks the models page in the UI to allow you to load a model without navigating away from the current page.

Summary by CodeRabbit

  • New Features
    • Added a "Load" button in the models table, allowing users to load stopped models directly from the interface.
  • Style
    • Updated button hover behavior so the cursor changes to a pointer, providing a clearer interactive cue.
  • User Interface
    • Model names now open upstream URLs in a new browser tab for easier access.

@coderabbitai
Copy link

coderabbitai bot commented Jun 19, 2025

Walkthrough

A new asynchronous loadModel function was added to the API context and integrated into the models page. The models table now includes an additional column with a "Load" button that triggers this function for models in the "stopped" state. A CSS rule was added for button hover interactivity.

Changes

File(s) Change Summary
ui/src/contexts/APIProvider.tsx Added loadModel async function to context and its interface; exposes it to context consumers.
ui/src/pages/Models.tsx Integrated loadModel into the models page; added "Load" button enabled for stopped models; changed link target to _blank.
ui/src/index.css Added .btn:hover rule to set cursor to pointer on button hover.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ModelsPage
    participant APIContext
    participant Backend

    User->>ModelsPage: Clicks "Load" button
    ModelsPage->>APIContext: Calls loadModel(modelId)
    APIContext->>Backend: GET /upstream/{modelId}/
    Backend-->>APIContext: Response (success or error)
    APIContext-->>ModelsPage: Resolves or throws error
    ModelsPage-->>User: (Optional) Updates UI or shows error
Loading

📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1f38eab and 5946820.

📒 Files selected for processing (1)
  • ui/src/pages/Models.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • ui/src/pages/Models.tsx
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: run-tests
  • GitHub Check: run-tests
✨ 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.
    • Explain this complex logic.
    • 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 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

@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 (2)
ui/src/contexts/APIProvider.tsx (1)

143-155: Consider using POST method for model loading operation.

The loadModel function uses a GET request, which is typically for retrieving data rather than triggering actions. Loading a model is a state-changing operation that would conventionally use POST or PUT method.

Consider changing to POST method if the API supports it:

-      const response = await fetch(`/upstream/${model}/`, {
-        method: "GET",
+      const response = await fetch(`/upstream/${model}/load`, {
+        method: "POST",
       });
ui/src/pages/Models.tsx (1)

6-6: Consider adding loading state for individual models.

Similar to how isUnloading state is managed for "Unload All Models", consider adding loading state for individual model operations to provide better user feedback.

You could track loading state per model:

+  const [loadingModels, setLoadingModels] = useState<Set<string>>(new Set());

Then update the button to show loading state and disable during loading.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a6b2e93 and 1f38eab.

📒 Files selected for processing (3)
  • ui/src/contexts/APIProvider.tsx (3 hunks)
  • ui/src/index.css (1 hunks)
  • ui/src/pages/Models.tsx (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: run-tests
  • GitHub Check: run-tests
🔇 Additional comments (3)
ui/src/contexts/APIProvider.tsx (1)

15-15: LGTM! Proper context integration.

The loadModel function is correctly added to the interface, context value, and dependency array. The implementation follows established patterns in the codebase.

Also applies to: 162-162, 173-173

ui/src/index.css (1)

146-148: Good UX enhancement.

Adding pointer cursor on button hover provides clear visual feedback for interactive elements, enhancing the user experience with the new Load button functionality.

ui/src/pages/Models.tsx (1)

46-47: Well-structured table updates.

The new table columns are logically organized:

  • "Upstream" column provides direct access to model endpoints
  • "Actions" column consolidates model operations
  • Load button is properly disabled for non-stopped models
  • Model name simplification improves clarity

Also applies to: 55-64

</a>
</td>
<td className="p-2">
<button className="btn btn--sm" disabled={model.state !== "stopped"} onClick={() => loadModel(model.id)}>Load</button>
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add error handling for model loading.

The Load button calls loadModel without error handling, which could result in unhandled promise rejections if the API call fails. Consider adding try-catch with user feedback.

-                      <button className="btn btn--sm" disabled={model.state !== "stopped"} onClick={() => loadModel(model.id)}>Load</button>
+                      <button className="btn btn--sm" disabled={model.state !== "stopped"} onClick={async () => {
+                        try {
+                          await loadModel(model.id);
+                          // Optional: Add success feedback
+                        } catch (error) {
+                          console.error('Failed to load model:', error);
+                          // Optional: Add user-visible error feedback
+                        }
+                      }}>Load</button>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<button className="btn btn--sm" disabled={model.state !== "stopped"} onClick={() => loadModel(model.id)}>Load</button>
<button
className="btn btn--sm"
disabled={model.state !== "stopped"}
onClick={async () => {
try {
await loadModel(model.id);
// Optional: Add success feedback
} catch (error) {
console.error('Failed to load model:', error);
// Optional: Add user-visible error feedback
}
}}
>
Load
</button>
🤖 Prompt for AI Agents
In ui/src/pages/Models.tsx at line 63, the Load button's onClick handler calls
loadModel without error handling, risking unhandled promise rejections. Wrap the
loadModel call in an async function with a try-catch block, and in the catch
block provide user feedback such as an alert or notification indicating the
loading failure.

@mostlygeek
Copy link
Owner

Got a screenshot?

The model table looks OK on mobile and I wonder if this makes it too wide.

@acon96
Copy link
Contributor Author

acon96 commented Jun 19, 2025

desktop
mobile

Tweaked the table for mobile.

@mostlygeek
Copy link
Owner

looks great!

@mostlygeek mostlygeek merged commit 756193d into mostlygeek:main Jun 19, 2025
3 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Nov 19, 2025
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