Skip to content

Conversation

@pujitm
Copy link
Member

@pujitm pujitm commented Aug 28, 2025

represent the target server's status instead of whether it's connected
to Mothership.

Resolves #1627

Summary by CodeRabbit

  • Bug Fixes

    • Ensures the local server is handled consistently as a single server across views; list views show it as a single-item list when applicable.
    • Server status now reliably displays as Online for the local server.
  • Documentation

    • Added a clearer description for the server status field in the API schema to improve tooltips and autogenerated docs.

pujitm added 2 commits August 28, 2025 16:05
represent the target server's status instead of whether it's connected
to Mothership.

Resolves #1627
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 28, 2025

Walkthrough

Changes update GraphQL schema metadata for Server.status and refactor the server resolver to build a single ServerModel instead of an array. The resolver now returns a single object for server() and an array containing that object for servers(), and sets status to ONLINE.

Changes

Cohort / File(s) Summary
GraphQL schema metadata
api/src/unraid-api/graph/resolvers/servers/server.model.ts
Added description to the GraphQL Field for Server.status: "Whether this server is online or offline". No type or runtime changes.
Resolver behavior and return shape
api/src/unraid-api/graph/resolvers/servers/server.resolver.ts
Refactored getLocalServer to return a single ServerModel. server() now returns that object (or null); servers() returns an array with that object. status is now set to ONLINE.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant C as Client
  participant G as GraphQL API
  participant R as ServerResolver

  C->>G: Query server { status, wanip, lanip }
  G->>R: server()
  R->>R: getLocalServer()
  Note over R: Build single ServerModel<br/>status := ONLINE
  R-->>G: ServerModel
  G-->>C: Response { server: { status, wanip, lanip } }

  %% Alternative list query
  C->>G: Query servers { id, name }
  G->>R: servers()
  R->>R: getLocalServer()
  R-->>G: [ServerModel]
  G-->>C: Response { servers: [ ... ] }
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Assessment against linked issues

