Compare commits
8
Commits
v0.4.6
...
v0.4.8-mac
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
01e72e4785 | ||
|
|
2b35aa8c16 | ||
|
|
65a3d4eb29 | ||
|
|
2b2d9da606 | ||
|
|
3741e0fef5 | ||
|
|
0e6566d903 | ||
|
|
84a67fcd0d | ||
|
|
f3cc1c4c17 |
@@ -39,13 +39,48 @@ jobs:
|
||||
MAJOR_MINOR=$(cat VERSION | tr -d '[:space:]')
|
||||
echo "Major.Minor: ${MAJOR_MINOR}"
|
||||
|
||||
# Find the latest tag matching v{MAJOR_MINOR}.N (exclude -mac, -win suffixes)
|
||||
# `|| true` so an empty grep result doesn't fail the step under pipefail.
|
||||
LATEST_TAG=$(git tag -l "v${MAJOR_MINOR}.*" --sort=-v:refname | grep -E "^v${MAJOR_MINOR}\.[0-9]+$" | head -1 || true)
|
||||
# The patch number is **one past the highest patch already used**, and
|
||||
# never a distance.
|
||||
#
|
||||
# It used to be `git rev-list --count <highest tag>..HEAD`, which is
|
||||
# not a counter at all: it measures how far HEAD has drifted from
|
||||
# whichever tag sorts highest, and that resets to zero every time a
|
||||
# tag is cut. The published history is the proof — each of these is
|
||||
# exactly what the old formula returned at the time:
|
||||
#
|
||||
# v0.4.0 -> 3 commits -> v0.4.3 looked fine
|
||||
# v0.4.3 -> 4 commits -> v0.4.4 fine by luck, 4 > 3
|
||||
# v0.4.4 -> 2 commits -> v0.4.2 went backwards
|
||||
# v0.4.4 -> 6 commits -> v0.4.6 jumped, skipping .5
|
||||
# v0.4.6 -> 3 commits -> v0.4.3 already taken; the upload failed
|
||||
#
|
||||
# Reusing a version is worse than failing to publish one: the macOS
|
||||
# and Windows steps replace assets in place, so a duplicate silently
|
||||
# rewrote a release that had been public for three days. Monotonic
|
||||
# numbering is what stops that at the source.
|
||||
#
|
||||
# Suffixed tags count too. `create-tag` is skipped when any platform
|
||||
# job fails, so a run can publish v0.4.7-mac and never create the
|
||||
# plain v0.4.7 — reading only unsuffixed tags would then hand the
|
||||
# same number out twice.
|
||||
HIGHEST=$(git tag -l "v${MAJOR_MINOR}.*" \
|
||||
| grep -E "^v${MAJOR_MINOR}\.[0-9]+(-mac|-win)?$" \
|
||||
| sed -E "s/^v${MAJOR_MINOR}\.([0-9]+).*/\1/" \
|
||||
| sort -n | tail -1 || true)
|
||||
|
||||
if [ -n "$LATEST_TAG" ]; then
|
||||
echo "Latest matching tag: ${LATEST_TAG}"
|
||||
PATCH=$(git rev-list --count "${LATEST_TAG}..HEAD")
|
||||
# A re-run of a commit that already released must not mint a new
|
||||
# version just because its own tag now exists.
|
||||
EXISTING=$(git tag --points-at HEAD \
|
||||
| grep -E "^v${MAJOR_MINOR}\.[0-9]+$" \
|
||||
| sed -E "s/^v${MAJOR_MINOR}\.([0-9]+)$/\1/" \
|
||||
| sort -n | tail -1 || true)
|
||||
|
||||
if [ -n "$EXISTING" ]; then
|
||||
echo "HEAD is already tagged v${MAJOR_MINOR}.${EXISTING} — reusing it"
|
||||
PATCH="${EXISTING}"
|
||||
elif [ -n "$HIGHEST" ]; then
|
||||
echo "Highest patch already used on this line: ${HIGHEST}"
|
||||
PATCH=$((HIGHEST + 1))
|
||||
else
|
||||
# A minor line nobody has tagged yet is a *new* line, and a new line
|
||||
# starts at .0 — that is what "we are moving to 0.4.x" means. The
|
||||
@@ -165,21 +200,70 @@ jobs:
|
||||
env:
|
||||
TOKEN: ${{ secrets.REGISTRY_TOKEN }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
TAG="v${{ needs.compute-version.outputs.version }}"
|
||||
# Create release
|
||||
curl -s -X POST \
|
||||
|
||||
# Idempotent get-or-create, matching build-macos. This step used to
|
||||
# POST /releases unconditionally: against a tag that already existed
|
||||
# Gitea answered 409, the grep below found no id, and the run died
|
||||
# with a bare "exitcode '1'" and not one line of output explaining
|
||||
# it — `curl -s` with no `-f` swallows the HTTP error, so nothing
|
||||
# ever said "409" or "duplicate tag". Hence -fsS throughout, and
|
||||
# pipefail so a failure cannot be stepped over.
|
||||
HTTP_CODE=$(curl -sS -o release.json -w '%{http_code}' \
|
||||
-H "Authorization: token ${TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"tag_name\": \"${TAG}\", \"name\": \"Triple-C ${TAG} (Linux)\", \"body\": \"Automated build from commit ${{ gitea.sha }}\"}" \
|
||||
"${GITEA_URL}/api/v1/repos/${REPO}/releases" > release.json
|
||||
RELEASE_ID=$(cat release.json | grep -o '"id":[0-9]*' | head -1 | grep -o '[0-9]*')
|
||||
"${GITEA_URL}/api/v1/repos/${REPO}/releases/tags/${TAG}")
|
||||
case "${HTTP_CODE}" in
|
||||
200)
|
||||
echo "Release ${TAG} already exists, reusing"
|
||||
;;
|
||||
404)
|
||||
echo "Creating release ${TAG}"
|
||||
curl -fsS -X POST \
|
||||
-H "Authorization: token ${TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"tag_name\": \"${TAG}\", \"name\": \"Triple-C ${TAG} (Linux)\", \"body\": \"Automated build from commit ${{ gitea.sha }}\"}" \
|
||||
"${GITEA_URL}/api/v1/repos/${REPO}/releases" > release.json
|
||||
;;
|
||||
*)
|
||||
echo "Unexpected ${HTTP_CODE} looking up release ${TAG}:" >&2
|
||||
cat release.json >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
RELEASE_ID=$(python3 -c "import json,sys; print(json.load(open('release.json')).get('id',''))")
|
||||
if [ -z "${RELEASE_ID}" ]; then
|
||||
echo "No release id for ${TAG}; refusing to upload into nothing:" >&2
|
||||
cat release.json >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "Release ID: ${RELEASE_ID}"
|
||||
# Upload each artifact
|
||||
|
||||
# Replace-not-conflict, so a retry after a partial upload succeeds.
|
||||
# Versions are monotonic now (see compute-version), so this can only
|
||||
# ever be replacing an asset from a failed run of this same commit —
|
||||
# never one belonging to an already-published version.
|
||||
for file in artifacts/*; do
|
||||
[ -f "$file" ] || continue
|
||||
filename=$(basename "$file")
|
||||
|
||||
EXISTING_ID=$(curl -sS \
|
||||
-H "Authorization: token ${TOKEN}" \
|
||||
"${GITEA_URL}/api/v1/repos/${REPO}/releases/${RELEASE_ID}/assets" \
|
||||
| python3 -c "import json,sys; t=sys.argv[1]; print(next((a['id'] for a in json.load(sys.stdin) if a.get('name')==t), ''))" "${filename}" || true)
|
||||
if [ -n "${EXISTING_ID}" ]; then
|
||||
echo "Deleting existing asset ${filename} (id ${EXISTING_ID})"
|
||||
curl -fsS -X DELETE \
|
||||
-H "Authorization: token ${TOKEN}" \
|
||||
"${GITEA_URL}/api/v1/repos/${REPO}/releases/${RELEASE_ID}/assets/${EXISTING_ID}"
|
||||
fi
|
||||
|
||||
echo "Uploading ${filename}..."
|
||||
curl -s -X POST \
|
||||
curl -fsS --http1.1 \
|
||||
--retry 5 --retry-all-errors --retry-delay 5 \
|
||||
--max-time 600 \
|
||||
-X POST \
|
||||
-H "Authorization: token ${TOKEN}" \
|
||||
-H "Content-Type: application/octet-stream" \
|
||||
--data-binary "@${file}" \
|
||||
|
||||
@@ -273,6 +273,41 @@ migration and Reset. Four things here are not obvious:
|
||||
actively **removes** `triple-c-*.crt` when the setting is cleared — `/usr/local/share` rides the
|
||||
project's snapshot image, so turning the feature off has to undo, not merely stop.
|
||||
|
||||
### VPN support (`vpn_support_enabled`, `docker/container.rs`)
|
||||
|
||||
An opt-in per-project switch granting the container what a VPN client needs to build a tunnel.
|
||||
`vpn_host_config()` is the single definition of what that means, and it is unit-tested because a
|
||||
container is created once by a very long function where a dropped capability is invisible.
|
||||
|
||||
- **All three pieces or none.** `CAP_NET_ADMIN` (Docker's default set has `net_raw` but *not*
|
||||
`net_admin`, so a client can ping but never connect), the `/dev/net/tun` device (absent
|
||||
entirely from a default container — nothing to open even with the capability), and
|
||||
`net.ipv4.conf.all.src_valid_mark=1` (WireGuard's `wg-quick` sets it and cannot from inside a
|
||||
container, since `/proc/sys` is read-only, so handshake packets die to reverse-path filtering).
|
||||
Any two without the third still presents as a connection that hangs to a timeout, which is why
|
||||
the tests assert the whole set.
|
||||
- **The device is passed through from the host, never `mknod`-ed inside.** The kernel's `tun`
|
||||
module has to back it.
|
||||
- **A missing device fails at `start`, not `create` — verified against Docker 29.7.** `docker
|
||||
create --device /dev/does-not-exist` succeeds and prints an id; runc resolves the device (and
|
||||
validates sysctls) only when it builds the container. So the guard belongs on the start path:
|
||||
`explain_container_failure()` covers both and is called from `start_container`, where it has a
|
||||
container id and no project — which is why it keys off the error naming `/dev/net/tun` rather
|
||||
than off `vpn_support_enabled`. Nothing else in Triple-C requests a device, so that is
|
||||
unambiguous. A version of this check wired to `create` alone is dead code that looks correct.
|
||||
- **`NET_ADMIN` here is not user-namespaced.** Docker does not enable userns remapping by default,
|
||||
so only the *network* namespace confines it: no reach onto host interfaces, but promiscuous
|
||||
mode, arbitrary addresses/routes/NAT on the shared `docker0` segment (sibling containers, the
|
||||
LiteLLM gateway among them, are ARP-spoofable), netlink-triggered host module auto-load, and
|
||||
enough authority to flush in-container netfilter rules that sandbox mode may rely on. Keep the
|
||||
code comments honest about this — an earlier draft claimed it "confers no authority" outside the
|
||||
container, which is too strong.
|
||||
- **`triple-c.vpn-support` is written unconditionally, including `false`.** The usual
|
||||
`docker commit` reason: a `true` stamped once would ride the snapshot image into every future
|
||||
container and make the switch impossible to turn off.
|
||||
- Off is byte-identical to a container created before the feature existed, and a missing label
|
||||
reads as `false`, so no existing project is churned.
|
||||
|
||||
### Container Lifecycle
|
||||
|
||||
Containers use a **stop/start** model (not create/destroy). Installed packages persist across stops. The `.claude` config dir uses a named Docker volume (`triple-c-claude-config-{projectId}`), nested inside the home volume (`triple-c-home-{projectId}`), so OAuth tokens and Claude Code config survive container stop/start *and* container recreation.
|
||||
|
||||
@@ -471,6 +471,37 @@ When enabled, the host Docker socket is mounted into the container so Claude Cod
|
||||
|
||||
> Toggling this requires stopping and restarting the container to take effect.
|
||||
|
||||
### VPN Support
|
||||
|
||||
When enabled, the container is given the three things a VPN client needs to build a tunnel:
|
||||
the `NET_ADMIN` capability, the `/dev/net/tun` device, and the `net.ipv4.conf.all.src_valid_mark`
|
||||
sysctl that WireGuard requires. This is **off by default**.
|
||||
|
||||
Without it, a client such as PIA, WireGuard or OpenVPN installs and its daemon starts normally, but
|
||||
the connection attempt **hangs until it times out** — a default container has no tun device to open
|
||||
and no permission to add an interface or a route, and most clients report that as a generic timeout
|
||||
rather than a permissions error.
|
||||
|
||||
Things worth knowing:
|
||||
|
||||
- Tailscale is the exception: in its `--tun=userspace-networking` mode it needs neither the
|
||||
capability nor the device, so leave this off if that is all you want.
|
||||
|
||||
- `NET_ADMIN` applies to the container's **own** network namespace — it cannot touch the host's
|
||||
interfaces. It is not nothing, though: within that namespace anything in the container can set
|
||||
promiscuous mode and add arbitrary addresses, routes and firewall rules on the Docker bridge it
|
||||
shares with your other containers, and it can flush firewall rules that sandbox mode relies on.
|
||||
Grant it per project, to projects that need it.
|
||||
- The **Docker host's** kernel must have the `tun` module available. With Docker Desktop that is
|
||||
the Linux VM, not your own machine. If it is missing, the container is created but fails to
|
||||
**start**, with an error naming `/dev/net/tun` and pointing back at this setting.
|
||||
- A VPN client's kill switch applies to everything in the container, Claude Code included. If the
|
||||
tunnel drops, expect API calls to fail until it reconnects or the kill switch is turned off.
|
||||
|
||||
> This setting can only be changed when the container is stopped. Capabilities and devices are
|
||||
> fixed when a container is created, so toggling it recreates the container on the next start.
|
||||
> Recreation preserves the home and `.claude` volumes — it is not a Reset.
|
||||
|
||||
### Mission Control
|
||||
|
||||
Toggle **Mission Control** to integrate Flight Control — an AI-first development methodology bundled with Triple-C — into the project. When enabled:
|
||||
|
||||
@@ -194,11 +194,24 @@ impl BrowserTarget {
|
||||
}
|
||||
}
|
||||
|
||||
/// The `channel` a launch check must pass. `None` means the bundled build.
|
||||
fn channel(self) -> Option<&'static str> {
|
||||
/// Every `channel` a launch check must pass, comma-separated, where
|
||||
/// `default` means "no channel — the bundled build".
|
||||
///
|
||||
/// Chromium is checked twice because the two consumers of this install do
|
||||
/// not launch the same binary. A script calling `chromium.launch()` with
|
||||
/// no channel gets `chromium-headless-shell`; the viewer reads
|
||||
/// `~/.playwright/cli.config.json`, which pins channel
|
||||
/// `chrome-for-testing`, and that resolves to the *full* `chromium-<rev>`
|
||||
/// build — a separate download under the same `install chromium`.
|
||||
///
|
||||
/// Checking only the first is how a container reaches "verified" and then
|
||||
/// fails in the pane with `Browser "chrome-for-testing" is not installed`.
|
||||
/// Observed on a real project, where a stale `chromium-1217` satisfied the
|
||||
/// headless-shell launch while the viewer wanted `chromium-1237`.
|
||||
fn channels(self) -> &'static str {
|
||||
match self {
|
||||
Self::Chromium => None,
|
||||
Self::Chrome => Some("chrome"),
|
||||
Self::Chromium => "default,chrome-for-testing",
|
||||
Self::Chrome => "chrome",
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -235,7 +248,7 @@ pub async fn install_packages(
|
||||
&format!("Installing @playwright/cli into {}/node_modules…", INSTALL_DIR),
|
||||
);
|
||||
|
||||
let mut step = npm_install(app, project_id, container_id, VIEWER_PACKAGE).await?;
|
||||
let mut step = npm_install(app, project_id, container_id, &[VIEWER_PACKAGE]).await?;
|
||||
if step.exit_code != 0 {
|
||||
return Err(format!(
|
||||
"npm couldn't install the viewer package in this container (exit {}).\n\nnpm said:\n{}",
|
||||
@@ -246,9 +259,15 @@ pub async fn install_packages(
|
||||
|
||||
// Second, `playwright` at the version the viewer package pins — see
|
||||
// `VIEWER_PACKAGE`. Installing it as `@latest` is what splits the tree.
|
||||
//
|
||||
// The viewer package is named *again* here. It is already installed, so
|
||||
// this adds no work, but omitting it is what made npm prune it back out —
|
||||
// see the note on `npm_install`. The pin can only be read after the first
|
||||
// install has written the manifest, which is why this stays two commands
|
||||
// rather than one.
|
||||
let spec = pinned_playwright_spec(container_id).await;
|
||||
emit_progress(app, project_id, &format!("Installing {}…", spec));
|
||||
let second = npm_install(app, project_id, container_id, &spec).await?;
|
||||
let second = npm_install(app, project_id, container_id, &[VIEWER_PACKAGE, &spec]).await?;
|
||||
if second.exit_code != 0 {
|
||||
return Err(format!(
|
||||
"npm couldn't install {} in this container (exit {}).\n\nnpm said:\n{}",
|
||||
@@ -290,7 +309,7 @@ pub async fn install_packages(
|
||||
})
|
||||
}
|
||||
|
||||
/// One `npm install` of one spec, into [`INSTALL_DIR`], as `claude`.
|
||||
/// One `npm install` of one or more specs, into [`INSTALL_DIR`], as `claude`.
|
||||
///
|
||||
/// `env VAR=… cmd` rather than an exec env: it keeps the one exec path in
|
||||
/// `docker/exec.rs` untouched, and `env` is a real binary so no shell is
|
||||
@@ -298,13 +317,24 @@ pub async fn install_packages(
|
||||
/// has no postinstall (verified — `playwright@1.62.1` declares no `scripts` at
|
||||
/// all), but if a future release brings the browser download back, this step
|
||||
/// must stay small and the download must stay the step the user asked for.
|
||||
///
|
||||
/// **Every package that must survive has to appear in `specs`.** `--no-save`
|
||||
/// in a directory with no `package.json` — which [`INSTALL_DIR`] is — leaves
|
||||
/// npm with the command line as its only statement of what the tree should
|
||||
/// contain, and npm ≥7 reconciles the tree against that on every run by
|
||||
/// removing whatever it now considers extraneous. Installing `@playwright/cli`
|
||||
/// and then installing `playwright` in a second command therefore *deletes the
|
||||
/// first one*: verified in a container, `removed 3 packages`, leaving an empty
|
||||
/// `node_modules/@playwright/` behind `playwright` and `playwright-core`. That
|
||||
/// empty directory is why a fresh setup could report success and still leave
|
||||
/// the pane saying `@playwright/cli` was not installed.
|
||||
async fn npm_install(
|
||||
app: &AppHandle,
|
||||
project_id: &str,
|
||||
container_id: &str,
|
||||
spec: &str,
|
||||
specs: &[&str],
|
||||
) -> Result<StepResult, String> {
|
||||
let cmd = vec![
|
||||
let mut cmd = vec![
|
||||
"env".to_string(),
|
||||
"PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1".to_string(),
|
||||
"npm".to_string(),
|
||||
@@ -313,8 +343,8 @@ async fn npm_install(
|
||||
"--no-save".to_string(),
|
||||
"--no-fund".to_string(),
|
||||
"--no-audit".to_string(),
|
||||
spec.to_string(),
|
||||
];
|
||||
cmd.extend(specs.iter().map(|s| s.to_string()));
|
||||
run_step(
|
||||
app,
|
||||
project_id,
|
||||
@@ -704,7 +734,7 @@ async fn verify_launch(
|
||||
],
|
||||
vec![
|
||||
format!("TRIPLE_C_PW_DIR={}", dir),
|
||||
format!("TRIPLE_C_PW_CHANNEL={}", target.channel().unwrap_or("")),
|
||||
format!("TRIPLE_C_PW_CHANNELS={}", target.channels()),
|
||||
format!("TRIPLE_C_PW_URL={}", REACHABILITY_URL),
|
||||
],
|
||||
);
|
||||
@@ -795,27 +825,43 @@ fn parse_launch_output(output: &str) -> LaunchVerdict {
|
||||
/// The launch check. One `argv` element, no newlines, same contract as the
|
||||
/// detection probe.
|
||||
///
|
||||
/// Playwright leaves the Chromium sandbox disabled by default, which is what
|
||||
/// makes this work in a container at all. The timeout exists so a browser that
|
||||
/// hangs on a missing library still returns a verdict rather than sitting there
|
||||
/// until the exec is torn down. The navigation is best-effort and never decides
|
||||
/// `ok` — it exists to tell a TLS-intercepted network apart from a broken
|
||||
/// install.
|
||||
/// `chromiumSandbox` is set explicitly rather than left to Playwright's
|
||||
/// default, so this check states the same thing the seeded
|
||||
/// `cli.config.json` does instead of agreeing with it by coincidence. The
|
||||
/// containers forbid unprivileged user namespaces, so a sandboxed Chromium
|
||||
/// aborts on launch; nothing here should be able to drift back into testing a
|
||||
/// configuration the viewer will not use.
|
||||
///
|
||||
/// Each channel in `TRIPLE_C_PW_CHANNELS` is launched in turn — see
|
||||
/// [`BrowserTarget::channels`] for why Chromium needs two — and a failure
|
||||
/// names the channel that failed, because "is not installed" is meaningless
|
||||
/// without it. Only the last launch loads a page: the navigation is
|
||||
/// best-effort, never decides `ok`, and exists to tell a TLS-intercepted
|
||||
/// network apart from a broken install, so doing it once is enough.
|
||||
///
|
||||
/// The timeout exists so a browser that hangs on a missing library still
|
||||
/// returns a verdict rather than sitting there until the exec is torn down.
|
||||
const LAUNCH_PROBE: &str = concat!(
|
||||
r#"const d=process.env.TRIPLE_C_PW_DIR,ch=process.env.TRIPLE_C_PW_CHANNEL||undefined,u=process.env.TRIPLE_C_PW_URL;"#,
|
||||
r#"const d=process.env.TRIPLE_C_PW_DIR,chs=process.env.TRIPLE_C_PW_CHANNELS||"default",u=process.env.TRIPLE_C_PW_URL;"#,
|
||||
r#"let done=false;const say=(ok,detail,nav)=>{if(done)return;done=true;"#,
|
||||
r#"process.stdout.write("\n__TRIPLE_C_BROWSER_LAUNCH__"+JSON.stringify({ok,detail,nav:nav||null})+"\n");};"#,
|
||||
r#"const one=(e)=>String((e&&e.message)||e).split("\n").slice(0,8).join(" | ");"#,
|
||||
r#"const t=setTimeout(()=>{say(false,"the browser did not finish starting within 90s");process.exit(0);},90000);"#,
|
||||
r#"(async()=>{let b=null;try{const {chromium}=require(d);b=await chromium.launch(ch?{channel:ch}:{});"#,
|
||||
r#"let v="";try{v=b.version();}catch(e){}"#,
|
||||
r#"let nav={ok:true,cert:false,detail:""};"#,
|
||||
r#"(async()=>{let b=null,cur="";try{const {chromium}=require(d);"#,
|
||||
r#"const list=chs.split(",").map(s=>s.trim()).filter(Boolean);"#,
|
||||
r#"let v="",nav={ok:true,cert:false,detail:""};"#,
|
||||
r#"for(let i=0;i<list.length;i++){cur=list[i];const c=cur==="default"?undefined:cur;"#,
|
||||
r#"b=await chromium.launch(Object.assign({chromiumSandbox:false},c?{channel:c}:{}));"#,
|
||||
r#"try{v=b.version();}catch(e){}"#,
|
||||
r#"if(i===list.length-1){"#,
|
||||
r#"try{const p=await b.newPage();await p.goto(u,{timeout:20000});}"#,
|
||||
// A certificate failure is classified here, next to the message, because
|
||||
// Chromium's wording is the only place the distinction exists.
|
||||
r#"catch(e){const m=one(e);nav={ok:false,cert:/ERR_CERT|CERT_AUTHORITY|ERR_SSL|SSL_ERROR|self.signed/i.test(m),detail:m};}"#,
|
||||
r#"await b.close();clearTimeout(t);say(true,v,nav);}"#,
|
||||
r#"catch(e){clearTimeout(t);try{if(b)await b.close();}catch(e2){}say(false,one(e));}"#,
|
||||
r#"catch(e){const m=one(e);nav={ok:false,cert:/ERR_CERT|CERT_AUTHORITY|ERR_SSL|SSL_ERROR|self.signed/i.test(m),detail:m};}}"#,
|
||||
r#"await b.close();b=null;}"#,
|
||||
r#"clearTimeout(t);say(true,v,nav);}"#,
|
||||
r#"catch(e){clearTimeout(t);try{if(b)await b.close();}catch(e2){}"#,
|
||||
r#"say(false,(cur&&cur!=="default"?"channel "+cur+": ":"")+one(e));}"#,
|
||||
r#"process.exit(0);})();"#,
|
||||
);
|
||||
|
||||
@@ -984,8 +1030,10 @@ mod tests {
|
||||
// `@playwright/mcp` asks for the chrome channel specifically, so the UI
|
||||
// must be able to say so.
|
||||
assert!(BrowserTarget::Chrome.needed_for().contains("@playwright/mcp"));
|
||||
assert_eq!(BrowserTarget::Chrome.channel(), Some("chrome"));
|
||||
assert_eq!(BrowserTarget::Chromium.channel(), None);
|
||||
assert_eq!(BrowserTarget::Chrome.channels(), "chrome");
|
||||
// Both of Chromium's consumers, or the check passes for a browser the
|
||||
// viewer cannot open — see `channels`.
|
||||
assert_eq!(BrowserTarget::Chromium.channels(), "default,chrome-for-testing");
|
||||
// And a size, before the click, for both.
|
||||
for t in [BrowserTarget::Chromium, BrowserTarget::Chrome] {
|
||||
assert!(t.download_note().to_lowercase().contains("mb"), "{:?}", t);
|
||||
|
||||
@@ -73,6 +73,25 @@ use crate::AppState;
|
||||
/// Report how far behind the current base image a project's container is, and
|
||||
/// what migrating it would actually carry across.
|
||||
///
|
||||
/// Choose the recorded lineage from the two places it can be written, most
|
||||
/// authoritative first: the live container's label, then the snapshot image's.
|
||||
///
|
||||
/// **An empty label is absence, not an answer.** `create_container` always
|
||||
/// writes `triple-c.base-image-id`, even when the value is unknown — that is
|
||||
/// deliberate, because Docker merges an image's labels into a container's and
|
||||
/// an inherited value would otherwise ride a snapshot forever. The consequence
|
||||
/// is that `Some("")` is the *common* reading from a container whose lineage
|
||||
/// was never established, so treating it as an answer silently skips the
|
||||
/// snapshot, which may well have recorded a real one.
|
||||
fn pick_recorded_lineage(
|
||||
from_container: Option<String>,
|
||||
from_snapshot: Option<String>,
|
||||
) -> Option<String> {
|
||||
from_container
|
||||
.filter(|v| !v.is_empty())
|
||||
.or_else(|| from_snapshot.filter(|v| !v.is_empty()))
|
||||
}
|
||||
|
||||
/// Read-only. Runs two filesystem probes (~3 s each) and is therefore meant to
|
||||
/// be called on demand, not polled.
|
||||
#[tauri::command]
|
||||
@@ -98,20 +117,24 @@ pub async fn get_container_staleness(
|
||||
// Lineage, most authoritative source first: the live container's label,
|
||||
// then the snapshot image's. Both are written by `create_container` and
|
||||
// propagated onto the snapshot by `docker commit`.
|
||||
// Each source is filtered for emptiness *before* it is allowed to satisfy
|
||||
// the lookup. `create_container` always writes this label, even when the
|
||||
// value is unknown — deliberately, so an inherited image label cannot ride
|
||||
// a snapshot forever — which means the container's copy is very often
|
||||
// `Some("")`. Filtering only the final result let that empty string count
|
||||
// as an answer and skip the snapshot entirely, so a snapshot that *did*
|
||||
// record a lineage was never consulted and the project reported "unknown"
|
||||
// with the information sitting one lookup away.
|
||||
let container_id = docker::find_existing_container(&project).await.unwrap_or(None);
|
||||
let recorded = match &container_id {
|
||||
let from_container = match &container_id {
|
||||
Some(id) => container_label(id, mig::LABEL_BASE_IMAGE_ID).await,
|
||||
None => None,
|
||||
}
|
||||
.or_else(|| None);
|
||||
let recorded = match recorded {
|
||||
Some(v) => Some(v),
|
||||
None => mig::image_labels(&snapshot_image)
|
||||
.await
|
||||
.get(mig::LABEL_BASE_IMAGE_ID)
|
||||
.cloned(),
|
||||
}
|
||||
.filter(|v| !v.is_empty());
|
||||
};
|
||||
let from_snapshot = mig::image_labels(&snapshot_image)
|
||||
.await
|
||||
.get(mig::LABEL_BASE_IMAGE_ID)
|
||||
.cloned();
|
||||
let recorded = pick_recorded_lineage(from_container, from_snapshot);
|
||||
|
||||
out.base_image_id = recorded.clone();
|
||||
out.known = recorded.is_some();
|
||||
@@ -1671,6 +1694,32 @@ fn summarize(
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn an_empty_lineage_label_is_absence_and_falls_through_to_the_snapshot() {
|
||||
let some = |s: &str| Some(s.to_string());
|
||||
|
||||
// The regression: the container always carries the label, so an
|
||||
// unknown lineage reads as `Some("")`. Letting that satisfy the lookup
|
||||
// skipped a snapshot that had recorded the real thing.
|
||||
assert_eq!(
|
||||
pick_recorded_lineage(some(""), some("sha256:base")),
|
||||
some("sha256:base")
|
||||
);
|
||||
|
||||
// Ordinary precedence still holds: the container wins when it has one.
|
||||
assert_eq!(
|
||||
pick_recorded_lineage(some("sha256:container"), some("sha256:snapshot")),
|
||||
some("sha256:container")
|
||||
);
|
||||
assert_eq!(pick_recorded_lineage(None, some("sha256:snap")), some("sha256:snap"));
|
||||
|
||||
// Genuinely unknown stays unknown — "probe instead", never a lineage
|
||||
// invented to make the comparison succeed.
|
||||
assert_eq!(pick_recorded_lineage(None, None), None);
|
||||
assert_eq!(pick_recorded_lineage(some(""), some("")), None);
|
||||
assert_eq!(pick_recorded_lineage(some(""), None), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn byte_sizes_read_the_way_a_disk_warning_should() {
|
||||
assert_eq!(human_bytes(512), "512 B");
|
||||
|
||||
@@ -798,6 +798,111 @@ async fn resolve_base_image_id(image_name: &str, base_image_name: &str) -> Strin
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
/// The `/dev/net/tun` character device, as it is named on both sides.
|
||||
const TUN_DEVICE: &str = "/dev/net/tun";
|
||||
|
||||
/// The `HostConfig` fields "VPN support" contributes: `CapAdd`, `Devices`,
|
||||
/// `Sysctls` — in that order.
|
||||
type VpnHostConfigParts = (
|
||||
Option<Vec<String>>,
|
||||
Option<Vec<bollard::models::DeviceMapping>>,
|
||||
Option<HashMap<String, String>>,
|
||||
);
|
||||
|
||||
/// The three host-config pieces a VPN client needs, or all-`None` when the
|
||||
/// project has not opted in.
|
||||
///
|
||||
/// Returned as a triple rather than set inline so the exact shape is unit
|
||||
/// testable — a container is created once, by a very long async function, and a
|
||||
/// silently-dropped capability looks identical to a VPN server that is simply
|
||||
/// unreachable.
|
||||
///
|
||||
/// All three are required together and each fails differently on its own:
|
||||
/// * **`CAP_NET_ADMIN`** — without it the client cannot create an interface or
|
||||
/// write a route. Docker's default bounding set grants `net_raw` but not
|
||||
/// `net_admin`, which is why a client can ping but never connect.
|
||||
/// * **`/dev/net/tun`** — the device is absent from a default container, so
|
||||
/// there is nothing to open even with the capability. It is passed through
|
||||
/// from the host rather than `mknod`-ed inside, so the kernel's `tun` module
|
||||
/// backs it.
|
||||
/// * **`net.ipv4.conf.all.src_valid_mark`** — WireGuard's own `wg-quick` sets
|
||||
/// this, and cannot from inside a container (`/proc/sys` is read-only), so
|
||||
/// its handshake packets are dropped by reverse-path filtering. Harmless for
|
||||
/// OpenVPN-based clients, so it is set unconditionally with the rest.
|
||||
///
|
||||
/// What it costs, stated accurately: Docker does not enable user-namespace
|
||||
/// remapping by default, so this is a real `CAP_NET_ADMIN` in the *initial*
|
||||
/// user namespace and only the **network** namespace confines it. It cannot
|
||||
/// touch the host's interfaces, but within its own namespace it can set
|
||||
/// promiscuous mode and add arbitrary addresses, routes and NAT rules on the
|
||||
/// shared `docker0` L2 segment — which puts sibling containers (the LiteLLM
|
||||
/// gateway among them) within reach of ARP spoofing, and lets netlink trigger
|
||||
/// host-kernel module auto-loading. It is also enough to flush netfilter rules
|
||||
/// inside the container, so pair it with `sandbox_mode_enabled` advisedly.
|
||||
/// Hence opt-in, per project, rather than on for everyone.
|
||||
fn vpn_host_config(enabled: bool) -> VpnHostConfigParts {
|
||||
if !enabled {
|
||||
return (None, None, None);
|
||||
}
|
||||
|
||||
let devices = vec![bollard::models::DeviceMapping {
|
||||
path_on_host: Some(TUN_DEVICE.to_string()),
|
||||
path_in_container: Some(TUN_DEVICE.to_string()),
|
||||
cgroup_permissions: Some("rwm".to_string()),
|
||||
}];
|
||||
|
||||
let sysctls = HashMap::from([(
|
||||
"net.ipv4.conf.all.src_valid_mark".to_string(),
|
||||
"1".to_string(),
|
||||
)]);
|
||||
|
||||
(
|
||||
Some(vec!["NET_ADMIN".to_string()]),
|
||||
Some(devices),
|
||||
Some(sysctls),
|
||||
)
|
||||
}
|
||||
|
||||
/// Turn the daemon's device-passthrough failure into an explanation.
|
||||
///
|
||||
/// **This fires on `start`, not `create`.** Verified against Docker 29.7:
|
||||
/// `docker create --device /dev/does-not-exist` succeeds and prints an id; the
|
||||
/// device is only resolved when runc builds the container, so the failure lands
|
||||
/// on the *next* call. Sysctls validate at the same point. Anything that
|
||||
/// inspects only the create path will never see it — which is why both paths
|
||||
/// route through here and the tests exercise the start-side string.
|
||||
///
|
||||
/// Unmapped, this reads as `Failed to start container: Docker responded with
|
||||
/// status code 500: error gathering device information while adding custom
|
||||
/// device "/dev/net/tun": no such file or directory` — a path the user will go
|
||||
/// looking for on the wrong machine, since with Docker Desktop the relevant
|
||||
/// host is the Linux VM rather than their own, and with nothing pointing back
|
||||
/// at the switch that caused it.
|
||||
///
|
||||
/// Deliberately not gated on `vpn_support_enabled`: nothing else in Triple-C
|
||||
/// ever asks for a device, so an error naming `/dev/net/tun` can only have come
|
||||
/// from a container created with the switch on. That keeps the check usable
|
||||
/// from [`start_container`], which has a container id and no project.
|
||||
fn explain_container_failure(action: &str, err: &str) -> String {
|
||||
let device_missing = err.contains(TUN_DEVICE)
|
||||
&& (err.contains("no such file or directory")
|
||||
|| err.contains("No such file or directory")
|
||||
|| err.contains("error gathering device information"));
|
||||
|
||||
if device_missing {
|
||||
return format!(
|
||||
"Failed to {} container: the Docker host has no {} device, which \
|
||||
\"VPN support\" requires. The host kernel needs the `tun` module \
|
||||
loaded (on Docker Desktop that is the Linux VM, not your own \
|
||||
machine). Turn VPN support off in Config → Runtime to start this \
|
||||
project without it. Original error: {}",
|
||||
action, TUN_DEVICE, err
|
||||
);
|
||||
}
|
||||
|
||||
format!("Failed to {} container: {}", action, err)
|
||||
}
|
||||
|
||||
pub async fn create_container(
|
||||
project: &Project,
|
||||
docker_socket_path: &str,
|
||||
@@ -1375,6 +1480,13 @@ pub async fn create_container(
|
||||
labels.insert("triple-c.image".to_string(), image_name.to_string());
|
||||
labels.insert("triple-c.timezone".to_string(), timezone.unwrap_or("").to_string());
|
||||
labels.insert("triple-c.mission-control".to_string(), project.mission_control_enabled.to_string());
|
||||
// Capabilities, devices and sysctls are fixed at creation, so this is
|
||||
// container state and gets the label-and-compare treatment. Written
|
||||
// unconditionally (`false`, not omitted) because `docker commit` copies
|
||||
// container labels onto the snapshot image: a `true` stamped once would
|
||||
// otherwise ride that snapshot into every future container and make the
|
||||
// switch impossible to turn back off.
|
||||
labels.insert("triple-c.vpn-support".to_string(), project.vpn_support_enabled.to_string());
|
||||
labels.insert("triple-c.permission-mode".to_string(),
|
||||
project.effective_permission_mode().as_env_value().to_string());
|
||||
labels.insert("triple-c.custom-env-fingerprint".to_string(), custom_env_fingerprint.clone());
|
||||
@@ -1443,10 +1555,15 @@ pub async fn create_container(
|
||||
labels.insert((*key).to_string(), (*value).to_string());
|
||||
}
|
||||
|
||||
let (cap_add, devices, sysctls) = vpn_host_config(project.vpn_support_enabled);
|
||||
|
||||
let host_config = HostConfig {
|
||||
mounts: Some(mounts),
|
||||
port_bindings: if port_bindings.is_empty() { None } else { Some(port_bindings) },
|
||||
init: Some(true),
|
||||
cap_add,
|
||||
devices,
|
||||
sysctls,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
@@ -1476,7 +1593,7 @@ pub async fn create_container(
|
||||
let response = docker
|
||||
.create_container(Some(options), config)
|
||||
.await
|
||||
.map_err(|e| format!("Failed to create container: {}", e))?;
|
||||
.map_err(|e| explain_container_failure("create", &e.to_string()))?;
|
||||
|
||||
Ok(response.id)
|
||||
}
|
||||
@@ -1486,7 +1603,7 @@ pub async fn start_container(container_id: &str) -> Result<(), String> {
|
||||
docker
|
||||
.start_container(container_id, None::<StartContainerOptions<String>>)
|
||||
.await
|
||||
.map_err(|e| format!("Failed to start container: {}", e))
|
||||
.map_err(|e| explain_container_failure("start", &e.to_string()))
|
||||
}
|
||||
|
||||
pub async fn stop_container(container_id: &str) -> Result<(), String> {
|
||||
@@ -2367,6 +2484,19 @@ pub async fn container_needs_recreation(
|
||||
return Ok(true);
|
||||
}
|
||||
|
||||
// ── VPN support (NET_ADMIN + /dev/net/tun + sysctl) ───────────────────
|
||||
// A container's capabilities, devices and sysctls are set at creation and
|
||||
// cannot be changed on a running or stopped container, so recreation is the
|
||||
// only way a toggle here takes effect. A missing label means the container
|
||||
// predates the feature, which is the same thing as having it off — so
|
||||
// existing projects are not churned until someone actually turns it on.
|
||||
let expected_vpn = project.vpn_support_enabled.to_string();
|
||||
let container_vpn = get_label("triple-c.vpn-support").unwrap_or_else(|| "false".to_string());
|
||||
if container_vpn != expected_vpn {
|
||||
log::info!("VPN support mismatch (container={:?}, expected={:?})", container_vpn, expected_vpn);
|
||||
return Ok(true);
|
||||
}
|
||||
|
||||
// ── Permission mode ────────────────────────────────────────────────────
|
||||
// The mode is injected as the TRIPLE_C_PERMISSION_MODE env var, and
|
||||
// container env can only change by recreating the container. A missing
|
||||
@@ -2616,6 +2746,98 @@ mod tests {
|
||||
assert_eq!(fp, "");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn vpn_support_off_touches_nothing_in_the_host_config() {
|
||||
// The default must stay byte-identical to a container created before the
|
||||
// feature existed, or every project recreates on the next start.
|
||||
let (cap_add, devices, sysctls) = vpn_host_config(false);
|
||||
assert_eq!(cap_add, None);
|
||||
assert_eq!(devices, None);
|
||||
assert_eq!(sysctls, None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn vpn_support_on_grants_all_three_pieces() {
|
||||
// Each is useless without the others — a client with the capability but
|
||||
// no device, or the device but no capability, still times out — so this
|
||||
// asserts the whole set rather than any one of them.
|
||||
let (cap_add, devices, sysctls) = vpn_host_config(true);
|
||||
|
||||
assert_eq!(cap_add, Some(vec!["NET_ADMIN".to_string()]));
|
||||
|
||||
let devices = devices.expect("the tun device must be passed through");
|
||||
assert_eq!(devices.len(), 1);
|
||||
assert_eq!(devices[0].path_on_host.as_deref(), Some(TUN_DEVICE));
|
||||
assert_eq!(devices[0].path_in_container.as_deref(), Some(TUN_DEVICE));
|
||||
assert_eq!(devices[0].cgroup_permissions.as_deref(), Some("rwm"));
|
||||
|
||||
assert_eq!(
|
||||
sysctls
|
||||
.expect("wireguard needs src_valid_mark")
|
||||
.get("net.ipv4.conf.all.src_valid_mark")
|
||||
.map(String::as_str),
|
||||
Some("1")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn vpn_support_never_grants_more_than_net_admin() {
|
||||
// NET_ADMIN is already a step out of the sandbox. Anything else added
|
||||
// here (SYS_ADMIN, or a blanket privileged flag) would be a much larger
|
||||
// one, so pin the set.
|
||||
let (cap_add, _, _) = vpn_host_config(true);
|
||||
assert_eq!(cap_add.unwrap(), vec!["NET_ADMIN"]);
|
||||
}
|
||||
|
||||
/// What bollard actually hands us when a tun-less host rejects the device.
|
||||
///
|
||||
/// Captured verbatim from Docker 29.7: `docker create` with a missing
|
||||
/// device **succeeds**, and this arrives from the subsequent `start`.
|
||||
/// `DockerResponseServerError`'s Display is
|
||||
/// `"Docker responded with status code {code}: {message}"` with the
|
||||
/// daemon's message unaltered.
|
||||
const REAL_TUN_ERROR: &str = "Docker responded with status code 500: error \
|
||||
gathering device information while adding custom device \
|
||||
\"/dev/net/tun\": no such file or directory";
|
||||
|
||||
#[test]
|
||||
fn a_missing_tun_device_is_explained_on_the_path_that_actually_fails() {
|
||||
// The start path is the one that matters: the daemon defers device
|
||||
// resolution to runc, so create returns an id on a host with no tun
|
||||
// module and only start fails. A version of this that checked create
|
||||
// alone would be dead code.
|
||||
let msg = explain_container_failure("start", REAL_TUN_ERROR);
|
||||
assert!(msg.starts_with("Failed to start container:"), "{}", msg);
|
||||
assert!(msg.contains("VPN support"), "should name the switch: {}", msg);
|
||||
assert!(msg.contains("tun` module"), "should name the cause: {}", msg);
|
||||
assert!(msg.contains("Config → Runtime"), "should say where to fix it: {}", msg);
|
||||
assert!(msg.contains(REAL_TUN_ERROR), "should keep the original: {}", msg);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_same_explanation_covers_create_if_the_daemon_ever_checks_earlier() {
|
||||
// Belt and braces — older and future daemons may validate at create.
|
||||
let msg = explain_container_failure("create", REAL_TUN_ERROR);
|
||||
assert!(msg.starts_with("Failed to create container:"), "{}", msg);
|
||||
assert!(msg.contains("VPN support"), "{}", msg);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unrelated_failures_are_left_alone() {
|
||||
for (action, err) in [
|
||||
("create", "Conflict. The container name \"/triple-c-x\" is already in use"),
|
||||
("start", "Docker responded with status code 404: No such container"),
|
||||
("start", "error gathering device information while adding custom device \"/dev/dri/card0\""),
|
||||
] {
|
||||
assert_eq!(
|
||||
explain_container_failure(action, err),
|
||||
format!("Failed to {} container: {}", action, err),
|
||||
"{} should pass through untouched",
|
||||
err
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_orphan_sweep_only_ever_looks_at_our_own_untagged_images() {
|
||||
// Both conditions are load-bearing. Without `dangling` the sweep would
|
||||
|
||||
@@ -145,6 +145,22 @@ pub struct Project {
|
||||
/// container-recreation label.
|
||||
#[serde(default)]
|
||||
pub browser_view_enabled: bool,
|
||||
/// Grant the container what a VPN client needs to build a tunnel:
|
||||
/// `CAP_NET_ADMIN`, the `/dev/net/tun` device, and the WireGuard
|
||||
/// `src_valid_mark` sysctl. Without all three a client (PIA, WireGuard,
|
||||
/// OpenVPN) installs and runs but its connection attempt hangs until it
|
||||
/// times out, because it cannot create the tunnel interface or touch the
|
||||
/// routing table.
|
||||
///
|
||||
/// Off by default and deliberately opt-in: `NET_ADMIN` lets anything in the
|
||||
/// container reconfigure its own network stack, which reaches further than
|
||||
/// it sounds — see `vpn_host_config` for what it does and does not confer.
|
||||
/// Unlike `auth_bridge_enabled` this *is*
|
||||
/// container state, so it carries a `triple-c.vpn-support` label and is
|
||||
/// compared in `container_needs_recreation` — capabilities and devices are
|
||||
/// fixed at creation and can only change by recreating the container.
|
||||
#[serde(default)]
|
||||
pub vpn_support_enabled: bool,
|
||||
/// Use the shared, long-lived Claude Code OAuth token (from
|
||||
/// `claude setup-token`, held in the OS keychain) for this project instead
|
||||
/// of requiring its own `claude login`. Only consulted when `backend` is
|
||||
@@ -366,6 +382,7 @@ impl Project {
|
||||
mission_control_enabled: false,
|
||||
auth_bridge_enabled: false,
|
||||
browser_view_enabled: false,
|
||||
vpn_support_enabled: false,
|
||||
use_shared_auth_token: default_use_shared_auth_token(),
|
||||
full_permissions: false,
|
||||
permission_mode: None,
|
||||
|
||||
@@ -127,6 +127,46 @@ describe("ContainerMigrationBanner", () => {
|
||||
expect(container).toBeEmptyDOMElement();
|
||||
});
|
||||
|
||||
it("speaks up when an unlabelled container could not be probed at all", () => {
|
||||
// The probe is the only signal a container with no lineage label has. If
|
||||
// it fails and the banner stays silent, that is indistinguishable from
|
||||
// "up to date" — the exact reading that let an out-of-date project go
|
||||
// unnoticed indefinitely.
|
||||
renderBanner(
|
||||
migration({
|
||||
staleness: {
|
||||
...FRESH,
|
||||
known: false,
|
||||
stale: false,
|
||||
probe_error: "output exceeded the inspection limit",
|
||||
},
|
||||
probeSettled: false,
|
||||
}),
|
||||
);
|
||||
expect(
|
||||
screen.getByText(/Container base could not be checked/i),
|
||||
).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByText(/output exceeded the inspection limit/i),
|
||||
).toBeInTheDocument();
|
||||
// And it must not pose as a finding about the container itself.
|
||||
expect(
|
||||
screen.queryByText(/Container is missing things/i),
|
||||
).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("stays quiet when a labelled container's probe fails but its lineage is current", () => {
|
||||
// `known` means the version comparison already answered the question, so
|
||||
// a failed probe is not grounds to raise anything.
|
||||
const { container } = renderBanner(
|
||||
migration({
|
||||
staleness: { ...FRESH, probe_error: "could not exec in the container" },
|
||||
probeSettled: false,
|
||||
}),
|
||||
);
|
||||
expect(container).toBeEmptyDOMElement();
|
||||
});
|
||||
|
||||
it("disables the action and explains why while the container is running", () => {
|
||||
renderBanner(migration({ staleness: STALE }), false);
|
||||
expect(
|
||||
|
||||
@@ -131,7 +131,15 @@ export default function ContainerMigrationBanner({
|
||||
const probeFoundGaps =
|
||||
!staleness.known &&
|
||||
(staleness.missing_features.length > 0 || staleness.missing_paths.length > 0);
|
||||
if (!staleness.stale && !probeFoundGaps) return null;
|
||||
|
||||
// The probe is the *only* signal a container with no lineage label has, so
|
||||
// when it fails there is nothing left to be quiet about. Staying silent here
|
||||
// is indistinguishable from "everything is fine" — and it is the likeliest
|
||||
// outcome for the oldest, largest projects, whose manifests are the ones apt
|
||||
// to exceed the inspection limit. Say that the check did not run instead.
|
||||
const probeUnavailable = !staleness.known && !!staleness.probe_error;
|
||||
|
||||
if (!staleness.stale && !probeFoundGaps && !probeUnavailable) return null;
|
||||
|
||||
const snapshot = formatSnapshotDate(staleness.snapshot_created_at);
|
||||
const features = joinFeatures(staleness.missing_features);
|
||||
@@ -139,16 +147,25 @@ export default function ContainerMigrationBanner({
|
||||
return (
|
||||
<section
|
||||
className={`${SHELL} border-[var(--warning)]/40 bg-[var(--warning-muted)]`}
|
||||
aria-label="Container base is out of date"
|
||||
aria-label={
|
||||
probeUnavailable
|
||||
? "Container base could not be checked"
|
||||
: "Container base is out of date"
|
||||
}
|
||||
>
|
||||
<div className="flex items-start justify-between gap-3">
|
||||
<div className="min-w-0 space-y-1">
|
||||
<StatusIndicator
|
||||
tone="error"
|
||||
// A check that could not run is not a finding: it gets the
|
||||
// "unresolved" tone rather than the one that says something is
|
||||
// wrong with the container.
|
||||
tone={probeUnavailable ? "unknown" : "error"}
|
||||
label={
|
||||
staleness.known
|
||||
? "Container base is out of date"
|
||||
: "Container is missing things the current base ships"
|
||||
: probeUnavailable
|
||||
? "Container base could not be checked"
|
||||
: "Container is missing things the current base ships"
|
||||
}
|
||||
className="text-[13px] font-semibold"
|
||||
/>
|
||||
@@ -158,7 +175,9 @@ export default function ContainerMigrationBanner({
|
||||
? snapshot
|
||||
? `Running on a saved image from ${snapshot}.`
|
||||
: "Running on a saved image older than the current base."
|
||||
: "This container predates base-image tracking, so it was probed directly."}
|
||||
: probeUnavailable
|
||||
? "This container predates base-image tracking, so probing it is the only way to tell whether it is behind — and that did not complete."
|
||||
: "This container predates base-image tracking, so it was probed directly."}
|
||||
</p>
|
||||
|
||||
{staleness.missing_features.length > 0 && (
|
||||
|
||||
@@ -120,6 +120,15 @@ export default function OverviewTab({
|
||||
{project.mission_control_enabled ? "ON" : "OFF"}
|
||||
</span>
|
||||
</span>
|
||||
{/* Only when granted. It is off for nearly every project and an
|
||||
always-present "VPN OFF" would be noise, but where it *is* on the
|
||||
container holds NET_ADMIN, which is worth seeing at a glance. */}
|
||||
{project.vpn_support_enabled && (
|
||||
<span className="text-[var(--text-secondary)]">
|
||||
VPN support{" "}
|
||||
<span className="text-[var(--text-primary)] font-medium">ON</span>
|
||||
</span>
|
||||
)}
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => onOpenTab("config")}
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
import { describe, it, expect, vi, beforeEach } from "vitest";
|
||||
import { render, screen, fireEvent } from "@testing-library/react";
|
||||
import RuntimeSection from "./RuntimeSection";
|
||||
import type { Project } from "../../../../lib/types";
|
||||
|
||||
const baseProject: Project = {
|
||||
id: "p1",
|
||||
name: "api-server",
|
||||
paths: [{ host_path: "/src/api", mount_name: "api" }],
|
||||
container_id: null,
|
||||
status: "stopped",
|
||||
backend: "anthropic",
|
||||
bedrock_config: null,
|
||||
ollama_config: null,
|
||||
llamacpp_config: null,
|
||||
openai_compatible_config: null,
|
||||
allow_docker_access: false,
|
||||
sandbox_mode_enabled: true,
|
||||
mission_control_enabled: false,
|
||||
auth_bridge_enabled: false,
|
||||
browser_view_enabled: false,
|
||||
vpn_support_enabled: false,
|
||||
use_shared_auth_token: true,
|
||||
full_permissions: false,
|
||||
permission_mode: null,
|
||||
ssh_key_path: null,
|
||||
ca_cert_path: null,
|
||||
git_token: null,
|
||||
git_user_name: null,
|
||||
git_user_email: null,
|
||||
custom_env_vars: [],
|
||||
port_mappings: [],
|
||||
claude_instructions: null,
|
||||
claude_code_settings: null,
|
||||
renamed_session_names: {},
|
||||
created_at: "2026-01-01T00:00:00Z",
|
||||
updated_at: "2026-01-01T00:00:00Z",
|
||||
};
|
||||
|
||||
const VPN = "VPN support";
|
||||
|
||||
const save = vi.fn().mockResolvedValue(true);
|
||||
|
||||
function renderSection(over: Partial<Project> = {}, disabled = false) {
|
||||
return render(
|
||||
<RuntimeSection
|
||||
project={{ ...baseProject, ...over }}
|
||||
save={save}
|
||||
disabled={disabled}
|
||||
disabledReason="Container must be stopped to change this setting."
|
||||
/>,
|
||||
);
|
||||
}
|
||||
|
||||
describe("RuntimeSection — VPN support toggle", () => {
|
||||
beforeEach(() => vi.clearAllMocks());
|
||||
|
||||
it("saves only the VPN flag when switched on", () => {
|
||||
renderSection();
|
||||
fireEvent.click(screen.getByRole("switch", { name: VPN }));
|
||||
expect(save).toHaveBeenCalledWith({ vpn_support_enabled: true });
|
||||
});
|
||||
|
||||
it("saves the flag off again, rather than dropping the key", () => {
|
||||
// Off has to be written explicitly: the container carries a
|
||||
// `triple-c.vpn-support` label either way, and an absent value would leave
|
||||
// the capability granted.
|
||||
renderSection({ vpn_support_enabled: true });
|
||||
fireEvent.click(screen.getByRole("switch", { name: VPN }));
|
||||
expect(save).toHaveBeenCalledWith({ vpn_support_enabled: false });
|
||||
});
|
||||
|
||||
it("reflects the project's current state", () => {
|
||||
renderSection({ vpn_support_enabled: true });
|
||||
expect(screen.getByRole("switch", { name: VPN })).toBeChecked();
|
||||
});
|
||||
|
||||
it("cannot be changed while the container is running", () => {
|
||||
// Capabilities and devices are fixed at creation, so this setting is gated
|
||||
// on the container being stopped along with the rest of the tab.
|
||||
renderSection({}, true);
|
||||
const toggle = screen.getByRole("switch", { name: VPN });
|
||||
expect(toggle).toBeDisabled();
|
||||
fireEvent.click(toggle);
|
||||
expect(save).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("warns that the change recreates the container", () => {
|
||||
renderSection();
|
||||
expect(
|
||||
screen.getByText(/recreates the container on its next start/i),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
@@ -57,6 +57,19 @@ export default function RuntimeSection({
|
||||
}
|
||||
/>
|
||||
|
||||
<SwitchRow
|
||||
label="VPN support"
|
||||
hint="Grants NET_ADMIN and the /dev/net/tun device so a VPN client (PIA, WireGuard, OpenVPN) can build a tunnel inside the container. Without it a client installs and runs but its connection hangs until it times out. Anything in the container can then reconfigure the container's own network stack; the host's is untouched. Changing this recreates the container on its next start — the home and .claude volumes are preserved."
|
||||
control={
|
||||
<Toggle
|
||||
label="VPN support"
|
||||
checked={project.vpn_support_enabled}
|
||||
disabled={disabled}
|
||||
onChange={(v) => save({ vpn_support_enabled: v })}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
|
||||
<SwitchRow
|
||||
label="Mission Control"
|
||||
hint="A web dashboard for monitoring and managing Claude sessions remotely."
|
||||
|
||||
@@ -33,6 +33,10 @@ export interface Project {
|
||||
auth_bridge_enabled: boolean;
|
||||
/** Opt in to the browser-view pane. Host-side only, like `auth_bridge_enabled`. */
|
||||
browser_view_enabled: boolean;
|
||||
/** Grant NET_ADMIN, /dev/net/tun and the WireGuard `src_valid_mark` sysctl so
|
||||
* a VPN client inside the container can build a tunnel. Unlike the two flags
|
||||
* above this is container state — changing it recreates the container. */
|
||||
vpn_support_enabled: boolean;
|
||||
/** Use the shared long-lived Claude Code token (from `claude setup-token`,
|
||||
* held in the OS keychain) instead of this project's own `claude login`.
|
||||
* Defaults to true; only applies when `backend` is "anthropic" and a token
|
||||
|
||||
@@ -318,6 +318,13 @@ COPY entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||
RUN chmod +x /usr/local/bin/entrypoint.sh
|
||||
COPY triple-c-scheduler /usr/local/bin/triple-c-scheduler
|
||||
RUN chmod +x /usr/local/bin/triple-c-scheduler
|
||||
# Lives in /usr/local/bin rather than under /home/claude on purpose: the home
|
||||
# directory is the mount point of the project's home volume, so an image copy
|
||||
# of it is masked after the project's first start and can never be updated
|
||||
# again. /usr/local/bin rides the snapshot and is replaced on migration, which
|
||||
# is what lets a fix to this script reach an existing project at all.
|
||||
COPY triple-c-playwright-heal /usr/local/bin/triple-c-playwright-heal
|
||||
RUN chmod +x /usr/local/bin/triple-c-playwright-heal
|
||||
COPY triple-c-task-runner /usr/local/bin/triple-c-task-runner
|
||||
RUN chmod +x /usr/local/bin/triple-c-task-runner
|
||||
|
||||
|
||||
@@ -425,6 +425,32 @@ if [ -x /usr/local/bin/triple-c-open ]; then
|
||||
export BROWSER=/usr/local/bin/triple-c-open
|
||||
fi
|
||||
|
||||
# ── Playwright browser config ───────────────────────────────────────────────
|
||||
# Seed ~/.playwright/cli.config.json on every start.
|
||||
#
|
||||
# Without it `playwright-cli` resolves to channel `chrome` — system Google
|
||||
# Chrome — with the Chromium sandbox ON, and these containers do not permit
|
||||
# unprivileged user namespaces, so the browser aborts with "Failed to move to
|
||||
# new namespace ... Operation not permitted". On a base image that no longer
|
||||
# ships Google Chrome the same default fails the other way, with "Chromium
|
||||
# distribution 'chrome' is not found". One cause, two error messages, and
|
||||
# neither of them looks like a configuration problem.
|
||||
#
|
||||
# Seeded here rather than baked into the image because ~/.playwright is inside
|
||||
# the home volume: an image copy would reach new projects only, and every
|
||||
# existing project would stay broken forever. Written on every start from a
|
||||
# source outside the volume, the way CLAUDE_INSTRUCTIONS and the Mission
|
||||
# Control skills already are.
|
||||
#
|
||||
# --seed-config-only is the cheap path: no npm install, no browser download, no
|
||||
# apt, no verify launch, nothing over the network. It writes one small file if
|
||||
# it is absent and returns. Measured at ~2 ms. The heavier repairs stay
|
||||
# on-demand — run `triple-c-playwright-heal` with no arguments for those.
|
||||
if [ -x /usr/local/bin/triple-c-playwright-heal ]; then
|
||||
/usr/local/bin/triple-c-playwright-heal --seed-config-only --quiet || \
|
||||
echo "entrypoint: warning — playwright config seeding failed (browser view may not launch)"
|
||||
fi
|
||||
|
||||
# ── Scheduler setup ─────────────────────────────────────────────────────────
|
||||
SCHEDULER_DIR="/home/claude/.claude/scheduler"
|
||||
mkdir -p "$SCHEDULER_DIR/tasks" "$SCHEDULER_DIR/logs" "$SCHEDULER_DIR/notifications"
|
||||
|
||||
Executable
+272
@@ -0,0 +1,272 @@
|
||||
#!/bin/bash
|
||||
# triple-c-playwright-heal — make Playwright usable in a Triple-C container.
|
||||
#
|
||||
# Idempotent: safe to run on every start and safe to re-run after a partial
|
||||
# failure. Each step checks for its own result first, so a healthy container is
|
||||
# a fast no-op that still prints why it is healthy. The last step is the only
|
||||
# one that means anything: it launches a browser for real.
|
||||
#
|
||||
# The things that go wrong, in the order they bite:
|
||||
#
|
||||
# 1. @playwright/cli missing — including the case where it was installed and
|
||||
# then silently removed again. `npm install --no-save <pkg>` in /workspace,
|
||||
# which has no package.json, prunes packages npm considers extraneous, so
|
||||
# installing @playwright/cli and then installing playwright wipes the
|
||||
# first one and leaves an empty node_modules/@playwright/. That directory
|
||||
# reads as "installed" to a naive check, which is why this script tests
|
||||
# the package *entry point*.
|
||||
#
|
||||
# 2. Bundled chromium missing or the wrong revision. Browsers live in the
|
||||
# home volume and outlive any single @playwright/cli install, so a stale
|
||||
# chromium-<old> is routinely present while the installed playwright-core
|
||||
# wants a newer one. Must be installed AS claude: run as root it lands in
|
||||
# /root/.cache/ms-playwright where the agent cannot see it.
|
||||
#
|
||||
# 3. No cli.config.json — the one that breaks an otherwise clean install.
|
||||
# With no config, playwright-cli resolves to channel `chrome` (system
|
||||
# Google Chrome) with the sandbox ON. These containers forbid unprivileged
|
||||
# user namespaces, so Chrome aborts with "Failed to move to new namespace
|
||||
# ... Operation not permitted". On newer base images Chrome is not present
|
||||
# at all and it fails with "Chromium distribution 'chrome' is not found".
|
||||
# Same root cause both ways: the default channel is wrong here.
|
||||
#
|
||||
# 4. The storage-state file the config points at is missing. Playwright
|
||||
# treats an unreadable storageState as a hard error on every launch, not
|
||||
# as "no saved state", so the file has to exist from the very first run.
|
||||
#
|
||||
# 5. xvfb or socat missing (older base images only). Headless Playwright
|
||||
# needs neither; the `playwright-cli show` dashboard needs xvfb, and the
|
||||
# browser-view pane needs socat — without it the pane reports
|
||||
# "127.0.0.1 sent an invalid response" while the container side is fine.
|
||||
#
|
||||
# Usage: triple-c-playwright-heal [--seed-config-only] [--force-config] [--quiet]
|
||||
# --seed-config-only only ensure the config and its storage-state file
|
||||
# exist. No npm install, no browser download, no apt, no
|
||||
# verify launch. Cheap and offline — this is the mode
|
||||
# entrypoint.sh runs on every container start.
|
||||
# --force-config overwrite an existing config instead of keeping it
|
||||
# --quiet print only problems and repairs, not healthy no-ops
|
||||
|
||||
set -u
|
||||
|
||||
TARGET_USER=claude
|
||||
TARGET_HOME=/home/claude
|
||||
PW_DIR=/workspace
|
||||
CONFIG_DIR="$TARGET_HOME/.playwright"
|
||||
CONFIG_FILE="$CONFIG_DIR/cli.config.json"
|
||||
STATE_FILE="$CONFIG_DIR/storage-state.json"
|
||||
CLI_ENTRY="$PW_DIR/node_modules/@playwright/cli/playwright-cli.js"
|
||||
|
||||
FORCE_CONFIG=0
|
||||
QUIET=0
|
||||
SEED_ONLY=0
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
--force-config) FORCE_CONFIG=1 ;;
|
||||
--quiet) QUIET=1 ;;
|
||||
--seed-config-only) SEED_ONLY=1 ;;
|
||||
*) echo "playwright-heal: unknown option: $arg" >&2; exit 2 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
changed=0
|
||||
failed=0
|
||||
|
||||
say() { [ "$QUIET" = 1 ] || echo "playwright-heal: $*"; }
|
||||
warn() { echo "playwright-heal: $*" >&2; }
|
||||
did() { changed=1; echo "playwright-heal: $*"; }
|
||||
|
||||
# Run as claude whether we were invoked as root (docker exec / entrypoint) or
|
||||
# as claude (terminal session). Nothing user-visible may end up root-owned.
|
||||
as_claude() {
|
||||
if [ "$(id -u)" = 0 ]; then
|
||||
su "$TARGET_USER" -s /bin/sh -c "$1"
|
||||
else
|
||||
sh -c "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
# ── 1. @playwright/cli ───────────────────────────────────────────────────────
|
||||
if [ "$SEED_ONLY" = 1 ]; then
|
||||
:
|
||||
elif [ -f "$CLI_ENTRY" ]; then
|
||||
say "@playwright/cli present"
|
||||
else
|
||||
# An empty leftover @playwright/ can make npm consider the tree settled.
|
||||
if [ -d "$PW_DIR/node_modules/@playwright" ]; then
|
||||
say "clearing partial @playwright install"
|
||||
rm -rf "$PW_DIR/node_modules/@playwright"
|
||||
fi
|
||||
say "installing @playwright/cli..."
|
||||
if as_claude "cd $PW_DIR && npm install --no-save --no-audit --no-fund @playwright/cli" >/tmp/pw-heal-npm.log 2>&1; then
|
||||
did "installed @playwright/cli"
|
||||
else
|
||||
warn "npm install failed; see /tmp/pw-heal-npm.log"
|
||||
failed=1
|
||||
fi
|
||||
fi
|
||||
|
||||
# ── 2. bundled chromium ──────────────────────────────────────────────────────
|
||||
# Ask Playwright where *this* version's chromium belongs rather than globbing
|
||||
# chromium-*, which would call a stale revision "present" and then fail at
|
||||
# launch with 'Browser "chrome-for-testing" is not installed'. --dry-run prints
|
||||
# the install location for the installed version and downloads nothing.
|
||||
if [ "$SEED_ONLY" = 1 ]; then
|
||||
:
|
||||
else
|
||||
chromium_dir=""
|
||||
if [ -f "$PW_DIR/node_modules/playwright-core/cli.js" ]; then
|
||||
chromium_dir=$(as_claude "cd $PW_DIR && node node_modules/playwright-core/cli.js install --dry-run chromium 2>/dev/null" \
|
||||
| awk '/Install location:/ { print $3; exit }')
|
||||
fi
|
||||
|
||||
if [ -n "$chromium_dir" ] && [ -d "$chromium_dir" ]; then
|
||||
say "chromium present ($(basename "$chromium_dir"))"
|
||||
elif [ -f "$PW_DIR/node_modules/playwright-core/cli.js" ]; then
|
||||
say "downloading chromium (~300 MB)..."
|
||||
if as_claude "cd $PW_DIR && node node_modules/playwright-core/cli.js install chromium" >/tmp/pw-heal-browser.log 2>&1; then
|
||||
did "installed chromium"
|
||||
else
|
||||
warn "chromium install failed; see /tmp/pw-heal-browser.log"
|
||||
failed=1
|
||||
fi
|
||||
else
|
||||
warn "playwright-core missing, cannot install chromium"
|
||||
failed=1
|
||||
fi
|
||||
fi
|
||||
|
||||
# ── 3. cli.config.json ───────────────────────────────────────────────────────
|
||||
# The *global* config, not a project-level .playwright/, because the project
|
||||
# one resolves relative to the current working directory and silently stops
|
||||
# applying the moment you cd elsewhere.
|
||||
#
|
||||
# `chrome-for-testing` is the only recognised chromium alias — "chromium" is
|
||||
# not one and falls back to system Chrome. chromiumSandbox:false is what
|
||||
# actually appends --no-sandbox.
|
||||
write_config() {
|
||||
mkdir -p "$CONFIG_DIR" || return 1
|
||||
cat > "$CONFIG_FILE" <<EOF
|
||||
{
|
||||
"browser": {
|
||||
"browserName": "chromium",
|
||||
"launchOptions": {
|
||||
"channel": "chrome-for-testing",
|
||||
"chromiumSandbox": false,
|
||||
"args": ["--no-sandbox", "--disable-dev-shm-usage"]
|
||||
},
|
||||
"contextOptions": {
|
||||
"storageState": "$STATE_FILE"
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
chown -R "$TARGET_USER:$TARGET_USER" "$CONFIG_DIR" 2>/dev/null || true
|
||||
}
|
||||
|
||||
# storageState is a *load* path, and Playwright reads it at context creation.
|
||||
# A path that does not exist is not treated as "no saved state" — it is a hard
|
||||
# error, "Error reading storage state from …", on every single launch. So the
|
||||
# file has to exist before the config that names it can be used at all, and it
|
||||
# has to be recreated if anything deletes it. An empty state is valid and
|
||||
# behaves exactly like no state.
|
||||
#
|
||||
# The path is read back out of the config rather than assumed, so a
|
||||
# hand-edited config pointing somewhere else still gets its file created
|
||||
# instead of being silently broken by ours.
|
||||
ensure_state_file() {
|
||||
[ -f "$CONFIG_FILE" ] || return 0
|
||||
state_path=$(grep -o '"storageState"[[:space:]]*:[[:space:]]*"[^"]*"' "$CONFIG_FILE" 2>/dev/null \
|
||||
| sed 's/.*"\([^"]*\)"[[:space:]]*$/\1/')
|
||||
[ -n "$state_path" ] || return 0
|
||||
[ -f "$state_path" ] && return 0
|
||||
mkdir -p "$(dirname "$state_path")" 2>/dev/null
|
||||
printf '{\n "cookies": [],\n "origins": []\n}\n' > "$state_path" || return 1
|
||||
chown "$TARGET_USER:$TARGET_USER" "$state_path" 2>/dev/null || true
|
||||
did "created empty $state_path (storageState needs it to exist)"
|
||||
}
|
||||
|
||||
if [ ! -f "$CONFIG_FILE" ]; then
|
||||
if write_config; then did "wrote $CONFIG_FILE"; else warn "could not write $CONFIG_FILE"; failed=1; fi
|
||||
elif [ "$FORCE_CONFIG" = 1 ]; then
|
||||
if write_config; then did "overwrote $CONFIG_FILE (--force-config)"; else warn "could not write $CONFIG_FILE"; failed=1; fi
|
||||
elif grep -q '"chromiumSandbox"[[:space:]]*:[[:space:]]*false' "$CONFIG_FILE" 2>/dev/null; then
|
||||
say "config present and disables the sandbox"
|
||||
else
|
||||
# Present but hand-edited into a state that will not launch. Do not clobber
|
||||
# deliberate config silently; say what is wrong and how to replace it.
|
||||
warn "config at $CONFIG_FILE does not set chromiumSandbox:false — the browser will likely fail to launch. Re-run with --force-config to replace it."
|
||||
fi
|
||||
|
||||
# Unconditional: the config may name a storageState this run did not write —
|
||||
# one seeded by an older version of this script, or edited by hand — and a
|
||||
# missing file there breaks every launch.
|
||||
ensure_state_file || { warn "could not create the storage-state file"; failed=1; }
|
||||
|
||||
if [ "$SEED_ONLY" = 1 ]; then
|
||||
[ "$failed" = 1 ] && exit 1
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# ── 4. xvfb (headed dashboard only) ──────────────────────────────────────────
|
||||
# Current base images get this from `playwright install-deps` (its `tools`
|
||||
# group); older ones predate that layer. Headless never needs it, so a missing
|
||||
# xvfb is a note, not a failure.
|
||||
if command -v Xvfb >/dev/null 2>&1; then
|
||||
say "xvfb present"
|
||||
elif [ "$(id -u)" = 0 ]; then
|
||||
say "installing xvfb (needed only for the headed dashboard)..."
|
||||
if (apt-get update -qq && DEBIAN_FRONTEND=noninteractive apt-get install -y -qq xvfb) >/tmp/pw-heal-xvfb.log 2>&1; then
|
||||
did "installed xvfb"
|
||||
else
|
||||
warn "xvfb install failed (headless still works); see /tmp/pw-heal-xvfb.log"
|
||||
fi
|
||||
else
|
||||
say "xvfb missing and not running as root — skipping (headless still works)"
|
||||
fi
|
||||
|
||||
# ── 4b. socat (the browser-view pane's tunnel) ───────────────────────────────
|
||||
# Not Playwright's, but the same class of failure and it presents as a
|
||||
# Playwright problem: the pane's host-side proxy reaches the dashboard by
|
||||
# running `socat` *inside* the container over a Docker exec. On a container old
|
||||
# enough to predate socat in the base image, that exec produces something that
|
||||
# is not an HTTP response, and the webview reports "127.0.0.1 sent an invalid
|
||||
# response" — with the container side working perfectly. A project keeps the
|
||||
# base image it was first built from until it is migrated, so this is the
|
||||
# normal case on an older project, not an exotic one.
|
||||
if command -v socat >/dev/null 2>&1; then
|
||||
say "socat present"
|
||||
elif [ "$(id -u)" = 0 ]; then
|
||||
say "installing socat (needed by the browser-view pane)..."
|
||||
if (apt-get update -qq && DEBIAN_FRONTEND=noninteractive apt-get install -y -qq socat) >/tmp/pw-heal-socat.log 2>&1; then
|
||||
did "installed socat"
|
||||
else
|
||||
warn "socat install failed; the browser-view pane will report an invalid response. See /tmp/pw-heal-socat.log"
|
||||
failed=1
|
||||
fi
|
||||
else
|
||||
warn "socat missing and not running as root — the browser-view pane will report an invalid response"
|
||||
fi
|
||||
|
||||
# ── 5. verify by actually launching ──────────────────────────────────────────
|
||||
# Every step above can report success while the browser still refuses to
|
||||
# start — that is precisely how this broke. A dedicated session name keeps
|
||||
# this clear of whatever the agent already has open.
|
||||
if [ -f "$CLI_ENTRY" ]; then
|
||||
verify_out=$(as_claude "cd /tmp && timeout 90 node $CLI_ENTRY -s=heal-verify open 'data:text/html,<h1>ok</h1>' 2>&1")
|
||||
if printf '%s' "$verify_out" | grep -q 'opened with pid'; then
|
||||
say "verified: browser launches"
|
||||
as_claude "cd /tmp && timeout 30 node $CLI_ENTRY -s=heal-verify close" >/dev/null 2>&1
|
||||
else
|
||||
warn "browser still fails to launch:"
|
||||
printf '%s\n' "$verify_out" | grep -m4 -E 'namespace|Check failed|is not installed|is not found|missing dependencies|Error' >&2
|
||||
failed=1
|
||||
fi
|
||||
else
|
||||
warn "@playwright/cli not installed — nothing to verify"
|
||||
failed=1
|
||||
fi
|
||||
|
||||
[ "$failed" = 1 ] && exit 1
|
||||
[ "$changed" = 1 ] && say "done — repairs applied" || say "done — nothing to repair"
|
||||
exit 0
|
||||
Reference in New Issue
Block a user