Skip to content

Add --wait to code-server's own CLI - #8117

Merged
code-asher merged 3 commits into
coder:mainfrom
b84330808:cli-wait-flag
Nov 13, 2026
Merged

code-asher merged 3 commits into
coder:mainfrom
b84330808:cli-wait-flag

Conversation

@b84330808

Copy link
Copy Markdown
Contributor

Fixes #8089

As suggested in the issue, this adds --wait to code-server's own script, so code-server --wait --reuse-window works as GIT_EDITOR even when that script is the one on PATH instead of remote-cli. It also works from a shell outside the integrated terminal, through the session socket.

It does what VS Code's remote-cli does: create a marker file, send it as waitMarkerFilePath with the open request, and return once Code deletes it after the files are closed. Like --reuse-window, --wait only opens in an existing instance and errors if there is none. -w is already --welcome-text, so there's no short flag.

Added unit tests for the wait loop (with a fake socket standing in for Code's) and for --wait not falling back to starting a server. I haven't run it against a full build.

Using `code-server --wait --reuse-window` as GIT_EDITOR fails with
"Unknown option --wait" whenever code-server's own script is the one on
PATH rather than the remote-cli script VS Code adds to the integrated
terminal (coder#8089). It also cannot be used as an editor from a shell
outside the integrated terminal.

With --wait, code-server now creates a marker file, passes it to Code
with the open request, and returns once Code deletes it, which Code
does when the opened files are closed. This is what VS Code's remote-cli
does. Like --reuse-window, --wait always opens in an existing instance.
@b84330808
b84330808 requested a review from a team as a code owner November 7, 2026 16:58

@code-asher code-asher left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for the PR!

Comment thread src/node/main.ts Resolved
Comment thread src/node/main.ts Resolved
Comment thread test/unit/node/main.test.ts Resolved
Comment thread test/unit/node/main.test.ts Resolved
Comment thread test/unit/node/main.test.ts Resolved
b84330808 and others added 2 commits November 11, 2026 10:48
Reject on request errors instead of logging them, so --wait does not exit 0 when Code never got the request, and clean up the marker in that case. Put the marker in code-server's tmpdir with generateUuid(16), and use fake timers in the test.

@code-asher code-asher left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Superb, thank you!

@code-asher
code-asher merged commit bef3aff into coder:main Nov 13, 2026
10 checks passed
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.

Cannot open files in integrated terminal

2 participants