Commit Graph

298 Commits

Author SHA1 Message Date
Connor Peet 75d61a59ae Update CLI agent commands for AHP 0.4 (#322173)
AHP 0.4 moves turns/active_turn off SessionState onto per-chat ChatState
(SessionState now carries a `chats` catalog), and SessionStatus is now a
newtype bitset instead of a repr enum.

- agent_ps: use SessionStatus::bits()/from_bits().contains() instead of
  `as u32` casts
- agent_stop: resolve in-progress chats from the session catalog, subscribe
  to each chat to find its active turn, and dispatch the renamed
  StateAction::ChatTurnCancelled to the chat URI
- agent_logs: print the session's chats catalog instead of the removed
  turns/active_turn

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-06-20 01:30:32 +02:00
Lucas Parzianello 959a2d1d00 Fixed typo in cli update (#245751)
fixed typo in cli update

Co-authored-by: Lucas Parzianello <lucaspar@users.noreply.github.com>
Co-authored-by: Dmitriy Vasyura <dmitriv@microsoft.com>
2026-06-10 10:02:42 +00:00
Connor Peet f8a55977f7 Kill full server process tree in agent host kill_running_server (#320631)
* Kill full server process tree in agent host kill_running_server

The CLI agent host supervisor launches the server via a shell shim
(`<server>/bin/code-server-<quality>`) that spawns `node ... server-main.js`,
which in turn spawns a `bootstrap-fork` agent host process. The previous
`child.kill()` in `kill_running_server` only terminated the shim, leaving
the node descendants reparented to PID 1.

Route the shutdown through `kill_tree` instead, and have the non-Windows
`kill_tree` walk the full descendant tree via `pgrep -P` rather than just
the direct children. Add a depth-3 process-tree unit test on Unix.

Fixes #319516

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Fix flaky kill_tree test by reaping spawned child process

The previous test relied on `process_exists` to confirm pids were gone,
but on Linux the outer sh remains a zombie until its parent (the test
runtime) reaps it. Await `child.wait()` immediately after `kill_tree`
so the outer sh is reaped, and rely on init to reap the orphaned
descendants. Also bumps the deadline to 10s to absorb init latency.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Bound kill_running_server wait and check pgrep exit status

Addresses Copilot review feedback:
- kill_running_server: bound child reap with a 5s timeout; escalate to
  SIGKILL via Child::kill if a process ignores SIGTERM, so a misbehaving
  server can't wedge the supervisor's shutdown or upgrade path.
- children_of: distinguish pgrep exit codes — 0/1 are expected (matches
  vs no matches), 2/3 are surfaced as CommandFailed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-06-09 18:28:53 +00:00
Connor Peet 608255bcd0 cli: bump ahp and ahp-types to 0.3.0 (#320322) 2026-06-08 13:22:02 +09:00
Connor Peet 8d1fba12d9 cli: support pinning initial agent host version for upgrade testing (#319671)
* cli: support pinning initial agent host version for upgrade testing

- There was no way to exercise the agent host upgrade flow locally, since
  the CLI always starts the latest server version and has nothing older to
  upgrade from.
- Adds a VSCODE_CLI_INITIAL_AH_VERSION env var that pins the commit the
  agent host is first downloaded and started at, while leaving subsequent
  upgrades to resolve the real latest version, so the full download +
  restart upgrade path can be driven on demand.

(Commit message generated by Copilot)

* cli: restrict initial agent host version override to hex digits

Addresses PR review: the env var value flows into URL and filesystem
paths, so restrict it to hex digits (and trim whitespace) to prevent
path separators or traversal sequences.
2026-06-03 14:41:05 +10:00
Connor Peet d2f6870a95 cli: drop ahp-ws dependency in favor of direct tungstenite (#319451)
* cli: drop ahp-ws dependency in favor of direct tungstenite

- Removes the external ahp-ws crate so the CLI owns its WebSocket
  transport directly, avoiding a thin wrapper dependency and keeping the
  transport logic alongside the existing tunnel transport.
- Updates the agent commands to the ahp 0.2 API (channel-based params,
  optional snapshots, and the two-argument dispatch signature) so the
  CLI compiles against the pinned crate versions again.

(Commit message generated by Copilot)

* cli: deduplicate WebSocket transport adapter

- Replaces the separate WsTransport and TunnelWsTransport implementations
  with a single generic WsTransport over the stream type plus an optional
  keep-alive guard, so the direct and tunnel connections share one
  send/recv/close adapter and cannot drift apart.

(Commit message generated by Copilot)
2026-06-01 21:30:05 +00:00
Robo 8748be1f1a feat: update to Electron v42 (#316661)
* feat: update to Electron v42

* chore: drop support for arm 32-bit server

* chore: update types/node to v24.x

* chore: temporarily lock the target version for build/

* chore: update v8-source-location.patch

* chore: fix clippy

* chore: cleanup armhf server ci config

* fix: broken lock file

* fix: c++ version requirement for sysroot builds

* fix: msvc compilation of native modules

* fix: handle rejections for fire-and-forget loadurl

* fix: windows build

* ci: fix teardown of daemon process on windows

```
2026-05-15T20:55:09.7717127Z Assertion failed: !(handle->flags & UV_HANDLE_CLOSING), file src\win\async.c, line 76
```

* chore: update deb and rpm dependencies

* chore: update version info

* spec: improve reliablity of offscreencanvas tests

* spec: retry EPERM failures on teardown

* chore: update x86_64 rpm deps

* ci: exclude server binskim for armhf

* temp: bump distro

* test: ignore deprecation warnings treated as errors

* chore: update lockfile

* fix: externalize electron from auth extension bundles

 Error: Cannot find module 'c:\Users\cloudtest\AppData\Local\Temp\vscode-sanityQvCaze\vscode-server-win32-x64-web\extensions\github-authentication\dist\install.js'
     at Module._resolveFilename (node:internal/modules/cjs/loader:1476:15)
     at wrapResolveFilename (node:internal/modules/cjs/loader:1049:27)
     at defaultResolveImplForCJSLoading (node:internal/modules/cjs/loader:1073:10)
     at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1094:12)
     at Module._load (node:internal/modules/cjs/loader:1262:25)
     at wrapModuleLoad (node:internal/modules/cjs/loader:255:19)
     at Module.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:154:5)
     at node:internal/main/run_main_module:33:47 {
   code: 'MODULE_NOT_FOUND',
   requireStack: []
 }

 Node.js v24.15.0

* test: make wsl sanity tests reliable

* chore: bump electron@42.1.0

* temp: bump distro

* chore: bump electron@42.2.0

* chore: bump distro

* chore: update debian dependencies

* Revert "test: make wsl sanity tests reliable"

This reverts commit b3f2b63e83.

* test: do not fail for deprecation warnings

* chore: patch node24 server binary for wsl1

* chore: address review feedback

* chore: revert global navigation error handler in browserview

* chore: bump distro
2026-05-27 14:57:41 +02:00
Connor Peet 2acbbb8026 cli: do not block control server startup on agent host supervisor (#317874)
- ensure_supervisor_running now runs as a background task driven by
  tokio::spawn, so the tunnel control server and command-shell can
  start accepting connections immediately instead of waiting for the
  supervisor to come up.
- handle_serve (and the agent-host port forwarder) await the shared
  future on demand and mix the bridge endpoint into the per-request
  code_server_args. Supervisor failure is logged as a warning so editing
  and the extension host keep working; the renderer just misses
  agentHostProxy.
- This eliminates the startup stall that was sporadically tripping
  remote SSH's 450ms command-shell ready timeout.

Fixes #317714

(Commit message generated by Copilot)
2026-05-21 23:06:18 +00:00
Connor Peet ce2a4a6360 address review: only skip empty-relative-path entries when they are directories 2026-05-21 10:57:34 -07:00
Connor Peet d6fb8b71b0 cli: skip bare top-level directory entries when extracting archives
Fixes #317660
2026-05-21 09:14:45 -07:00
Connor Peet e9628be821 cli: validate paths when pulling update (#317393) 2026-05-19 14:55:35 -07:00
Nikolai Zakharov 016f6a1848 fix(cli): self-heal missing execute permission on server binary
When the VS Code server binary is extracted without execute permissions
or loses them (e.g. on network filesystems, after interrupted downloads,
or when copied without preserving permissions), spawning the server fails
with 'Permission denied'. The previous code treated this as generic
'ServerUnexpectedExit' corruption, triggering a useless re-download loop
that never fixes the actual problem.

Changes:
- Add ensure_executable() helper that checks and restores +x on Unix
  before attempting to spawn the server binary.
- Add ServerNotExecutable error variant so permission failures are
  reported clearly instead of being lumped into ServerUnexpectedExit.
- Skip the 'evict on corruption' logic for permission errors, since
  re-downloading cannot fix a filesystem permission issue.

Fixes the root cause where VS Code Remote-SSH shows generic connection
failure popups while the actual error ('Permission denied on server
binary') is hidden in remote logs.
2026-05-18 20:08:40 +08:00
Connor Peet fe314db5eb fix: clippy uninlined_format_args in agent_host.rs
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-16 07:33:24 -07:00
Connor Peet 118154bac5 comments 2026-05-15 22:46:14 -07:00
Connor Peet 56fe549585 agent host: lenient protocol negotiation + CLI-driven server upgrades
Replaces the exact-match version check in `ProtocolServerHandler._handleInitialize`
with a semver-caret negotiator (`negotiateProtocolVersion`) that picks the
highest offered version compatible with the server.

When negotiation still fails and the agent host was spawned by a managing
VS Code CLI (signalled by the new `VSCODE_AGENT_HOST_MANAGEMENT_SOCKET`
env var), the `UnsupportedProtocolVersion` error advertises a
`_meta.vscodeUpgradeMethod = "_vscodeUpgrade"` hint. The client can then
invoke that method on the same transport (callable pre-`initialize`) to
request a server upgrade.

The CLI runs a hyper-based HTTP control server on a unix socket / named
pipe. `POST /upgrade` synchronously downloads the latest release, returns
a serde-derived response (`{ok, upgradeNeeded, upgradeStarted,
runningCommit, latestCommit, restartDelayMs, error}`), and then schedules
a kill+respawn after a 3 s drain delay so the response can hop back
through the proxy before the transport drops. Single-flight via
`upgrade_in_progress: AtomicBool`; the listener is started lazily from
`AgentHostManager::start_server`.

UI:
- `RemoteAgentHostConnectionStatus.incompatible` carries `vscodeUpgradeMethod`
  (read from `_meta`).
- A `watchForIncompatibleNotifications` autorun on each provider raises a
  one-shot warning notification on transition into `incompatible`, with
  "Update Server" (when the host advertised it) and "Show Options"
  primary actions.
- `runServerUpgrade` is shared between the notification action and the
  per-host quickpick. It drives a progress notification with a per-second
  "Restarting in Ns..." countdown and observes `connectionStatus` so it
  bails out if some other code path is already reconnecting.
2026-05-15 21:34:22 -07:00
Copilot 5089fb0bb7 chore: bump rand in cli to 0.8.6 (#316462)
chore: bump rand in cli from 0.10 to 0.8.6 and fix API usage

Agent-Logs-Url: https://github.com/microsoft/vscode/sessions/dadd6751-1668-4f1a-931b-dfa34f0fc227

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: rzhao271 <7199958+rzhao271@users.noreply.github.com>
2026-05-15 13:12:20 -07:00
Connor Peet 83cac60ab6 actually work 2026-05-13 20:26:23 -07:00
Connor Peet 34d208175f wip 2026-05-13 18:45:19 -07:00
Connor Peet 979d3176a2 fix CI: stable Duration ctor + drop stale doc block 2026-05-13 15:39:05 -07:00
Connor Peet 1c3ba6a284 Merge remote-tracking branch 'origin/main' into connor4312/ah-matrix 2026-05-13 15:20:44 -07:00
Connor Peet 5794a86f60 make it work 2026-05-13 15:11:50 -07:00
Connor Peet 0f960d26f1 wip: connection unification 2026-05-12 14:22:21 -07:00
Connor Peet cd73d8b686 cli: enable upgrades on proxied websocket client connection (#315802)
The serve-web command's websocket proxy spawned the client-side hyper connection without `.with_upgrades()`, so `hyper::upgrade::on(&mut res)` rejected the upgrade with "upgrade expected but low level API in use" and the websocket failed to establish.

- Spawn `connection.with_upgrades()` in `forward_ws_req_to_server` to mirror the server side and the equivalent agent-host proxy.

Fixes https://github.com/microsoft/vscode/issues/315448

(Commit message generated by Copilot)
2026-05-11 11:40:41 -07:00
Rob Lourens 9ea2ac02b3 Fix divide-by-zero panic in CLI unzip for small archives (#313389)
When the archive contained fewer than 20 entries, `archive.len() / 20`
evaluated to 0 and the subsequent `i % report_progress_every` operation
panicked with 'attempt to calculate the remainder with a divisor of zero'.

Clamp the divisor to a minimum of 1.

(Written by Copilot)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-30 20:39:40 -07:00
Connor Peet cdf20ffcba agentHost: improve update pickup and fix startup-failure wedge (#313541)
- Shorten background update check interval from 24h to 6h so newly
  published server versions are picked up sooner after auto-shutdown.
- Don't store the child into self.running when it exits before signaling
  ready. Previously a failed startup left a dead child in running
  forever, wedging ensure_server() so it could never restart the server.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-30 17:44:44 +00:00
Connor Peet 23fcb67582 agentHost: small cli polishes
- Mark agent-host > agent as a native cli command
- Update to final tunnel URI format
- Lock to Github auth for agent host tunnels (matching agents app logic)
2026-04-30 08:48:43 -07:00
Connor Peet ed85ff7a6c comments and more deps 2026-04-28 08:56:30 -07:00
Connor Peet 3317944fde Merge remote-tracking branch 'origin/main' into connor4312/cli-ahp-management 2026-04-28 08:35:16 -07:00
Connor Peet 2c36ddb55e cli: implement client AHP control functionality 2026-04-28 08:10:51 -07:00
Connor Peet 06db90587c cli: clean up and update dependencies 2026-04-26 19:53:35 -07:00
dependabot[bot] 7d224d9546 build(deps): bump rand from 0.8.5 to 0.9.3 in /cli (#309689)
* build(deps): bump rand from 0.8.5 to 0.9.3 in /cli

Bumps [rand](https://github.com/rust-random/rand) from 0.8.5 to 0.9.3.
- [Release notes](https://github.com/rust-random/rand/releases)
- [Changelog](https://github.com/rust-random/rand/blob/0.9.3/CHANGELOG.md)
- [Commits](https://github.com/rust-random/rand/compare/0.8.5...0.9.3)

---
updated-dependencies:
- dependency-name: rand
  dependency-version: 0.9.3
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* fix clippy lint warnings after rand 0.8.5 → 0.9.3 upgrade

Agent-Logs-Url: https://github.com/microsoft/vscode/sessions/8e6151a9-d6c4-42c0-9e9e-e8e384b8ce48

Co-authored-by: rzhao271 <7199958+rzhao271@users.noreply.github.com>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: rzhao271 <7199958+rzhao271@users.noreply.github.com>
2026-04-17 10:31:19 -07:00
Connor Peet 62a503dc25 Revert "Revert build breakages (#308162)"
This reverts commit 8aa4cf8a0f.
2026-04-07 07:48:16 -07:00
João Moreno 8aa4cf8a0f Revert build breakages (#308162)
* Revert "agentHost: Hook up isRead/isDone (#308107)"

This reverts commit a3d69b7767.

* Revert "agentHost: support connections over tunnels (#307948)"

This reverts commit 75f21d0a8d.
2026-04-07 08:43:56 +00:00
Connor Peet 75f21d0a8d agentHost: support connections over tunnels (#307948)
* wip

* clean up unused bits and make auth work correctly

* comments and fixes
2026-04-06 16:14:01 +00:00
Raymond Zhao 167b3b89a2 Merge branch 'main' into main 2026-03-26 14:07:44 -07:00
Rob Lourens c82bc515c2 More specific log string for cli agent host proxy (#304339) 2026-03-24 14:14:44 +11:00
Connor Peet b7462b4a00 Merge pull request #303597 from microsoft/connor4312/agent-host-server-fixups
agentHost: fixup build for server
2026-03-20 13:54:33 -07:00
Connor Peet 5d5d0763fb fix build 2026-03-16 19:05:09 -07:00
Rob Lourens 4393d06a0f Skip quality check when VSCODE_CLI_OVERRIDE_SERVER_PATH is set and log agent host startup error 2026-03-13 15:36:45 -07:00
Connor Peet 60c18f38f6 auto updating agent host in the cli 2026-03-13 14:07:24 -07:00
Connor Peet 2da8aa0354 better command detection 2026-03-12 23:31:48 -07:00
Connor Peet 222bbd480e add agent-host command for cli 2026-03-12 23:31:40 -07:00
Dan Plischke b141217200 feat: add support for --default-folder, --default-workspace and --disable-telemetry in rust cli 2026-03-05 16:14:04 +01:00
Raymond Zhao 965d950c25 chore: run cargo update (#295062) 2026-02-13 10:58:40 -08:00
Josh Spicer 6cc2564bf9 remote: configurable 'reconnection grace time' (#274910)
* reconnection grace period prototype

* plumb through CLI

* polish

* Apply suggestions from code review

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-11-12 18:51:28 -08:00
Josh Spicer b96e6d762c allow update endpoint in rs cli to be configurable by env var (#276761) 2025-11-11 10:23:39 -08:00
Justin Wang b0271fa725 Fix --commit-id flag for code serve-web (#258904)
* Fix --commit-id flag for code serve-web

Fixes a bug where passing --commit-id during `code serve-web` would
prevent serve-web from downloading a new version of the client at all.

* Update cli/src/commands/serve_web.rs

---------

Co-authored-by: Connor Peet <connor@peet.io>
2025-07-31 16:52:39 +00:00
Copilot 90072b47cf Fix serve-web port randomization when --port 0 is specified (#254676)
* Initial plan

* Fix serve-web port randomization when --port 0 is specified

Co-authored-by: connor4312 <2230985+connor4312@users.noreply.github.com>

* Fix serve-web to display actual bound port instead of 0

When --port 0 is specified, the OS assigns a random port but the
logging was showing port 0 instead of the actual assigned port.
Fixed by reading the local_addr() from the server builder after binding.

Co-authored-by: connor4312 <2230985+connor4312@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: connor4312 <2230985+connor4312@users.noreply.github.com>
2025-07-22 13:35:24 -07:00
Justin Wang b4d1fec915 Add commit_id option to ServeWebArgs for specific client version (#255494)
* Add commit_id option to ServeWebArgs for specific client version

* Don't start serve-web update checker if given commit-id
2025-07-14 06:12:36 +00:00
S. M. Mohiuddin Khan Shiam 70f8e0e38f Fix incorrect SHA-1 commit regex in [version_manager.rs](cci:7://file:///d:/Github/vscode/cli/src/desktop/version_manager.rs:0:0-0:0) (#251329)
The CLI’s `RequestedVersion::Commit` parser rejected many valid commit hashes and allowed invalid ones due to an erroneous regular expression:

* **Old pattern:** `^[a-e0-f]{40}$`
  * Allowed non-hex characters outside the `a–f` range
  * Excluded the valid hex digit `f` and any uppercase letters
* **New pattern:** [(?i)^[0-9a-f]{40}$](cci:1://file:///d:/Github/vscode/cli/src/desktop/version_manager.rs:102:1-107:2)
  * [(?i)](cci:1://file:///d:/Github/vscode/cli/src/desktop/version_manager.rs:102:1-107:2) enables case-insensitive matching (accepts `A–F`)
  * Character class now correctly restricts input to hexadecimal digits `0-9` and `a-f`
  * Ensures the string is exactly 40 characters, matching a valid SHA-1

#### Impact

`code version use <commit>` and related commands could silently fail or accept malformed commit IDs, leading to unexpected version resolution behavior.
With this fix, only valid 40-character hexadecimal commit hashes are accepted, restoring reliable version selection and preventing subtle bugs.

#### Notes

No API changes; the fix is a single-line update in [cli/src/desktop/version_manager.rs](cci:7://file:///d:/Github/vscode/cli/src/desktop/version_manager.rs:0:0-0:0).
2025-06-13 15:40:55 +00:00