Skip to content

Add explicit connection-state tracking to the ZeuZ Python Node to auto connect browser#702

Open
ToWhiD073 wants to merge 3 commits into
devfrom
task-3008-node-auto-connect-to-server
Open

Add explicit connection-state tracking to the ZeuZ Python Node to auto connect browser#702
ToWhiD073 wants to merge 3 commits into
devfrom
task-3008-node-auto-connect-to-server

Conversation

@ToWhiD073

Copy link
Copy Markdown
Collaborator

PR Type

Feature

PR Checklist

  • Tests for the changes have been added / updated.
  • Documentation comments have been added / updated.
  • A changelog entry has been made.
  • Version number has been updated.
  • Required modules have been added to respective "requirements*.txt" files. N/A - no new dependencies added.
  • Relevant Test Cases added to this description (below).
  • (Team) Label with affected action categories and semver status.

Overview

This PR updates the ZeuZ Python Node connection-state handling so the ZeuZ Server UI can automatically reconnect an available local node to
the currently active browser server tab.

Previously, the local node exposed only basic status information through /api/v1/status, such as node state, node ID, and version. The
browser could discover that a node was running, but it could not reliably know which ZeuZ server the node was connected to or whether it was
already reconnecting to another server.

New behavior:

  • The node now tracks runtime connection metadata:
    • connection_state
    • connected_server
    • target_server
    • started_at
    • instance_id
    • last_connect_error
  • /api/v1/status now returns this metadata.
  • /api/v1/connect immediately marks the node as authenticating to the requested server.
  • The main node login/reconnect flow updates the connection state after success, offline response, authentication failure, or unexpected
    error.

This is backward-compatible because existing /api/v1/status fields are preserved. No database changes, dependency changes, or breaking API
changes are introduced.

Test Cases

Manual verification performed:

  • Started ZeuZ Node using node_cli.py.
  • Verified node status endpoint compiles and returns extended status fields.
  • Verified /api/v1/connect still accepts the same request body.
  • Verified Python syntax with:

  the server/browser can know which ZeuZ server the local node is
  connected to or currently trying to connect to.

  Changes included:
  - Added runtime connection metadata to :
    -
    -
    -
    -
    -
    -

  - Updated  so  immediately
  records:
    - the requested target server
    - authenticating/disconnected state
    - cleared previous connection/error state

  - Extended  so  returns the new
  connection metadata along with existing node status fields.

  - Updated  login/reconnect flow to keep connection
  state accurate:
    - marks node as  before login
    - marks node as  after successful login
    - marks node as  when the target server is unavailable
    - marks node as  when authentication or unexpected login
    errors occur
    - clears target/error state when disconnected

  This supports browser-side auto-connect behavior by allowing each
  ZeuZ server tab to detect whether the local node is already
  connected to that tab’s server or needs to reconnect.
@riz-hossain

Copy link
Copy Markdown
Contributor

🔎 ZeuZ PR Review

Open the full report in ZeuZ: Review findings and apply suggestions

Overview Value
Agents ✅ 4 completed
Suggestions 💡 3

Agent breakdown

→ General Review

Status: ✅ Completed
Suggestions: 1 suggestion

One correctness issue stands out: the new ServerState timestamps/IDs are computed at import time instead of per instance, which can produce stale/shared values and break the intended connection-state tracking metadata.

→ Security Review

Status: ✅ Completed
Suggestions: 1 suggestion

The PR adds connection-state telemetry, but it also exposes sensitive node metadata on the public /status endpoint. I found one information-disclosure issue: server identifiers and raw connection errors are now returned to any caller, which can leak infrastructure details and troubleshooting data.

→ Performance Review

Status: ✅ Completed
Suggestions: 0 suggestions

No performance issues found in this PR diff. The changes are state-tracking additions and do not introduce noticeable query, algorithmic, memory, or network regressions.

→ Testing Review

Status: ✅ Completed
Suggestions: 1 suggestion

The PR adds new connection-state behavior, but there are no tests covering the new status/connect responses or the state transitions they drive.

Open ZeuZ to inspect full findings, continue an agent conversation, or apply safe patch suggestions.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 41fd3abe70

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread node_cli.py Outdated
… = connected immediately after authentication. It now stays

  authenticating after login succeeds, and only becomes connected after the deploy long-poll endpoint responds successfully.

  Files changed

  - projects/Zeuz_Python_Node/node_cli.py:253
  - projects/Zeuz_Python_Node/Framework/deploy_handler/long_poll_handler.py:48

  Backend changes

  - In node_cli.py, login success now sets:
      - connected_server = None
      - target_server = server_name
      - connection_state = authenticating

  - In DeployHandler.run(), deploy service status now controls final connection state:
      - resp.ok marks node as connected
      - 502, no response, request errors mark node as offline
      - deploy error payloads/unexpected exceptions mark node as failed
@riz-hossain

Copy link
Copy Markdown
Contributor

🔎 ZeuZ PR Review

Open the full report in ZeuZ: Review findings and apply suggestions

Overview Value
Agents ✅ 4 completed
Suggestions 💡 4

Agent breakdown

→ General Review

Status: ✅ Completed
Suggestions: 1 suggestion

One issue found: the new startup metadata is captured at import time, so started_at and instance_id won’t be regenerated if ServerState is instantiated more than once. The rest of the connection-state tracking looks consistent with the surrounding flow.

→ Security Review

Status: ✅ Completed
Suggestions: 1 suggestion

One informational security concern: the PR expands the public status payload with connection and instance details that may be sensitive in an unauthenticated endpoint.

→ Performance Review

Status: ✅ Completed
Suggestions: 1 suggestion

One performance concern: the new connection-state bookkeeping re-reads the config file in the deploy polling hot path, which is avoidable overhead. I flagged a small refactor to reuse the known host instead of hitting disk on every successful poll.

→ Testing Review

Status: ✅ Completed
Suggestions: 1 suggestion

The PR adds connection-state tracking and new /status//connect response fields, but I couldn’t find any regression or API-level tests covering the new state transitions or serialized fields.

Open ZeuZ to inspect full findings, continue an agent conversation, or apply safe patch suggestions.

@riz-hossain

Copy link
Copy Markdown
Contributor

🔎 ZeuZ PR Review

Open the full report in ZeuZ: Review findings and apply suggestions

Overview Value
Agents ✅ 4 completed
Suggestions 💡 5

Agent breakdown

→ General Review

Status: ✅ Completed
Suggestions: 1 suggestion

I found one meaningful issue: the new started_at and instance_id fields are initialized at import time, so every ServerState instance will share the same timestamp and UUID. That makes the new status metadata misleading and brittle for tests or any future re-instantiation.

→ Security Review

Status: ✅ Completed
Suggestions: 1 suggestion

Found one medium-risk information exposure: the new public connection-status fields can leak raw backend error text and exception details to any /status caller.

→ Performance Review

Status: ✅ Completed
Suggestions: 1 suggestion

One hot-path regression: the reconnect loop now re-reads settings.conf multiple times per iteration just to populate connection state. No other material performance issues stood out in the diff.

→ Testing Review

Status: ✅ Completed
Suggestions: 2 suggestions

The PR adds new connection-state tracking and status fields, but I don’t see regression tests covering the new state transitions or the /status payload shape. That leaves the core behavior of this change unverified.

Open ZeuZ to inspect full findings, continue an agent conversation, or apply safe patch suggestions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants