mirror of
https://github.com/headroomlabs-ai/headroom.git
synced 2026-11-24 19:52:53 +08:00
fix(copilot): keep new VS Code chats on the Local harness so they reach the proxy (#4899)
## Description
VS Code can run a Copilot chat on its "Copilot harness" (Agent Host, the
bundled Copilot SDK runtime) instead of the Local harness. That runtime
ignores `github.copilot.advanced.debug.overrideCapiUrl` /
`overrideProxyUrl`, so the chat goes straight to GitHub. Copilot's small
background calls (title, intent) still reach the proxy, so the proxy
looks connected while the main conversation never arrives. The harness
default (`chat.defaultToCopilotHarness`,
`chat.editor.preferCopilotHarness`) is tagged `experiment: startup` in
VS Code, so it can be flipped per user by rollout.
`headroom wrap vscode` now pins new chats to the Local harness.
## Type of Change
- [x] Bug fix (non-breaking change that fixes an issue)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] Documentation update
- [ ] Performance improvement
- [ ] Code refactoring (no functional changes)
## Changes Made
- `headroom/providers/copilot/vscode.py`: the managed block also writes
`"chat.defaultToCopilotHarness": false` and
`"chat.editor.preferCopilotHarness": false`. Because they sit inside the
marker block, `headroom unwrap vscode` removes them. A harness setting
the user already set outside the block is left alone (no duplicate key).
New helper `copilot_harness_settings_enabled(path)` reports a user value
of `true`.
- `headroom/cli/wrap.py`: one line saying new chats stay on the Local
harness and existing chats keep their engine; a warning instead when the
user's own setting is `true`. `--no-configure` prints the two extra
settings.
- `docs/content/docs/vscode-copilot.mdx`: documents the harness settings
and the troubleshooting case.
- Blocks written by older versions (including ones with
`overrideAuthType`) are replaced by marker as before.
## Testing
- [x] Unit tests pass (`pytest`)
- [x] Linting passes (`ruff check .`)
- [ ] Type checking passes (`mypy headroom`)
- [x] New tests added for new functionality
- [x] Manual testing performed
### Test Output
```text
tests/test_provider_copilot_vscode_config.py + tests/test_cli/test_wrap_vscode.py: 32 passed.
Against origin/main source: 7 of those fail (block contents, old-block upgrade, user-set key [True]/[False], wrap output, --no-configure output).
ruff 0.17.4 check + format --check on the 5 changed Python files: clean.
mypy on the changed source files: 8 errors, all in headroom/cache/prefix_tracker.py and headroom/ccr/mcp_server.py, identical on origin/main; none in changed files.
```
## Real Behavior Proof
- Environment: macOS 27.2.1, Python 3.12.13, VS Code 1.145.2 with GitHub
Copilot signed in, core run from this branch, real GitHub Copilot
upstream. Real user `settings.json` (backed up and restored afterwards).
- Exact command / steps:
1. `headroom wrap vscode -p 8795` from this branch.
2. `code chat -n -m agent "Reply with the single word OK and nothing
else."` (opens a new VS Code window and sends one Agent-mode chat).
3. Read the proxy's `/stats`, VS Code's `agenthost.log`, then `headroom
unwrap vscode`.
- Observed result:
```text
VS Code Copilot proxy settings updated: ~/Library/Application
Support/Code/User/settings.json
Keep using Copilot's normal model picker; the selected model is
preserved.
New chats stay on VS Code's Local harness; a chat keeps the engine it
started with, so start a new chat.
settings.json after wrap:
{
// --- Headroom Copilot proxy ---
"github.copilot.advanced.debug.overrideProxyUrl":
"http://127.0.0.1:8795/p/win-local",
"github.copilot.advanced.debug.overrideCapiUrl":
"http://127.0.0.1:8795/p/win-local",
"chat.defaultToCopilotHarness": false,
"chat.editor.preferCopilotHarness": false
// --- end Headroom Copilot proxy ---
}
proxy requests before chat: 0 {}
proxy requests after one Agent-mode chat in a new VS Code window: 4
{'gpt-4o-mini-2024-07-18': 3, 'claude-opus-5.5': 1}
agent host turns during the chat: 0
Removed Headroom Copilot proxy settings from ~/Library/Application
Support/Code/User/settings.json
settings.json after unwrap:
{
}
```
Separately, on the same machine with the settings edited by hand (same
VS Code, same proxy, new window each time):
`"chat.defaultToCopilotHarness": true` -> the Agent-mode chat ran in the
Agent Host (provider `copilotcli`) and 0 requests reached the proxy;
`"chat.defaultToCopilotHarness": false` +
`"chat.editor.preferCopilotHarness": false` -> Local harness, 4 requests
reached the proxy including the main `/v1/messages` call.
`"chat.temporaryDefaultToLocalHarness": true` as a user setting had no
effect, so it is not written.
- Not tested: a VS Code where Microsoft's rollout has flipped the
default (the explicit user value is expected to win, but that could not
be reproduced); an organization that enforces managed sandbox settings,
where VS Code can require the Copilot harness regardless; VS Code
profiles, workspace-level settings, Insiders/VSCodium; Windows and
Linux; the persistent `headroom start --persistent --vscode` path in the
Enterprise client.
## Runtime Rollout Safety
- Rollout-managed feature(s): none.
- Minimum rollout channel: n/a.
- Stable/default behavior changed: `headroom wrap vscode` writes two
more VS Code user settings inside its managed block. No proxy behaviour
changes.
- Kill switch / disable path: `headroom unwrap vscode` removes them; a
user who sets either key themselves keeps their value.
- Unsafe override required: no.
- Qualification impact: none expected.
- Rollback path: revert this commit; `unwrap` removes blocks of either
format.
## Review Readiness
- [x] I have performed a self-review
- [x] This PR is ready for human review
## Checklist
- [x] My code follows the project's style guidelines
- [x] I have performed a self-review of my code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] New and existing unit tests pass locally with my changes
- [x] I did **not** edit `CHANGELOG.md` — it is generated by
release-please from my Conventional Commit PR title (a CI guard enforces
this)
## Additional Notes
- This keeps users off the Copilot harness; it does not route that
harness through Headroom. Supporting it is separate work.
- Only the configured settings file is checked for a user value. A
`true` in workspace settings, another profile, or policy is not
detected.
- After `unwrap` the keys return to VS Code's default, which a rollout
may move to the Copilot harness.
- Existing chats keep the harness they started with; the wrap output
says to start a new chat.
- `e2e/copilot_live.py` and `e2e/wrap/run.py` were not run.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- devin-review-badge-begin -->
---
<a href="https://app.devin.ai/review/headroomlabs-ai/headroom/pull/4899"
target="_blank"><picture><source media="(prefers-color-scheme: dark)"
srcset="https://static.devin.ai/assets/gh-devin-review-dark.svg?v=4"><img
src="https://static.devin.ai/assets/gh-devin-review-light.svg?v=4"
alt="Devin Review"></picture></a>
<!-- devin-review-badge-end -->
Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
Co-authored-by: JD Davis <mxjerrett@gmail.com>
This commit is contained in:
co-authored by
Claude Fable 5.2
JD Davis
parent
b560cba927
commit
0d203db6b8
@@ -46,7 +46,9 @@ The command:
|
||||
2. starts Headroom on `127.0.0.1:8787` with the short-lived upstream token;
|
||||
3. adds a marker-owned block to VS Code user settings containing
|
||||
`github.copilot.advanced.debug.overrideProxyUrl` (inline completions) and
|
||||
`github.copilot.advanced.debug.overrideCapiUrl` (chat);
|
||||
`github.copilot.advanced.debug.overrideCapiUrl` (chat), plus
|
||||
`chat.defaultToCopilotHarness` and `chat.editor.preferCopilotHarness` set to
|
||||
`false` so new chats stay on VS Code's Local harness;
|
||||
4. keeps running until `Ctrl+C` so the local proxy is available to VS Code.
|
||||
|
||||
Continue using Copilot's normal model picker. The request body—and therefore the
|
||||
@@ -69,6 +71,14 @@ Copilot UI: user selects model M
|
||||
-> response from model M
|
||||
```
|
||||
|
||||
## Chat harness
|
||||
|
||||
A chat running on VS Code's Copilot harness (Agent Host) ignores the endpoint
|
||||
overrides and bypasses Headroom, so the managed block keeps new chats on the
|
||||
Local harness. A chat keeps the engine it started with: start a new chat after
|
||||
running `headroom wrap vscode`. If you already set either harness setting
|
||||
yourself, Headroom leaves your value alone and warns when it is `true`.
|
||||
|
||||
## Safe settings lifecycle
|
||||
|
||||
Headroom edits only a marked block in VS Code's `settings.json`. Existing JSONC
|
||||
@@ -89,7 +99,7 @@ remote extension host, provide the exact user settings file:
|
||||
headroom wrap vscode --settings-file /path/to/User/settings.json
|
||||
```
|
||||
|
||||
Use `--no-configure` to print the two settings without editing a file.
|
||||
Use `--no-configure` to print the settings without editing a file.
|
||||
|
||||
## Model coverage
|
||||
|
||||
@@ -183,6 +193,9 @@ or `GITHUB_COPILOT_ENTERPRISE_DOMAIN` before both `copilot-auth login` and
|
||||
- If Headroom records no requests while Copilot keeps working, the window is
|
||||
probably using a VS Code profile with its own settings. `wrap vscode` warns
|
||||
about each such profile and prints the `--settings-file` path to configure it.
|
||||
- If only some chats are missing, they are running on the Copilot harness: start
|
||||
a new chat, and set `chat.defaultToCopilotHarness` and
|
||||
`chat.editor.preferCopilotHarness` to `false` if you had set them to `true`.
|
||||
- Use `--port 8788` when the default port is occupied; settings update safely.
|
||||
- If Headroom refuses settings, repair the reported JSONC/marker conflict or use
|
||||
`--no-configure` and apply the printed settings manually.
|
||||
|
||||
+15
-1
@@ -132,6 +132,7 @@ from headroom.providers.copilot import (
|
||||
)
|
||||
from headroom.providers.copilot import (
|
||||
configure_vscode_proxy_settings,
|
||||
copilot_harness_settings_enabled,
|
||||
remove_vscode_proxy_settings,
|
||||
unrouted_vscode_profiles,
|
||||
vscode_proxy_url,
|
||||
@@ -7390,14 +7391,27 @@ def vscode_copilot(
|
||||
click.echo(
|
||||
" Keep using Copilot's normal model picker; the selected model is preserved."
|
||||
)
|
||||
user_enabled = copilot_harness_settings_enabled(target_settings)
|
||||
for key in user_enabled:
|
||||
click.echo(
|
||||
f' Warning: {target_settings} sets "{key}": true, so chats on the '
|
||||
"Copilot harness bypass Headroom. Set it to false to route them."
|
||||
)
|
||||
if not user_enabled:
|
||||
click.echo(
|
||||
" New chats stay on VS Code's Local harness; a chat keeps the engine it "
|
||||
"started with, so start a new chat."
|
||||
)
|
||||
return
|
||||
click.echo(" Add these user settings to VS Code:")
|
||||
click.echo(
|
||||
f' "github.copilot.advanced.debug.overrideProxyUrl": "{vscode_proxy_url(actual_port, _project_name_from_cwd())}",'
|
||||
)
|
||||
click.echo(
|
||||
f' "github.copilot.advanced.debug.overrideCapiUrl": "{vscode_proxy_url(actual_port, _project_name_from_cwd())}"'
|
||||
f' "github.copilot.advanced.debug.overrideCapiUrl": "{vscode_proxy_url(actual_port, _project_name_from_cwd())}",'
|
||||
)
|
||||
click.echo(' "chat.defaultToCopilotHarness": false,')
|
||||
click.echo(' "chat.editor.preferCopilotHarness": false')
|
||||
|
||||
_run_proxy_only_watcher(
|
||||
agent_label="VS CODE COPILOT",
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
from .vscode import (
|
||||
configure_vscode_proxy_settings,
|
||||
copilot_harness_settings_enabled,
|
||||
remove_vscode_proxy_settings,
|
||||
unrouted_vscode_profiles,
|
||||
vscode_proxy_url,
|
||||
@@ -37,6 +38,7 @@ __all__ = [
|
||||
"strip_auto_model_args",
|
||||
"validate_configuration",
|
||||
"configure_vscode_proxy_settings",
|
||||
"copilot_harness_settings_enabled",
|
||||
"remove_vscode_proxy_settings",
|
||||
"unrouted_vscode_profiles",
|
||||
"vscode_proxy_url",
|
||||
|
||||
@@ -28,6 +28,11 @@ _CAPI_KEY = "github.copilot.advanced.debug.overrideCapiUrl"
|
||||
# VS Code flags unknown keys, and shipping one that does nothing invited the
|
||||
# conclusion that the override mechanism had stopped working.
|
||||
_AUTH_KEY = "github.copilot.advanced.debug.overrideAuthType"
|
||||
# A chat on VS Code's "Copilot harness" (Agent Host, the bundled Copilot SDK
|
||||
# runtime) ignores both endpoint overrides and never reaches the proxy. Both
|
||||
# settings default to false but are tagged `experiment: startup`, so a rollout
|
||||
# can flip them per user; only an explicit user value pins the Local harness.
|
||||
_COPILOT_HARNESS_KEYS = ("chat.defaultToCopilotHarness", "chat.editor.preferCopilotHarness")
|
||||
|
||||
|
||||
def _read_settings(path: Path) -> str:
|
||||
@@ -115,7 +120,7 @@ def _parse_settings(raw: str) -> object:
|
||||
return json.loads(re.sub(r",\s*([}\]])", r"\1", candidate))
|
||||
|
||||
|
||||
def _validate_settings(raw: str, path: Path) -> None:
|
||||
def _validate_settings(raw: str, path: Path) -> dict[str, object]:
|
||||
try:
|
||||
parsed = _parse_settings(raw)
|
||||
except json.JSONDecodeError as exc:
|
||||
@@ -124,16 +129,17 @@ def _validate_settings(raw: str, path: Path) -> None:
|
||||
) from exc
|
||||
if not isinstance(parsed, dict):
|
||||
raise click.ClickException(f"{path} must contain a JSON object; refusing to overwrite it.")
|
||||
return parsed
|
||||
|
||||
|
||||
def _managed_block(proxy_url: str, *, owns_preceding_comma: bool, line_sep: str) -> str:
|
||||
def _managed_block(
|
||||
settings: Mapping[str, object], *, owns_preceding_comma: bool, line_sep: str
|
||||
) -> str:
|
||||
marker = _MARKER_START + (" (comma-added)" if owns_preceding_comma else "")
|
||||
return (
|
||||
f"\t{marker}{line_sep}"
|
||||
f"\t{json.dumps(_PROXY_KEY)}: {json.dumps(proxy_url)},{line_sep}"
|
||||
f"\t{json.dumps(_CAPI_KEY)}: {json.dumps(proxy_url)}{line_sep}"
|
||||
f"\t{_MARKER_END}"
|
||||
entries = f",{line_sep}".join(
|
||||
f"\t{json.dumps(key)}: {json.dumps(value)}" for key, value in settings.items()
|
||||
)
|
||||
return f"\t{marker}{line_sep}{entries}{line_sep}\t{_MARKER_END}"
|
||||
|
||||
|
||||
def remove_vscode_proxy_settings(path: Path) -> bool:
|
||||
@@ -166,7 +172,12 @@ def remove_vscode_proxy_settings(path: Path) -> bool:
|
||||
|
||||
|
||||
def configure_vscode_proxy_settings(path: Path, proxy_url: str) -> str:
|
||||
"""Add/update transparent routing while preserving all non-Headroom text."""
|
||||
"""Add/update transparent routing while preserving all non-Headroom text.
|
||||
|
||||
The block also pins new chats to the Local harness, except for a harness
|
||||
setting the user already set themselves: theirs is left alone, and
|
||||
``copilot_harness_settings_enabled`` reports it when it bypasses Headroom.
|
||||
"""
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
raw = _read_settings(path) if path.exists() else "{}\n"
|
||||
_validate_settings(raw, path)
|
||||
@@ -179,6 +190,9 @@ def configure_vscode_proxy_settings(path: Path, proxy_url: str) -> str:
|
||||
f"{path} already configures a Copilot endpoint override outside Headroom's "
|
||||
"managed block; refusing to replace it. Remove it or use --no-configure."
|
||||
)
|
||||
user_settings = _validate_settings(raw, path)
|
||||
managed: dict[str, object] = {_PROXY_KEY: proxy_url, _CAPI_KEY: proxy_url}
|
||||
managed.update({key: False for key in _COPILOT_HARNESS_KEYS if key not in user_settings})
|
||||
|
||||
close = raw.rfind("}")
|
||||
if close < 0:
|
||||
@@ -194,7 +208,7 @@ def configure_vscode_proxy_settings(path: Path, proxy_url: str) -> str:
|
||||
before
|
||||
+ separator
|
||||
+ newline
|
||||
+ _managed_block(proxy_url, owns_preceding_comma=needs_comma, line_sep=line_sep)
|
||||
+ _managed_block(managed, owns_preceding_comma=needs_comma, line_sep=line_sep)
|
||||
+ line_sep
|
||||
+ after
|
||||
)
|
||||
@@ -203,6 +217,12 @@ def configure_vscode_proxy_settings(path: Path, proxy_url: str) -> str:
|
||||
return "updated" if had_managed_block else "added"
|
||||
|
||||
|
||||
def copilot_harness_settings_enabled(path: Path) -> list[str]:
|
||||
"""Return the harness settings in ``path`` that send new chats around Headroom."""
|
||||
settings = _validate_settings(_read_settings(path), path)
|
||||
return [key for key in _COPILOT_HARNESS_KEYS if settings.get(key) is True]
|
||||
|
||||
|
||||
def unrouted_vscode_profiles(user_dir: Path) -> list[tuple[str, Path]]:
|
||||
"""Return ``(name, settings.json)`` for profiles that ignore ``user_dir/settings.json``.
|
||||
|
||||
|
||||
@@ -44,6 +44,11 @@ def test_wrap_vscode_configures_actual_port_and_seeds_subscription(tmp_path: Pat
|
||||
assert "http://127.0.0.1:9999/" in settings
|
||||
assert "model" not in settings.lower()
|
||||
assert "normal model picker" in result.output
|
||||
# Chats on the Copilot harness never reach the proxy, and a chat keeps the
|
||||
# engine it started with, so the user has to be told to start a new one.
|
||||
assert "Local harness" in result.output
|
||||
assert "start a new chat" in result.output
|
||||
assert "Warning" not in result.output
|
||||
assert captured["openai_api_url"] == "https://api.githubcopilot.com"
|
||||
assert captured["copilot_api_token"] == "copilot-token"
|
||||
|
||||
@@ -120,6 +125,20 @@ def test_wrap_vscode_checks_the_profiles_of_the_user_dir_it_configures(
|
||||
assert "Work" not in output
|
||||
|
||||
|
||||
def test_wrap_vscode_warns_when_the_user_opted_into_the_copilot_harness(tmp_path: Path) -> None:
|
||||
path = tmp_path / "settings.json"
|
||||
path.write_text('{\n "chat.editor.preferCopilotHarness": true\n}\n', encoding="utf-8")
|
||||
|
||||
output = _run_wrap_vscode("--settings-file", str(path))
|
||||
|
||||
# The wrap still succeeds and keeps the user's choice, but says what it costs.
|
||||
assert '"chat.editor.preferCopilotHarness": true' in output
|
||||
assert "bypass Headroom" in output
|
||||
assert "chat.defaultToCopilotHarness" not in output
|
||||
assert "stay on VS Code's Local harness" not in output
|
||||
assert path.read_text(encoding="utf-8").count("preferCopilotHarness") == 1
|
||||
|
||||
|
||||
def test_wrap_vscode_no_configure_prints_transparent_settings(tmp_path: Path) -> None:
|
||||
path = tmp_path / "settings.json"
|
||||
|
||||
@@ -141,6 +160,8 @@ def test_wrap_vscode_no_configure_prints_transparent_settings(tmp_path: Path) ->
|
||||
assert not path.exists()
|
||||
assert "overrideProxyUrl" in result.output
|
||||
assert "overrideCapiUrl" in result.output
|
||||
assert '"chat.defaultToCopilotHarness": false' in result.output
|
||||
assert '"chat.editor.preferCopilotHarness": false' in result.output
|
||||
# No `overrideAuthType`: the setting does not exist in the modern Copilot
|
||||
# Chat extension, so printing it told users to add a key VS Code flags as
|
||||
# unknown and which does nothing (#3076).
|
||||
|
||||
@@ -8,6 +8,7 @@ import pytest
|
||||
|
||||
from headroom.providers.copilot.vscode import (
|
||||
configure_vscode_proxy_settings,
|
||||
copilot_harness_settings_enabled,
|
||||
remove_vscode_proxy_settings,
|
||||
unrouted_vscode_profiles,
|
||||
vscode_proxy_url,
|
||||
@@ -67,6 +68,77 @@ def test_configure_update_and_remove_preserve_jsonc_verbatim(tmp_path: Path) ->
|
||||
assert remove_vscode_proxy_settings(path) is False
|
||||
|
||||
|
||||
def _live_settings(path: Path) -> dict[str, object]:
|
||||
"""Parse the written JSONC the way VS Code does: comments and trailing commas ignored."""
|
||||
lines = path.read_text(encoding="utf-8").splitlines()
|
||||
body = "\n".join(line for line in lines if not line.strip().startswith("//"))
|
||||
return json.loads(body.replace(",\n}", "\n}"))
|
||||
|
||||
|
||||
def test_configure_keeps_new_chats_on_the_local_harness(tmp_path: Path) -> None:
|
||||
path = tmp_path / "settings.json"
|
||||
original = '{\n\t"editor.fontSize": 15\n}\n'
|
||||
path.write_text(original, encoding="utf-8")
|
||||
|
||||
configure_vscode_proxy_settings(path, "http://127.0.0.1:8787")
|
||||
|
||||
# A chat on the Copilot harness ignores the endpoint overrides, and VS Code
|
||||
# can flip either default by rollout, so both are pinned explicitly.
|
||||
settings = _live_settings(path)
|
||||
assert settings["chat.defaultToCopilotHarness"] is False
|
||||
assert settings["chat.editor.preferCopilotHarness"] is False
|
||||
assert copilot_harness_settings_enabled(path) == []
|
||||
assert remove_vscode_proxy_settings(path) is True
|
||||
assert path.read_text(encoding="utf-8") == original
|
||||
|
||||
|
||||
def test_configure_upgrades_a_block_written_before_the_harness_settings(tmp_path: Path) -> None:
|
||||
path = tmp_path / "settings.json"
|
||||
original = '{\n\t"editor.fontSize": 15\n}\n'
|
||||
path.write_text(
|
||||
'{\n\t"editor.fontSize": 15,\n'
|
||||
"\t// --- Headroom Copilot proxy --- (comma-added)\n"
|
||||
'\t"github.copilot.advanced.debug.overrideProxyUrl": "http://127.0.0.1:8787",\n'
|
||||
'\t"github.copilot.advanced.debug.overrideAuthType": "token",\n'
|
||||
'\t"github.copilot.advanced.debug.overrideCapiUrl": "http://127.0.0.1:8787"\n'
|
||||
"\t// --- end Headroom Copilot proxy ---\n}\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
assert configure_vscode_proxy_settings(path, "http://127.0.0.1:8787") == "updated"
|
||||
|
||||
settings = _live_settings(path)
|
||||
assert settings["chat.defaultToCopilotHarness"] is False
|
||||
assert settings["chat.editor.preferCopilotHarness"] is False
|
||||
assert "github.copilot.advanced.debug.overrideAuthType" not in settings
|
||||
assert remove_vscode_proxy_settings(path) is True
|
||||
assert path.read_text(encoding="utf-8") == original
|
||||
|
||||
|
||||
@pytest.mark.parametrize("user_value", [True, False])
|
||||
def test_configure_leaves_a_harness_setting_the_user_already_chose(
|
||||
tmp_path: Path, user_value: bool
|
||||
) -> None:
|
||||
path = tmp_path / "settings.json"
|
||||
original = f'{{\n\t"chat.defaultToCopilotHarness": {json.dumps(user_value)},\n}}\n'
|
||||
path.write_text(original, encoding="utf-8")
|
||||
|
||||
for _ in range(2): # a re-run must not start writing the key either
|
||||
configure_vscode_proxy_settings(path, "http://127.0.0.1:8787")
|
||||
configured = path.read_text(encoding="utf-8")
|
||||
# A second copy inside the block would win silently: JSONC keeps the last one.
|
||||
assert configured.count('"chat.defaultToCopilotHarness"') == 1
|
||||
settings = _live_settings(path)
|
||||
assert settings["chat.defaultToCopilotHarness"] is user_value
|
||||
assert settings["chat.editor.preferCopilotHarness"] is False
|
||||
assert copilot_harness_settings_enabled(path) == (
|
||||
["chat.defaultToCopilotHarness"] if user_value else []
|
||||
)
|
||||
|
||||
assert remove_vscode_proxy_settings(path) is True
|
||||
assert path.read_text(encoding="utf-8") == original
|
||||
|
||||
|
||||
def test_configure_refuses_malformed_and_unmanaged_override(tmp_path: Path) -> None:
|
||||
path = tmp_path / "settings.json"
|
||||
for original in (
|
||||
|
||||
Reference in New Issue
Block a user