Skip to content

fix(cloud): the next session in a workspace is reachable and selectable; New thread survives an ended machine - #377

Merged
johnnyelwailer merged 4 commits into
mainfrom
fix/run-on-connect-grace
Oct 6, 2026
Merged

johnnyelwailer merged 4 commits into
mainfrom
fix/run-on-connect-grace

Conversation

@johnnyelwailer

Copy link
Copy Markdown
Owner

Three bugs found by the live resume test (fork #376 / distro #592 follow-up):

  1. Reconnect pinned to an ended session. Sessions in one workspace share their environment (the snapshot keeps its id), but the client's broker target pinned the first session's id. After it ended, every reconnect attached the ended session (409), the composer blocked sending on "… is reconnecting", and the new machine was never reached. Attach now also takes the environment id; when the known session has ended, the server attaches the live session serving that environment, and the client pairs and stores its bearer under the session actually attached.
  2. Fresh machine not selected. A just-started machine registers its project seconds after it connects; the selector took it for another project's machine, gave up, and the thread ran on This computer. It now keeps Connecting… for a 30 s grace first.
  3. New thread did nothing when the first project in sidebar order lived on an ended machine. It now defaults to the first project on a reachable environment.

Tests: client-runtime resolver 16/16 (new: follows the live session), server sessionToAttach 4/4 + cloud service, web selector + cloud 92/92. Live: with these, a machine session from a fresh draft is selected on one click and the agent's work lands on the VM (verified: the local checkout untouched).

🤖 Generated with Claude Code

Phil J and others added 2 commits October 6, 2026 12:41
… ended one

Live test: clicking Ready on a just-started machine session connected it,
but its project registers seconds later, so the selector took it for
another project's machine, gave up, and the thread ran on This computer.
It now keeps Connecting for a 30 s grace before calling it unavailable.

New thread defaulted to the first project in sidebar order even when that
project lived on a machine that had gone away; it did nothing. It now takes
the first project whose environment is reachable.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ment it already knows

Sessions in one workspace share their environment (the snapshot keeps its
id), but the client's broker target pinned the session it first connected
to. After that session ended, every reconnect attached the ended session
(409), the composer blocked sending on "reconnecting", and the new machine
was never reached.

Attach now takes the environment id too: when the known session has ended,
the live session serving the same environment is attached, and the client
pairs and keeps its bearer under the session actually attached.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-06T11:04:46.763885Z 84fcfa6 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:L labels Oct 6, 2026
…r New thread lives there)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

@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: 84fcfa6a95

ℹ️ 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 on lines +42 to +44
typeof body.environmentId === "string" && /^[\w.:-]{1,128}$/.test(body.environmentId)
? body.environmentId
: undefined;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve opaque environment IDs in attach requests

When an environment uses a valid identifier containing characters outside \w.:- (for example workspace/prod) or longer than 128 characters, this parser silently discards it. The shared EnvironmentId contract in packages/contracts/src/baseSchemas.ts accepts any non-empty trimmed string, so after the pinned session ends, sessionToAttach receives no environmentId and cannot locate the replacement session, leaving these supported environments permanently unable to reconnect. Validate against the shared contract or forward the opaque string unchanged.

AGENTS.md reference: AGENTS.md:L51-L56

Useful? React with 👍 / 👎.

@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Thread transfer impact

⚠️ The latest CI run did not produce a thread transfer result for 2657143.

This comment will update automatically after the next completed run.

- two live sessions serving one environment: the newest run wins, so
  reconnects stay on one machine; an asked-for session is used only when it
  serves the environment the client expects (broker lists only the
  caller's sessions: services/nexi-broker/src/broker.mjs:131);
- an environment is not called ended while the workspace's next session
  serves it;
- the connect deadline is one timer per click (60 s), read against the
  latest state, so re-renders cannot restart it, and a connect that never
  completes no longer hangs on Connecting;
- New thread never counts This computer as offline at startup;
- the attach route accepts any non-empty environment id.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@johnnyelwailer
johnnyelwailer merged commit 6d0f222 into main Oct 6, 2026
20 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant