Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
5596 commits
Select commit Hold shift + click to select a range
83ad2f6
Style overrides: Add border to modified side-by-side diff editor (#32…
Aug 6, 2026
afcab41
Onboarding new session view version 3 with prompt auto fill
Aug 6, 2026
b0e0a8d
Merge branch 'main' into eli/agents/fix-bug-theme-color-token
Aug 6, 2026
e0e16ee
Fix Quick Input action visibility specificity (#327983)
Aug 6, 2026
f62b602
Merge branch 'main' into eli/agents/fix-bug-theme-color-token
Aug 6, 2026
fec2ccd
refactor: share the find input toggle navigation (#329128)
Aug 6, 2026
d62bf25
sessions: Refine Show/Hide Editor placement, icons, and Browser-tab f…
Aug 6, 2026
7833204
Merge branch 'main' into benibenj/inner-leopard
Aug 6, 2026
618d34f
Fix SVG paths for consistency in preview files (#329410)
Aug 6, 2026
86e361b
Add missing Azure SDK for Go modules to GoModulesToLookFor (#322786)
Aug 6, 2026
b75b4a8
Merge pull request #329010 from microsoft/copilot/fix-infinite-loop-m…
Aug 6, 2026
79e090a
chat: restore completion relevance (#329367)
Aug 6, 2026
5cb2373
Address onboarding V3 review feedback
Aug 6, 2026
68e1826
nes: fix: compose complete recording oracles (#329454)
Aug 6, 2026
3bb4511
Fix active client refresh feedback loop (#329452)
Aug 6, 2026
164c728
Remove legacy agent session picker (#329501)
Aug 6, 2026
b65471b
chat: reduce agent session change retention (#329505)
Aug 7, 2026
b4a0459
Bound dictation LLM cleanup latency (#329419)
Aug 7, 2026
9245212
Add voice session awareness and actions (#329493)
Aug 7, 2026
846f9ce
Add auxiliary window bounds API (#329484)
Aug 7, 2026
9812025
Add lightweight chat session history reads (#329492)
Aug 7, 2026
1ccea89
Support Auto Tiers (#329463)
Aug 7, 2026
a51130c
Gate Voice Mode on Copilot entitlement (#329220)
Aug 7, 2026
75d99b9
sessions: restore maximization after side pane toggle (#329437)
Aug 7, 2026
cd07a0e
Fix voice playback when reopening chat sessions (#329451)
Aug 7, 2026
a2680bc
agentPlugins: support Copilot client extensions (#329473)
Aug 7, 2026
e5770ec
sessions: keep Changes and Files in aux-only view (#329448)
Aug 7, 2026
6a94d32
Track native edit context focus by owner document (#329483)
Aug 7, 2026
ca04dbe
Add chat session router service (#329486)
Aug 7, 2026
798c373
Split policy telemetry by delivery source (#328140)
Aug 7, 2026
75f5593
Allow remote resolver terminals before workspace trust (#329228)
Aug 7, 2026
3346aae
Scope "Auto accept delay" and "Select a code block" tips out of Agent…
Aug 7, 2026
695b9d3
Revert "Guard Azure node_modules caches against missing native packag…
Aug 7, 2026
8376cba
sessions: prevent header dropdown flicker (#329487)
Aug 7, 2026
0e03962
event: Reduce listener leak instrumentation memory (#329324)
Aug 7, 2026
4e81e37
Allow compact frameless auxiliary windows (#329485)
Aug 7, 2026
7b46bb9
test: skip flaky Codex structured file reads (#329513)
Aug 7, 2026
6aa95a5
pet: new typing and finish animation, drag and drop, fall off map (#3…
Aug 7, 2026
4a999ce
agentHost: Align deferred tool search result names (#329510)
Aug 7, 2026
f4f7942
Remove Border From Lone Voice Input Action (#329428)
Aug 7, 2026
762a16c
tunnels: fail over to a dedicated agent host when the gateway rejects…
Aug 7, 2026
af5750c
Preserve voice mode when creating a new chat session (#329441)
Aug 7, 2026
15bdbfa
Distinguish rearmed voice approval occurrences (#329509)
Aug 7, 2026
0dcbac4
Fix stationary mouse menu selection issues (#329507)
Aug 7, 2026
6cfacef
agentHost: Refresh OSS SSH CLI and improve connection errors (#329459)
Aug 7, 2026
098619a
fix streaming tool calls (#329519)
Aug 7, 2026
1792cd8
agentHost: Track host and client topology (#329323)
Aug 7, 2026
9815495
Verify SSH host keys for remote agent host connections (#329462)
Aug 7, 2026
fe15ac9
Remove rolled out Copilot session settings (#329450)
Aug 7, 2026
1fe4419
test: increase agent host e2e coverage (#329333)
Aug 7, 2026
068c55b
chat: fix collapsible part collapse (#329465)
Aug 7, 2026
11b7f24
agentHost: gate flaky Codex shell output tests (#329517)
Aug 7, 2026
54e7cd2
editor: avoid telemetry creation after disposal (#329518)
Aug 7, 2026
a616228
Expose agent plugin update actions (#329467)
Aug 7, 2026
1f6baee
agentHost: capture git baseline checkpoint for Claude and Codex sessi…
Aug 7, 2026
12caca0
Improve survey attribution and option ordering (#326848)
Aug 7, 2026
3c9d7f2
editor: support inputs that cannot be closed by users (#329429)
Aug 7, 2026
0d10356
Fix onboarding V3 CI failures
Aug 7, 2026
473f9f7
Merge remote-tracking branch 'origin/main' into benibenj/inner-leopard
Aug 7, 2026
db16b90
sessions: align outer gutters with panel spacing (#329548)
Aug 7, 2026
b6b7723
agents window: fix sessions list icon/animation (#329542)
Aug 7, 2026
a73436f
sessions: reuse shared editor tab styles (#329547)
Aug 7, 2026
511fd2d
agentHost: Claude per-session provider selection (#329331)
Aug 7, 2026
3ff4448
Improve Agents window sign-in dialog (#329470)
Aug 7, 2026
c1d2bab
regiters markdown editor commands as vscode commands, so that shortcu…
Aug 6, 2026
1099972
Address Markdown editor command review feedback
Aug 6, 2026
9950fa3
Mark generated Markdown editor localization entries
Aug 6, 2026
ae1d0ba
Extract chat session routing heuristics (#329522)
Aug 7, 2026
5eb21bd
Merge pull request #329438 from microsoft/benibenj/inner-leopard
Aug 7, 2026
939e397
sessions: Preserve side pane with multiple sessions (#329552)
Aug 7, 2026
832de46
Add message authentication for Markdown editor webview communication …
Aug 7, 2026
c4bfb51
Make agentStatusIndicator.background inherit from commandCenter.backg…
Aug 7, 2026
152c2cf
Remove padding from sessions github reference list (#329563)
Aug 7, 2026
b40d363
Introduce modern file icon theme with new SVG assets (#329568)
Aug 7, 2026
8df633d
sessions: don't swallow clicks on header meta pills via session drag …
Aug 7, 2026
5ce2706
Fix pasting in Markdown editor
Aug 7, 2026
624cb75
sessions: Show diff layout toggle for single files (#329569)
Aug 7, 2026
36cb0da
agentHost: inherit model and permissions in session tools (#329562)
Aug 7, 2026
98b093a
sessions: align chat tabs with modern editor tabs (#329572)
Aug 7, 2026
97e7e43
Version Markdown code block editor API
Aug 7, 2026
c422aca
improves markdown editor loading performance by inlining initial docu…
Aug 7, 2026
d9e34e5
sessions: improve Changes view layout (#329580)
Aug 7, 2026
9118348
Refactor attachment widget icons to use compact variants (#329586)
Aug 7, 2026
6dc5902
Fix can't hit enter really fast on simple file picker (#329581)
Aug 7, 2026
b2ebb55
Run flaky test pipeline for stable on Monday mornings (#329585)
Aug 7, 2026
8fd29eb
scm: Avoid quick diff after model disposal (#329534)
Aug 7, 2026
9dcae82
sessions: keep aux-only tabs limited to Changes and Files (#329590)
Aug 7, 2026
4c0cd16
Style overrides: Improve layout and visibility of activity and compos…
Aug 7, 2026
be449c2
nes: feat: add optional rejected edit memory to diffpatch prompt (#32…
Aug 7, 2026
83dd819
Remove Copilot session file monitoring (#329593)
Aug 7, 2026
924f9cf
chat: add signed-out Copilot entry points
Aug 7, 2026
28a37ff
Dont show reopen as preview/text in agents window, as editor type dro…
Aug 7, 2026
7904fa6
Avoid entitlement lazy re-entry during Agents startup (#329599)
Aug 7, 2026
e6619fc
Potential fix for pull request finding
Aug 7, 2026
f724f0d
sessions: preserve panel height when restoring editor (#329608)
Aug 7, 2026
262ba9c
chat: remove account entry point documentation
Aug 7, 2026
1d68945
Fix stale session changes document lifecycle (#329325)
Aug 7, 2026
a278eaa
agentHost: Attribute edits in focus windows (#329472)
Aug 7, 2026
9f91a99
Browser auto-reload small cleanups (#329622)
Aug 7, 2026
55876d4
adding command which returns internal copilot settings (#329598)
Aug 7, 2026
445ff84
sessions: remove Local harness from Agents window (#329603)
Aug 7, 2026
3325926
test: register signed-out model actions at suite scope
Aug 7, 2026
1aa1a7b
build(deps-dev): bump fast-uri from 3.1.4 to 3.1.5 in /test/monaco (#…
Aug 7, 2026
8eaafbf
agentHost: exclude Copilot Chat GitHub MCP sync (#329623)
Aug 7, 2026
2dc4e80
Merge pull request #329617 from microsoft/vritant24/chat-notification…
Aug 7, 2026
c9569d5
Merge branch 'main' into vritant24/signed-out-account-model-actions
Aug 7, 2026
7087adc
Agent Host changes for agents/unit-test-reproduce-issue-329560
Aug 7, 2026
c17ebb8
Merge branch 'main' into agents/unit-test-reproduce-issue-329560
Aug 7, 2026
c69cd0d
agentHost: summarize parallel E2E failures (#329637)
Aug 7, 2026
6a0984c
Support running sanity tests against build pipeline artifacts (#329256)
Aug 7, 2026
9b4e244
Add GitHub prompt variation to the V3 onboarding tour (#329629)
Aug 7, 2026
812c5df
Merge pull request #329620 from microsoft/vritant24/signed-out-accoun…
Aug 7, 2026
271099c
Add form_post to UrlHandlerFlow (#329217)
Aug 7, 2026
d9ea9f8
agentHost: increase Copilot E2E coverage (#329602)
Aug 7, 2026
c5d02f8
Merge pull request #329646 from microsoft/agents/unit-test-reproduce-…
Aug 7, 2026
7dd6dac
chore: bump @github/copilot-sdk to 1.0.9 and @github/copilot to 1.0.7…
Aug 7, 2026
1b8f4bb
Rename Voice Mode voices to approved names (#329576)
Aug 7, 2026
e6e6206
removing execution of commands (#329652)
Aug 7, 2026
70ee5ae
Update 'Policy and Managed Settings' skill (#329499)
Aug 7, 2026
ca6ea1b
agentHost: remove the claudeUseCopilotProxy setting (#329650)
Aug 7, 2026
392a7a5
build(deps): bump brace-expansion from 2.1.0 to 2.1.4 in /test/sanity…
Aug 7, 2026
13fb6fb
Emit agent-host session title spans for Codex
Aug 7, 2026
721e499
Use tracked policy sources in diagnostics (#329658)
Aug 7, 2026
6d0617c
Fix operator precedence in timeline pageSize calculation (#303258)
Aug 7, 2026
cabbcbe
test: handle preselected Agents session type (#329663)
Aug 7, 2026
2eb3bea
Merge pull request #329665 from microsoft/michiisai/codex-otel-sessio…
Aug 7, 2026
b7b8500
Ignore audio capture files for Darwin and Linux platforms during Wind…
Aug 7, 2026
a9d169f
Fix Agent Host changeset discard E2E race (#329670)
Aug 7, 2026
06d74d6
Fix custom context menus on macOS (#329676)
Aug 7, 2026
d43a612
agentHost: bump AHP to 0.7.0 (#329674)
Aug 7, 2026
49af1f7
Omni-chat with multi-session routing (#326698)
Aug 7, 2026
58dc612
Add new exp TAS assignments endpoint (/api/v1/assignments) alongside …
Aug 7, 2026
ea79c39
Refresh cloned plugin marketplaces on a TTL (#329679)
Aug 7, 2026
aad4372
Fix chat animation during non-chat dictation (#329687)
Aug 7, 2026
4df819b
Show the source conversation in a side chat (#329681)
Aug 7, 2026
e390f36
agentHost: declare response success telemetry fields (#329690)
Aug 7, 2026
2ea28ea
Fix Update button spacing on macOS (#329692)
Aug 7, 2026
cbd1beb
docs: fix stale relative paths in Claude chat sessions AGENTS.md (#32…
Aug 7, 2026
a288cc8
Merge branch 'main' into eli/agents/fix-bug-theme-color-token
Aug 7, 2026
4d774f4
build(deps): bump brace-expansion from 5.0.7 to 5.0.9 in /extensions/…
Aug 7, 2026
ec59c6e
Update Copilot extension links (#329229)
Aug 7, 2026
6fb8150
build(deps): bump ip-address from 10.2.0 to 10.4.0 in /remote (#329078)
Aug 7, 2026
4c41177
Merge pull request #329294 from eli-w-king/eli/agents/fix-bug-theme-c…
Aug 7, 2026
7f22e3f
build(deps): bump fast-uri from 3.1.4 to 3.1.5 in /test/mcp (#328825)
Aug 7, 2026
2e5a3ab
fix: exclude arm64 MSAL runtime from VersionInfo sanity (#329628)
Aug 7, 2026
e267cb5
build(deps): bump brace-expansion from 5.0.7 to 5.0.9 in /extensions/…
Aug 7, 2026
66e2071
Restore the Omni Chat model picker (#329699)
Aug 7, 2026
6e3da3e
Fix Agent Host terminal command metadata in clean builds (#329703)
Aug 7, 2026
089827a
Remove redundant Omni file confirmation chrome (#329708)
Aug 7, 2026
eb55ea1
Restore theme colors in Modern UI shell (#329701)
Aug 7, 2026
c97a6dc
build(deps): bump ip-address from 10.2.0 to 10.4.0 in /test/mcp (#328…
Aug 7, 2026
2e073cf
agentHost: Fix failure and edit telemetry (#329686)
Aug 8, 2026
36865a9
agentHost: require GitHub for Claude unless a BYO-Anthropic setup exi…
Aug 8, 2026
b27f9f0
Fix Agent Host user settings loading (#329723)
Aug 8, 2026
321e0ee
pet: more click animations (#329729)
Aug 8, 2026
441790e
Remove sticky header setting and enable by default for all users (#32…
Aug 8, 2026
e867fe3
Merge pull request #329712 from microsoft/tyler/claude-first-signin-c…
Aug 8, 2026
d8dcf96
Implement 120-character truncation for Open Recent labels with Unicod…
Aug 8, 2026
e5ca89a
agentHost: widen native Claude setup detection (#329731)
Aug 8, 2026
a2aaf37
Show output file for truncated shell output when instead of shell_exi…
Aug 8, 2026
78a7b6c
agentHost: remove extension-host Claude implementation (#329697)
Aug 8, 2026
ef7dc8f
agentHost: EH Copilot CLI migration updates (prompt scaffolding, wor…
Aug 8, 2026
c780ea9
New TAS assignments endpoint updates (lifecycle, readiness, disposal)…
Aug 8, 2026
5fb9376
agentHost: run the agent host on the remote server (#329706)
Aug 8, 2026
9361d8d
test: fix agent host worktree path flake (#329730)
Aug 8, 2026
b285c02
Fix allowed remote MCP server initialization (#329774)
Aug 8, 2026
97f9937
Improve Agent Host large-output guidance (#329778)
Aug 8, 2026
47aea0c
agentHost: describe entry persistence with a static config table (#32…
Aug 9, 2026
e7d7d85
Fix duplicated word in Copilot prompt text (#328961)
Aug 9, 2026
d86a683
chat: fix: honor disabled built-in skills in the Agents window (#329786)
Aug 9, 2026
22e4419
agentHost: Preserve session worktrees on shutdown (#329719)
Aug 9, 2026
a8fee70
[Perf] Release stale RPC cancellation handlers (#329793)
Aug 9, 2026
5bd52b9
Fix retained snippet initialization work (#329728)
Aug 9, 2026
662434c
sessions: show Changes view toggle for file diffs (#329780)
Aug 9, 2026
add9a51
sessions: support editor tab display modes (#329783)
Aug 9, 2026
dbd7e5a
Fix recursive Agents session list updates (#329819)
Aug 9, 2026
d4c7a65
Agent host: reveal all unreviewed comments when the confirmation is a…
Aug 9, 2026
d73ddb9
Agent host: resolve session pull requests by remote branch and head c…
Aug 9, 2026
1415e6a
Fix headless tool preapproval (#329788)
Aug 9, 2026
99d3dc0
Add prompt options to V3 onboarding (#329837)
Aug 9, 2026
d4382f8
[Perf] Bound Agent Host response file observable caches (#329797)
Aug 9, 2026
fa16d82
Classify Agent Host Copilot startup failures (#329714)
Aug 9, 2026
7f2eabb
agentHost: Keep shell read helpers non-terminal (#329791)
Aug 9, 2026
b64d547
test: stabilize Copilot terminal metadata E2E (#329833)
Aug 9, 2026
cc0ca4f
agentHost: Track SSH connection outcomes (#329834)
Aug 9, 2026
d6f998e
Fix prompt option disabled and reduced-motion styling (#329838)
Aug 9, 2026
5a7d012
Prevent transient duplicate Agent Host sessions (#329794)
Aug 9, 2026
24bfcea
Restore persisted agent request errors (#329828)
Aug 9, 2026
dc95aeb
Only surface model picker Sign In for signed-out / sign-up users (#32…
Aug 9, 2026
bba5e40
agentHost: add local host restart command (#329839)
Aug 9, 2026
f1df8d0
Add full-text hovers to onboarding prompt options (#329845)
Aug 9, 2026
5a0c9b8
fix scrollbar inconsistencies in chat input (#329740)
Aug 9, 2026
aa5ead3
chat: Preserve scroll position between sessions (#329844)
Aug 9, 2026
5ade39d
[Perf] Clean Agent Host provider state after session deletion (#329798)
Aug 9, 2026
3a48cfa
Mute GitHub numbers in onboarding prompt options (#329849)
Aug 9, 2026
f479ad8
fix slow sash resizing with chat sessions (#329799)
Aug 9, 2026
88c8699
pet: keyboard hop (#329852)
Aug 9, 2026
c90f202
fix chat thinkig collapsible header overflow issue (#329858)
Aug 9, 2026
93f03e3
sessions: hide automations pointer focus outline (#329503)
Aug 9, 2026
45bd0b2
chat: limit general client tools in Agents window (#329860)
Aug 9, 2026
9d2ef77
Avoid oversized restricted telemetry requests (#329865)
Aug 9, 2026
8fdfd90
agentHost: Support Copilot root session forks (#329861)
Aug 9, 2026
a42ac74
Keep restored system notifications in one turn (#329869)
Aug 10, 2026
9cc86e8
test: Disable flaky Agent Host worktree cleanup E2E (#329875)
Aug 10, 2026
7172dbd
agentHost: add generic agent turn hang telemetry (#329884)
Aug 10, 2026
5a36a9c
chat: Cache generated built-in agent files (#329689)
Aug 10, 2026
4bef755
Limit pet clapping on confirmations (#329867)
Aug 10, 2026
3aa98d9
Add session workspace preselection fallback (#329896)
Aug 10, 2026
cdb5c6f
Bump version to 1.134.0 (#329898)
Aug 10, 2026
af22d22
Update endgame notebook milestones to 1.133.0 (#329897)
Aug 10, 2026
3f52ce5
sessions: Avoid recursive list splice (#329909)
Aug 10, 2026
72986a2
sessions: replace terminal action with panel toggle (#329914)
Aug 10, 2026
038d70c
Agents window: Update badge positioning and refactor activity bar sty…
Aug 10, 2026
f321c76
agentHost: multi-root turn changeset diffs (foundation) (#329531)
Aug 10, 2026
e1d3630
Filter pre-existing PRs from folder sessions (#329937)
Aug 10, 2026
2f6bda8
Style overries: Update sash handle appearance for high contrast theme…
Aug 10, 2026
ff15e52
sessions: reserve 5 file rows in changes list, collapse CI checks by …
Aug 10, 2026
ab2d850
Modern UI: Improve layout and padding for floating panels in activity…
Aug 10, 2026
17b6e73
Fix watching problem collector replay growth (#329733)
Aug 10, 2026
409665d
Update @vscode/codicons to version 0.0.46-35 and add 'close-small' ic…
Aug 10, 2026
47bef92
Style overrides: Update font weight for auxiliary bar action labels (…
Aug 10, 2026
66fe415
Update spacing for notifications center and toasts (#329959)
Aug 10, 2026
d97c8a8
Add extensions.gallery.authProvider policy, marketplace scope, and co…
Jul 7, 2026
6f54fb9
Add Entra ID eligibility check to the gallery manifest service
Jul 7, 2026
ab9e525
Add provider-aware marketplace sign-in and access-denied UX
Jul 7, 2026
3481985
Add microsoft to trustedExtensionAuthAccess
Jul 7, 2026
94a70a7
Add unit tests for marketplace provider routing and eligibility
Jul 7, 2026
bd44656
Harden Entra marketplace access: cache scoping, race guards, error ha…
Jul 10, 2026
eec93cb
Address Copilot PR review: policy export, cross-account leak, layerin…
Jul 10, 2026
6434607
Avoid `any` casts in extensionGalleryManifestService test
Jul 14, 2026
ca0d56f
Refactor Private Marketplace access validation into a provider strategy
Jul 29, 2026
5510595
Surface AccessDenied instead of re-prompting sign-in on 401 for signe…
Jul 29, 2026
2f7a8f9
Remove policy data from contributor PR
Aug 4, 2026
6ec632f
Dissolve access validator into account + service-index services
Aug 7, 2026
3aa3035
marketplace: thread CancellationToken guards, materialize index in ca…
Aug 10, 2026
988ffeb
marketplace: make getEffectiveAuthProvider dependency-free, cache res…
Aug 10, 2026
c0306bc
marketplace: collapse duplicate access-denied welcome content into on…
Aug 10, 2026
5ec451b
marketplace: fix telemetry provider scoping
Aug 10, 2026
0b48532
test: add gallery access unit and telemetry coverage
Aug 10, 2026
b5aaf89
Remove CONTEXT_MARKETPLACE_AUTH_PROVIDER re-export
Aug 12, 2026
3789654
Use Event.signal for onDidChangeAccount instead of an emitter relay
Aug 12, 2026
0630e80
Default extensions gallery auth provider to a valid enum member
Aug 12, 2026
322b2e3
Revert 'Add microsoft to trustedExtensionAuthAccess'
Aug 12, 2026
67955a3
Register account resolver as a Delayed singleton (Tyler #3, #4)
Aug 12, 2026
84ff6e0
Ground Private Marketplace account selection in a persisted slot
Aug 12, 2026
fc4e4a0
Show account quick pick on Microsoft marketplace sign-in
Aug 13, 2026
117928b
Clarify getAccount vs resolveCurrentAccount intent
Aug 13, 2026
d2626c5
Move Microsoft (Entra) marketplace eligibility check client-side
Aug 13, 2026
af73002
marketplace: break account->auth DI cycle via orchestrator wiring
Aug 13, 2026
c67ffce
marketplace: rename ExtensionGalleryServiceIndexService to ...Fetcher
Aug 13, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
553 changes: 269 additions & 284 deletions .agents/skills/launch/SKILL.md

Large diffs are not rendered by default.

559 changes: 559 additions & 0 deletions .agents/skills/launch/scripts/launch.ps1

Large diffs are not rendered by default.

283 changes: 283 additions & 0 deletions .agents/skills/launch/scripts/launch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,283 @@
#!/usr/bin/env bash
# Launch Code OSS (VS Code from sources) with:
# - a fresh, slimmed copy of the authenticated user-data-dir (so Copilot/GitHub auth works)
# - an isolated --shared-data-dir (otherwise two instances share ~/.vscode-oss-shared and crash each other)
# - unique debug ports for renderer (CDP), extension host, main process, and agent host
#
# Auth on macOS comes from the OS keychain (per-app, shared automatically) plus
# the encrypted blob in User/globalStorage/state.vscdb (per-UDD). The slim copy
# keeps the auth-relevant state and drops caches / workspaceStorage / logs.
#
# Prints a single JSON line to stdout with the chosen ports + paths so the
# caller can pick them up programmatically. Logs go to stderr.
#
# Usage:
# launch.sh [--agents] [--source-user-data-dir <path>] [--repo <vscode-repo-root>]
# [--clone-extensions] [--full] [-- <extra code.sh args>]
#
# Flags:
# --clone-extensions Copy the source extensions/ into the new profile (~10s).
# Default: start with an EMPTY extensions/ dir - fastest
# and conflict-free, but no third-party extensions.
# --full Copy the entire profile (incl. extensions). Use if the
# slim copy is missing something you need.
#
# Defaults:
# --source-user-data-dir $CODE_OSS_DEV_AUTHED_USER_DATA_DIR (else ~/.vscode-oss-dev)
# --repo $PWD if it looks like a vscode checkout; otherwise pass it explicitly

set -euo pipefail
umask 077

AGENTS=0
SOURCE_UDD="${CODE_OSS_DEV_AUTHED_USER_DATA_DIR:-$HOME/.vscode-oss-dev}"
REPO=""
EXTRA_ARGS=()
CLONE_EXTENSIONS=0
FULL=0

while [[ $# -gt 0 ]]; do
case "$1" in
--agents) AGENTS=1; shift ;;
--source-user-data-dir) SOURCE_UDD="$2"; shift 2 ;;
--repo) REPO="$2"; shift 2 ;;
--clone-extensions|--copy-extensions) CLONE_EXTENSIONS=1; shift ;;
--full) FULL=1; shift ;;
--) shift; EXTRA_ARGS=("$@"); break ;;
*) echo "Unknown arg: $1" >&2; exit 2 ;;
esac
done

if [[ -z "$REPO" ]]; then
if [[ -x "$PWD/scripts/code.sh" ]]; then
REPO="$PWD"
else
echo "Could not find a vscode checkout in $PWD. Pass --repo <path>." >&2
exit 2
fi
fi

if [[ ! -d "$SOURCE_UDD" ]]; then
echo "Source user-data-dir does not exist: $SOURCE_UDD" >&2
echo "Pass --source-user-data-dir <path> or set CODE_OSS_DEV_AUTHED_USER_DATA_DIR." >&2
exit 2
fi

pick_port() {
node -e '
const net = require("net");
const s = net.createServer();
s.listen(0, "127.0.0.1", () => { const p = s.address().port; s.close(() => console.log(p)); });
'
}

CDP_PORT=$(pick_port)
EXTHOST_PORT=$(pick_port)
MAIN_PORT=$(pick_port)
AGENTHOST_PORT=$(pick_port)

STAMP=$(date +%Y%m%d-%H%M%S)-$$
RUN_DIR="${TMPDIR:-/tmp}/code-oss-dev/$STAMP"
DEST_UDD="$RUN_DIR/user-data"
SHARED_DATA_DIR="$RUN_DIR/shared-data"
mkdir -p "$DEST_UDD" "$SHARED_DATA_DIR"

# Excludes (deny-list, so future VS Code additions copy through by default).
# Anchored excludes (starting with /) match only at the top level so we don't
# accidentally strip files inside subdirs that share a name.
EXCLUDES=(
'/extensions' # handled separately below
'/workspaceStorage' 'User/workspaceStorage' # per-workspace state, incl. chat sessions
'User/History' # local file edit history
'/CachedExtensionVSIXs' # backup VSIXs
'/logs'
'/Cache' '/Code Cache' '/CachedData' '/component_crx_cache'
'/GPUCache' '/ShaderCache' '/Dawn*Cache'
'/Backups' '/blob_storage' '/BrowserMetrics' '/Crashpad'
'/Session Storage'
'/Singleton*'
'*.lock' '*.sock'
)

if [[ "$FULL" == "1" ]]; then
echo "[launch.sh] full copy: $SOURCE_UDD -> $DEST_UDD" >&2
rsync -a "$SOURCE_UDD/" "$DEST_UDD/"
else
echo "[launch.sh] slim copy: $SOURCE_UDD -> $DEST_UDD" >&2
RSYNC_ARGS=(-a)
for e in "${EXCLUDES[@]}"; do RSYNC_ARGS+=(--exclude="$e"); done
rsync "${RSYNC_ARGS[@]}" "$SOURCE_UDD/" "$DEST_UDD/"
fi

# Extensions:
# --full -> already copied above
# --clone-extensions -> copy into the new profile (~10s)
# default -> fresh empty dir
EXT_DIR="$DEST_UDD/extensions"
mkdir -p "$EXT_DIR"
if [[ "$FULL" != "1" && "$CLONE_EXTENSIONS" == "1" ]]; then
echo "[launch.sh] copying extensions: $SOURCE_UDD/extensions -> $EXT_DIR" >&2
rsync -a "$SOURCE_UDD/extensions/" "$EXT_DIR/"
fi

# Force the simple (quick-input) file dialog so automation can drive
# "Open Folder" / workspace pickers. The native OS file dialog cannot be
# controlled by @playwright/cli over CDP (and is completely unreachable
# over SSH on headless macOS). The setting overlay is per-launch and
# always applied because every launched instance under this skill is
# a throwaway used for automation.
SETTINGS_FILE="$DEST_UDD/User/settings.json"
mkdir -p "$(dirname "$SETTINGS_FILE")"
# Data-preserving text-based merge: insert/update `files.simpleDialog.enable`
# without reparsing the whole file. Avoids dropping user comments and
# string values containing `//` (e.g. URLs). Fails loudly if the file
# exists but has no recognizable JSON object shape — never silently
# overwrites with `{}`.
if ! node - "$SETTINGS_FILE" <<'NODE'
const fs = require('fs');
const f = process.argv[2];
const KEY = 'files.simpleDialog.enable';

let text;
try { text = fs.readFileSync(f, 'utf8'); }
catch (e) {
if (e.code === 'ENOENT') text = '';
else { console.error('[launch.sh] cannot read ' + f + ': ' + e.message); process.exit(1); }
}

// Empty file → write a fresh object.
if (text.trim() === '') {
fs.writeFileSync(f, '{\n "' + KEY + '": true\n}\n');
process.exit(0);
}

// Key already present (with any value) → update its value to `true`
// via a targeted regex on the value slot only.
const keyValueRe = new RegExp('("' + KEY.replace(/\./g, '\\.') + '"\\s*:\\s*)(true|false|null|"[^"\\n]*"|-?\\d+(?:\\.\\d+)?)', 'g');
if (keyValueRe.test(text)) {
const updated = text.replace(keyValueRe, '$1true');
fs.writeFileSync(f, updated);
process.exit(0);
}

// Otherwise: find the LAST `}` and insert the new key before it.
// We deliberately don't parse JSONC — this preserves comments and
// any other content the source profile had.
const lastBrace = text.lastIndexOf('}');
if (lastBrace === -1) {
console.error('[launch.sh] settings.json has no closing brace — refusing to clobber it: ' + f);
process.exit(1);
}

// Decide whether to add a leading comma. If the only thing between the
// first `{` and the last `}` is whitespace and comments, the object is
// empty for our purposes and no comma is needed.
const firstBrace = text.indexOf('{');
if (firstBrace === -1 || firstBrace >= lastBrace) {
console.error('[launch.sh] settings.json has no opening brace — refusing to clobber it: ' + f);
process.exit(1);
}
const between = text.slice(firstBrace + 1, lastBrace)
.replace(/\/\*[\s\S]*?\*\//g, '')
.replace(/\/\/[^\n]*/g, '')
.trim();
const separator = between.length === 0 || between.endsWith(',') ? '' : ',';
const insertion = separator + '\n "' + KEY + '": true\n';

fs.writeFileSync(f, text.slice(0, lastBrace) + insertion + text.slice(lastBrace));
NODE
then
echo "[launch.sh] failed to ensure files.simpleDialog.enable=true in $SETTINGS_FILE — automation may need to fall back to per-key input" >&2
exit 1
fi
echo "[launch.sh] ensured files.simpleDialog.enable=true in $SETTINGS_FILE" >&2

# Strip ELECTRON_RUN_AS_NODE, commonly inherited from VS Code's integrated
# terminal / agent runtimes; it breaks ./scripts/code.sh.
unset ELECTRON_RUN_AS_NODE

CODE_SH="$REPO/scripts/code.sh"
if [[ ! -x "$CODE_SH" ]]; then
echo "Could not find an executable Code OSS launcher at $CODE_SH. Pass --repo <vscode-repo-root>." >&2
exit 2
fi

ARGS=(
"--user-data-dir=$DEST_UDD"
"--extensions-dir=$EXT_DIR"
"--shared-data-dir=$SHARED_DATA_DIR"
"--remote-debugging-port=$CDP_PORT"
"--inspect-extensions=$EXTHOST_PORT"
"--inspect=$MAIN_PORT"
"--inspect-agenthost=$AGENTHOST_PORT"
)
if [[ "$AGENTS" == "1" ]]; then
ARGS=("--agents" "${ARGS[@]}")
fi
if (( ${#EXTRA_ARGS[@]} )); then
ARGS+=("${EXTRA_ARGS[@]}")
fi

LOG_FILE="$RUN_DIR/code.log"
echo "[launch.sh] launching: $CODE_SH ${ARGS[*]}" >&2
echo "[launch.sh] logs: $LOG_FILE" >&2

# Run pre-launch (electron download, compile-if-missing, built-in extensions) in the
# foreground so any errors surface synchronously. Then skip code.sh's own pre-launch.
echo "[launch.sh] running pre-launch (ensures electron + compiled output + built-ins)..." >&2
if ! ( cd "$REPO" && node build/lib/preLaunch.ts ) >>"$LOG_FILE" 2>&1; then
echo "[launch.sh] pre-launch FAILED. Log tail:" >&2
tail -n 80 "$LOG_FILE" >&2
exit 1
fi

# Launch code.sh in the background. Detaching with `nohup ... & disown` is
# sufficient: by the time we return below, CDP is up and Electron is fully
# forked into its own process tree, so it's robust to its launching shell
# going away. (Earlier failures came from returning while Electron was still
# mid-bootstrap, not from process-group concerns.)
nohup env VSCODE_SKIP_PRELAUNCH=1 "$CODE_SH" "${ARGS[@]}" \
</dev/null >>"$LOG_FILE" 2>&1 &
PID=$!
disown $PID 2>/dev/null || true

# Block until the renderer's CDP endpoint is responding so the caller can attach
# immediately. If code.sh dies or we time out, dump the log so the failure is
# visible.
echo "[launch.sh] waiting for CDP on port $CDP_PORT (timeout 90s)..." >&2
READY=0
for i in $(seq 1 90); do
if ! kill -0 "$PID" 2>/dev/null; then
echo "[launch.sh] code.sh (PID $PID) exited before CDP came up. Log tail:" >&2
tail -n 80 "$LOG_FILE" >&2
exit 1
fi
if curl -sf -o /dev/null --max-time 1 "http://127.0.0.1:$CDP_PORT/json/version" 2>/dev/null; then
READY=1
echo "[launch.sh] CDP ready after ${i}s" >&2
break
fi
sleep 1
done
if [[ "$READY" != "1" ]]; then
echo "[launch.sh] timed out waiting for CDP on port $CDP_PORT. Log tail:" >&2
tail -n 80 "$LOG_FILE" >&2
exit 1
fi

node -e '
console.log(JSON.stringify({
pid: '"$PID"',
cdpPort: '"$CDP_PORT"',
extHostPort: '"$EXTHOST_PORT"',
mainPort: '"$MAIN_PORT"',
agentHostPort: '"$AGENTHOST_PORT"',
userDataDir: process.argv[1],
extensionsDir: process.argv[2],
sharedDataDir: process.argv[3],
runDir: process.argv[4],
logFile: process.argv[5],
repo: process.argv[6],
agents: '"$AGENTS"' === 1,
}));
' "$DEST_UDD" "$EXT_DIR" "$SHARED_DATA_DIR" "$RUN_DIR" "$LOG_FILE" "$REPO"
Loading