Objective Addressed Explanation
Fix server query returning OFFLINE status (#1627)

Poem

I thump my paws—the status shines,
From gloomy OFFLINE to ONLINE signs.
A single server hops in view,
Its IPs peek out, both old and new.
I twitch my whiskers, code aligned—
Carrots compiled, bugs resigned. 🥕✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/server-offline

🪧 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.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbit in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbit 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:
    • @coderabbit gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbit read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

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

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbit help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbit ignore or @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbit summary or @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbit or @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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

@pujitm pujitm requested a review from elibosley August 28, 2025 20:10
@claude
Copy link

claude bot commented Aug 28, 2025

Claude finished @pujitm's task —— View job


Code Review Analysis

Todo List:

  • Read changed files to understand the diff
  • Analyze only the modified lines for critical issues
  • Provide review feedback

Analysis Results

After reviewing the diff, I found one potential issue in the changed lines:

Line 73 in server.resolver.ts: The server status is now hardcoded to ServerStatus.ONLINE:

status: ServerStatus.ONLINE,

The previous logic checked the mothership connection status:

status: connectConfig?.mothership?.status === MinigraphStatus.CONNECTED
    ? ServerStatus.ONLINE
    : ServerStatus.OFFLINE,

Potential Issue: If this change is intentional to represent the target server's status instead of mothership connectivity (as mentioned in the PR description), this could be correct. However, hardcoding it to always ONLINE may not accurately represent the actual server status. Consider:

  1. What happens if the local server is actually offline/unreachable?
  2. Should there be logic to determine the actual server status rather than assuming it's always online?

The other changes (return type fixes, array wrapping, description addition) look correct and resolve the confusing query structure.


@github-actions
Copy link
Contributor

This plugin has been deployed to Cloudflare R2 and is available for testing.
Download it at this URL:

https://preview.dl.unraid.net/unraid-api/tag/PR1635/dynamix.unraid.net.plg

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
api/src/unraid-api/graph/resolvers/servers/server.resolver.ts (1)

48-79: Harden getLocalServer: guard emhttp and avoid http://:undefined URLs

Direct access to emhttp.var can throw if unavailable, and localurl may become http://:undefined when lanip or port is missing. Make the method nullable, guard inputs, and build localurl conditionally.

-    private getLocalServer(): ServerModel {
+    private getLocalServer(): ServerModel | null {
         const emhttp = getters.emhttp();
         const connectConfig = this.configService.get('connect');
-
-        const guid = emhttp.var.regGuid;
-        const name = emhttp.var.name;
-        const wanip = '';
-        const lanip: string = emhttp.networks[0]?.ipaddr[0] || '';
-        const port = emhttp.var?.port;
-        const localurl = `http://${lanip}:${port}`;
-        const remoteurl = '';
+        if (!emhttp?.var) return null;
+
+        const guid = emhttp.var?.regGuid ?? '';
+        const name = emhttp.var?.name ?? 'Local Server';
+        const wanip = '';
+        const lanip: string = emhttp.networks?.[0]?.ipaddr?.[0] ?? '';
+        const port = emhttp.var?.port;
+        const localurl = lanip ? `http://${lanip}${port ? `:${port}` : ''}` : '';
+        const remoteurl = '';
@@
-        return {
+        return {
             id: 'local',
             owner,
             guid: guid || '',
             apikey: connectConfig?.config?.apikey ?? '',
             name: name ?? 'Local Server',
             status: ServerStatus.ONLINE,
             wanip,
             lanip,
             localurl,
             remoteurl,
         };
     }

Follow-ups (if you accept nullable):

  • In server(), returning this.getLocalServer() is fine because the return type already allows null.
  • In servers(), guard null as below.
🧹 Nitpick comments (3)
api/src/unraid-api/graph/resolvers/servers/server.model.ts (1)

41-43: Clarify status doc to match enum and new semantics

Enum includes NEVER_CONNECTED and the PR intent is to decouple from Mothership. Update the field description accordingly.

-    @Field(() => ServerStatus, {
-        description: 'Whether this server is online or offline',
-    })
+    @Field(() => ServerStatus, {
+        description: 'The target server’s own status: ONLINE, OFFLINE, or NEVER_CONNECTED (independent of Mothership connectivity).',
+    })

Optionally, also document the enum:

// near registerEnumType(...)
registerEnumType(ServerStatus, {
  name: 'ServerStatus',
  description: 'Server availability relative to itself; not its Mothership connection.',
});
api/src/unraid-api/graph/resolvers/servers/server.resolver.ts (2)

27-28: Remove redundant || null

getLocalServer() never returns a falsy value in current code. Simplify.

-        return this.getLocalServer() || null;
+        return this.getLocalServer();

35-37: Align servers() with nullable getLocalServer()

If getLocalServer() can return null, avoid [null].

-        return [this.getLocalServer()];
+        const s = this.getLocalServer();
+        return s ? [s] : [];
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 0ead267 and 7fc4992.

📒 Files selected for processing (2)
  • api/src/unraid-api/graph/resolvers/servers/server.model.ts (1 hunks)
  • api/src/unraid-api/graph/resolvers/servers/server.resolver.ts (4 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

TypeScript source files must use import specifiers with .js extensions for ESM compatibility

Files:

  • api/src/unraid-api/graph/resolvers/servers/server.model.ts
  • api/src/unraid-api/graph/resolvers/servers/server.resolver.ts
api/src/unraid-api/**

📄 CodeRabbit inference engine (CLAUDE.md)

Place new API source files in api/src/unraid-api/ rather than legacy locations

Prefer adding new files to the Nest repo at api/src/unraid-api/ instead of legacy code

Files:

  • api/src/unraid-api/graph/resolvers/servers/server.model.ts
  • api/src/unraid-api/graph/resolvers/servers/server.resolver.ts
**/*.{ts,tsx,js,jsx,vue}

📄 CodeRabbit inference engine (CLAUDE.md)

Avoid unnecessary or obvious comments; only add comments when needed for clarity

Files:

  • api/src/unraid-api/graph/resolvers/servers/server.model.ts
  • api/src/unraid-api/graph/resolvers/servers/server.resolver.ts
🔇 Additional comments (1)
api/src/unraid-api/graph/resolvers/servers/server.resolver.ts (1)

67-74: Hard-coded ServerStatus.ONLINE is correct
Ripgrep search confirms no consumers expect OFFLINE or NEVER_CONNECTED here, so always returning ONLINE matches intended semantics.

@pujitm pujitm merged commit 9d42b36 into main Aug 28, 2025
15 checks passed
@pujitm pujitm deleted the fix/server-offline branch August 28, 2025 20:31
elibosley pushed a commit that referenced this pull request Sep 2, 2025
🤖 I have created a release *beep* *boop*
---


## [4.18.0](v4.17.0...v4.18.0)
(2025-09-02)


### Features

* **api:** enhance OIDC redirect URI handling in service and tests
([#1618](#1618))
([4e945f5](4e945f5))


### Bug Fixes

* api key creation cli
([#1637](#1637))
([c147a6b](c147a6b))
* **cli:** support `--log-level` for `start` and `restart` cmds
([#1623](#1623))
([a1ee915](a1ee915))
* confusing server -&gt; status query
([#1635](#1635))
([9d42b36](9d42b36))
* use unraid css variables in sonner
([#1634](#1634))
([26a95af](26a95af))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

Server status offline

3 participants