From ba7d426b3441c5980f75059f8f4aaba62121a9fa Mon Sep 17 00:00:00 2001 From: fismif Date: Wed, 18 Nov 2026 12:03:55 +0100 Subject: [PATCH 1/3] feat: Allow all network access when starting an Enclave session The Container group of the session create and restart forms gets an "Allow all network access" checkbox above Extra allowed domains. It defaults to Enclave's resolved allow_all_network and is locked on under the QEMU backend. Like hostConfig, it is recorded and passed only when it differs from the config (--allow-all-network, or =false), and Restart and Continue replay it. CLI-started sessions pick it up from ps --json. While all network is allowed, --allow-domain is not passed: nothing enforces it on Docker, and QEMU rejects it. The form greys the domains out through a generic daemon-sent schema keyword, x-disabled-when, and keeps their value. Refs eclipse-enclave/homeshell#15 --- daemon/internal/provider/enclave/sandbox.go | 40 +++++++++--- .../internal/provider/enclave/sandbox_test.go | 55 +++++++++++++++- .../provider/enclave/sandboxschema/schema.go | 53 ++++++++++++---- .../enclave/sandboxschema/schema_test.go | 60 ++++++++++++++++-- docs/API.md | 6 ++ docs/PROVIDERS.md | 11 +++- .../web-e2e/src/api/session-restart.spec.ts | 63 +++++++++++++++++++ .../web-e2e/src/ui/session-settings.spec.ts | 36 +++++++++++ .../components/src/lib/schema-form.spec.tsx | 60 ++++++++++++++++++ .../components/src/lib/schema-form.tsx | 12 ++-- .../components/src/lib/schema-values.spec.ts | 27 ++++++++ .../components/src/lib/schema-values.ts | 24 +++++++ 12 files changed, 412 insertions(+), 35 deletions(-) diff --git a/daemon/internal/provider/enclave/sandbox.go b/daemon/internal/provider/enclave/sandbox.go index 6131704..9bafb05 100644 --- a/daemon/internal/provider/enclave/sandbox.go +++ b/daemon/internal/provider/enclave/sandbox.go @@ -128,12 +128,13 @@ func (p *Provider) sandboxBase(ctx context.Context, dir, tool string) (sandboxsc // sandboxChoice is the sandbox group as a create form submits it. A field left // out means "Enclave's default". type sandboxChoice struct { - Features *[]string `json:"features,omitempty"` - Dirs []sandboxschema.Dir `json:"dirs,omitempty"` - Ports []string `json:"ports,omitempty"` - BridgePorts []int `json:"bridgePorts,omitempty"` - AllowDomains []string `json:"allowDomains,omitempty"` - HostConfig *bool `json:"hostConfig,omitempty"` + Features *[]string `json:"features,omitempty"` + Dirs []sandboxschema.Dir `json:"dirs,omitempty"` + Ports []string `json:"ports,omitempty"` + BridgePorts []int `json:"bridgePorts,omitempty"` + AllowAllNetwork *bool `json:"allowAllNetwork,omitempty"` + AllowDomains []string `json:"allowDomains,omitempty"` + HostConfig *bool `json:"hostConfig,omitempty"` } // unavailableSandboxSchema stands in for the sandbox group when Enclave could not @@ -146,7 +147,8 @@ var unavailableSandboxSchema = json.RawMessage(`{"type":"object","title":"Contai // Enclave. func (choice sandboxChoice) isEmpty() bool { return choice.Features == nil && len(choice.Dirs) == 0 && len(choice.Ports) == 0 && - len(choice.BridgePorts) == 0 && len(choice.AllowDomains) == 0 && choice.HostConfig == nil + len(choice.BridgePorts) == 0 && choice.AllowAllNetwork == nil && len(choice.AllowDomains) == 0 && + choice.HostConfig == nil } // sandboxOf reads the sandbox group out of a session config. @@ -208,7 +210,24 @@ func sandboxFlags(choice sandboxChoice, base sandboxschema.Base) []string { bridge[i] = strconv.Itoa(port) } flags = append(flags, extendList("--bridge-port", config.List("bridge_ports"), bridge)...) - flags = append(flags, extendList("--allow-domain", config.List("allow_domains"), choice.AllowDomains)...) + // Boolean flags take an explicit value, and the command line beats Enclave's + // config, so a session can also restrict what the config allows. With all + // network allowed there is no allowlist for the domains to extend. The QEMU + // backend always allows all network and rejects `--allow-domain`, so there a + // recorded restriction is dropped too. + qemu := config.String("backend") == "qemu" + allowAllNetwork := config.Bool("allow_all_network") || qemu + if !qemu && choice.AllowAllNetwork != nil && *choice.AllowAllNetwork != allowAllNetwork { + allowAllNetwork = *choice.AllowAllNetwork + if allowAllNetwork { + flags = append(flags, "--allow-all-network") + } else { + flags = append(flags, "--allow-all-network=false") + } + } + if !allowAllNetwork { + flags = append(flags, extendList("--allow-domain", config.List("allow_domains"), choice.AllowDomains)...) + } if choice.HostConfig != nil && *choice.HostConfig != (config.String("host_config") == "passthrough") { value := "none" @@ -278,6 +297,11 @@ func sandboxChoiceFromOptions(running map[string]json.RawMessage, base sandboxsc choice.BridgePorts = append(choice.BridgePorts, number) } } + if allowAllNetwork, ok := decode[bool](running, "allow_all_network"); ok { + if allowAllNetwork != base.Bool("allow_all_network") { + choice.AllowAllNetwork = &allowAllNetwork + } + } choice.AllowDomains = listed("allow_domains") if hostConfig, ok := decode[string](running, "host_config"); ok { if passthrough := hostConfig == "passthrough"; passthrough != (base.String("host_config") == "passthrough") { diff --git a/daemon/internal/provider/enclave/sandbox_test.go b/daemon/internal/provider/enclave/sandbox_test.go index 9c6dcbc..f223b11 100644 --- a/daemon/internal/provider/enclave/sandbox_test.go +++ b/daemon/internal/provider/enclave/sandbox_test.go @@ -126,6 +126,50 @@ func TestSandboxFlagsAgainstAConfigThatTurnsThingsOn(t *testing.T) { } } +// A session can allow all network, or turn off what Enclave's config allows, and +// while all network is allowed the domains, which nothing would enforce, are not +// passed. +func TestSandboxFlagsForAllNetwork(t *testing.T) { + tests := []struct { + name string + configured bool + qemu bool + choice sandboxChoice + want []string + }{ + {name: "allowed for one session", + choice: sandboxChoice{AllowAllNetwork: ptr(true)}, want: []string{"--allow-all-network"}}, + {name: "restricted as configured", choice: sandboxChoice{AllowAllNetwork: ptr(false)}}, + {name: "allowed as configured", configured: true, choice: sandboxChoice{AllowAllNetwork: ptr(true)}}, + {name: "restricted for one session against the config", configured: true, + choice: sandboxChoice{AllowAllNetwork: ptr(false)}, want: []string{"--allow-all-network=false"}}, + {name: "restricted for one session keeps the extra domains", configured: true, + choice: sandboxChoice{AllowAllNetwork: ptr(false), AllowDomains: []string{"cdn.example.com"}}, + want: []string{"--allow-all-network=false", "--allow-domain", "api.example.com", "--allow-domain", "cdn.example.com"}}, + {name: "extra domains are not passed while allowed", + choice: sandboxChoice{AllowAllNetwork: ptr(true), AllowDomains: []string{"cdn.example.com"}}, + want: []string{"--allow-all-network"}}, + {name: "nor while the config allows it", configured: true, + choice: sandboxChoice{AllowDomains: []string{"cdn.example.com"}}}, + {name: "the QEMU backend ignores a restriction, and the domains it would reject", configured: true, qemu: true, + choice: sandboxChoice{AllowAllNetwork: ptr(false), AllowDomains: []string{"cdn.example.com"}}}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + base := testBase() + if tt.configured { + base.Config["allow_all_network"] = option(`true`, "project") + } + if tt.qemu { + base.Config["backend"] = option(`"qemu"`, "global") + } + if got := sandboxFlags(tt.choice, base); !slices.Equal(got, tt.want) { + t.Errorf("sandboxFlags = %q; want %q", got, tt.want) + } + }) + } +} + // The features Enclave resolves for the tool produce no flag, in any order. func TestSandboxFlagsAgainstTheToolsFeatureSelection(t *testing.T) { base := testBase() @@ -145,9 +189,10 @@ func TestSandboxOf(t *testing.T) { if _, ok := sandboxOf(json.RawMessage(`{"model":"opus"}`)); ok { t.Error("a config without the group: want no sandbox") } - choice, ok := sandboxOf(json.RawMessage(`{"enclave":{"features":["devtools"],"bridgePorts":[5432],"hostConfig":true}}`)) + choice, ok := sandboxOf(json.RawMessage(`{"enclave":{"features":["devtools"],"bridgePorts":[5432],"allowAllNetwork":true,"hostConfig":true}}`)) if !ok || choice.Features == nil || !slices.Equal(*choice.Features, []string{"devtools"}) || - !slices.Equal(choice.BridgePorts, []int{5432}) || choice.HostConfig == nil || !*choice.HostConfig { + !slices.Equal(choice.BridgePorts, []int{5432}) || choice.HostConfig == nil || !*choice.HostConfig || + choice.AllowAllNetwork == nil || !*choice.AllowAllNetwork { t.Errorf("sandboxOf = %+v, %v", choice, ok) } } @@ -469,6 +514,9 @@ func TestSandboxChoiceFromOptions(t *testing.T) { {name: "host config passed through", running: map[string]string{"host_config": `"passthrough"`}, want: sandboxChoice{HostConfig: ptr(true)}}, {name: "host config as configured", running: map[string]string{"host_config": `"none"`}}, + {name: "all network allowed", running: map[string]string{"allow_all_network": `true`}, + want: sandboxChoice{AllowAllNetwork: ptr(true)}}, + {name: "network restricted as configured", running: map[string]string{"allow_all_network": `false`}}, {name: "options the form does not model", running: map[string]string{"yolo": `true`, "backend": `"auto"`}}, } for _, tt := range tests { @@ -489,6 +537,9 @@ func TestSandboxChoiceConfigHasNoNulls(t *testing.T) { if got := (sandboxChoice{AllowDomains: []string{"y.org"}}).config(); string(got) != `{"enclave":{"allowDomains":["y.org"]}}` { t.Errorf("config = %s", got) } + if got := (sandboxChoice{AllowAllNetwork: ptr(false)}).config(); string(got) != `{"enclave":{"allowAllNetwork":false}}` { + t.Errorf("config = %s; want a restricted network kept, not dropped as unset", got) + } if got := (sandboxChoice{}).config(); string(got) != `{}` { t.Errorf("empty config = %s; want {}", got) } diff --git a/daemon/internal/provider/enclave/sandboxschema/schema.go b/daemon/internal/provider/enclave/sandboxschema/schema.go index b0a2984..d987303 100644 --- a/daemon/internal/provider/enclave/sandboxschema/schema.go +++ b/daemon/internal/provider/enclave/sandboxschema/schema.go @@ -1,7 +1,8 @@ // Package sandboxschema builds the create-form group for an Enclave container's -// sandbox settings — features, mounts, ports, domains, host config — from what -// Enclave resolves for a tool, with Enclave's values as the defaults. It is free -// of the Enclave provider so the fake provider's demo offers the same form. +// sandbox settings — features, mounts, ports, network, domains, host config — +// from what Enclave resolves for a tool, with Enclave's values as the defaults. +// It is free of the Enclave provider so the fake provider's demo offers the same +// form. // // Two properties of Enclave's flags shape the form: a list flag replaces the // configured list rather than adding to it (enclave#99), and no flag empties one. @@ -214,17 +215,18 @@ func Schema(base Base) json.RawMessage { "default": []int{}, }, inheritedBridge, listSource(config, "bridge_ports"))) - domainsDescription := "Domains the container may reach, in addition to Enclave's allowlist for the agent and its features." - if config.Bool("allow_all_network") { - domainsDescription = "Enclave's config allows all network access for this project, so extra domains change nothing." - } + props = props.add("allowAllNetwork", allowAllNetworkProp(config)) + + // Without the gateway there is no allowlist to extend, so the domains are + // greyed out while all network is allowed, and kept for when it no longer is. props = props.add("allowDomains", withInherited(map[string]any{ - "type": "array", - "title": "Extra allowed domains", - "description": domainsDescription, - "uniqueItems": true, - "items": map[string]any{"type": "string", "pattern": domainNamePattern, "maxLength": 253}, - "default": []string{}, + "type": "array", + "title": "Extra allowed domains", + "description": "Domains the container may reach, in addition to Enclave's allowlist for the agent and its features.", + "uniqueItems": true, + "items": map[string]any{"type": "string", "pattern": domainNamePattern, "maxLength": 253}, + "default": []string{}, + "x-disabled-when": map[string]any{"allowAllNetwork": true}, }, config.List("allow_domains"), listSource(config, "allow_domains"))) props = props.add("hostConfig", map[string]any{ @@ -250,6 +252,31 @@ func Schema(base Base) json.RawMessage { return out } +// allowAllNetworkProp is the checkbox that turns Enclave's network restrictions +// off for a session (`--allow-all-network`), defaulting to what Enclave's config +// says. A config that allows all network can still be overridden for one session +// (`--allow-all-network=false`); the QEMU backend cannot, as it has no restricted +// network, so there the checkbox is locked on. Enclave's network policy mode is +// not in `enclave config --json`, so a global "unrestricted" mode goes unseen. +func allowAllNetworkProp(config EffectiveConfig) map[string]any { + const consequence = "The container can reach any host. Enclave also stops shielding your agent tokens, " + + "so the agent sees the real ones." + prop := map[string]any{ + "type": "boolean", + "title": "Allow all network access", + "description": consequence, + "default": config.Bool("allow_all_network"), + "x-source": sourceLabel(config["allow_all_network"].Source), + } + if config.String("backend") == "qemu" { + prop["description"] = "Enclave's QEMU backend always allows all network access. " + consequence + prop["default"] = true + prop["readOnly"] = true + prop["x-source"] = sourceLabel(config["backend"].Source) + } + return prop +} + // retiredSettings are settings the group no longer offers. They are accepted on // create and restart, kept in the record but not passed to Enclave, so a session // recorded with one still restarts, without the setting; the form shows only diff --git a/daemon/internal/provider/enclave/sandboxschema/schema_test.go b/daemon/internal/provider/enclave/sandboxschema/schema_test.go index 0cad977..b6ea2f5 100644 --- a/daemon/internal/provider/enclave/sandboxschema/schema_test.go +++ b/daemon/internal/provider/enclave/sandboxschema/schema_test.go @@ -132,7 +132,7 @@ func TestSchema(t *testing.T) { group := Schema(testBase()) names, props := schemaProps(t, group) - wantOrder := []string{"features", "dirs", "ports", "bridgePorts", "allowDomains", "hostConfig"} + wantOrder := []string{"features", "dirs", "ports", "bridgePorts", "allowAllNetwork", "allowDomains", "hostConfig"} if !slices.Equal(names, wantOrder) { t.Errorf("field order = %q; want %q", names, wantOrder) } @@ -170,7 +170,7 @@ func TestSchema(t *testing.T) { // The group must be a schema the daemon can validate a submitted config with. schema := with(t, nil, group) - if err := provider.ValidateConfig(schema, json.RawMessage(`{"enclave":{"features":["playwright"],"dirs":[{"path":"/x","readonly":true}],"ports":["3000","0:3000","8080:80","127.0.0.1:8080:80","[::1]:8080:80","*:8080:80","65535"],"bridgePorts":[6379],"allowDomains":["cdn.example.com","API.Example.COM"],"hostConfig":true}}`)); err != nil { + if err := provider.ValidateConfig(schema, json.RawMessage(`{"enclave":{"features":["playwright"],"dirs":[{"path":"/x","readonly":true}],"ports":["3000","0:3000","8080:80","127.0.0.1:8080:80","[::1]:8080:80","*:8080:80","65535"],"bridgePorts":[6379],"allowAllNetwork":true,"allowDomains":["cdn.example.com","API.Example.COM"],"hostConfig":true}}`)); err != nil { t.Errorf("a valid sandbox config was refused: %v", err) } for name, config := range map[string]string{ @@ -187,6 +187,7 @@ func TestSchema(t *testing.T) { "a domain with a port": `{"enclave":{"allowDomains":["example.com:443"]}}`, "a dir with no path": `{"enclave":{"dirs":[{"readonly":true}]}}`, "a setting the group lacks": `{"enclave":{"yolo":true}}`, + "all network as a string": `{"enclave":{"allowAllNetwork":"yes"}}`, } { if err := provider.ValidateConfig(schema, json.RawMessage(config)); err == nil { t.Errorf("%s was accepted", name) @@ -194,16 +195,63 @@ func TestSchema(t *testing.T) { } } -func TestSchemaWithoutFeaturesAndWithAllNetwork(t *testing.T) { +func TestSchemaWithoutFeatures(t *testing.T) { base := testBase() base.Features = nil - base.Config["allow_all_network"] = option(`true`, "global") _, props := schemaProps(t, Schema(base)) if _, ok := props["features"]; ok { t.Error("an Enclave listing no features still gets a features field") } - if !strings.Contains(props["allowDomains"]["description"].(string), "allows all network access") { - t.Errorf("allowDomains description = %q; want it to say extra domains change nothing", props["allowDomains"]["description"]) +} + +func TestSchemaAllowAllNetwork(t *testing.T) { + tests := []struct { + name string + config map[string]ConfigOption + wantDefault bool + wantSource string + wantReadOnly bool + }{ + {name: "restricted by default", wantDefault: false, wantSource: "Enclave defaults"}, + {name: "allowed by Enclave's project config", + config: map[string]ConfigOption{"allow_all_network": option(`true`, "project")}, + wantDefault: true, wantSource: "Enclave project config"}, + {name: "forced by the QEMU backend", + config: map[string]ConfigOption{ + "allow_all_network": option(`true`, "default"), + "backend": option(`"qemu"`, "global"), + }, + wantDefault: true, wantSource: "Enclave global config", wantReadOnly: true}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + base := testBase() + for name, value := range tt.config { + base.Config[name] = value + } + _, props := schemaProps(t, Schema(base)) + field := props["allowAllNetwork"] + if field["type"] != "boolean" || field["title"] != "Allow all network access" { + t.Errorf("allowAllNetwork = %v; want a checkbox titled for what it does", field) + } + if field["default"] != tt.wantDefault || field["x-source"] != tt.wantSource { + t.Errorf("allowAllNetwork default = %v from %v; want %v from %v", + field["default"], field["x-source"], tt.wantDefault, tt.wantSource) + } + if readOnly, _ := field["readOnly"].(bool); readOnly != tt.wantReadOnly { + t.Errorf("allowAllNetwork readOnly = %v; want %v", readOnly, tt.wantReadOnly) + } + description, _ := field["description"].(string) + if !strings.Contains(description, "real ones") { + t.Errorf("allowAllNetwork description = %q; want it to warn that the agent sees real tokens", description) + } + if tt.wantReadOnly && !strings.Contains(description, "QEMU") { + t.Errorf("allowAllNetwork description = %q; want it to say the QEMU backend forces it", description) + } + if got := props["allowDomains"]["x-disabled-when"]; !equalJSON(got, map[string]any{"allowAllNetwork": true}) { + t.Errorf("allowDomains x-disabled-when = %v; want it disabled while all network is allowed", got) + } + }) } } diff --git a/docs/API.md b/docs/API.md index 5e00ca9..d4e2bb5 100644 --- a/docs/API.md +++ b/docs/API.md @@ -320,6 +320,12 @@ Paths are under `/api/projects/{projectId}`; `{ws}` stands for `/workstreams/{wo - **Schemas** list the session types each session provider offers in this workstream; `schema` is a JSON Schema the UI renders as the create form. Read per request, so catalog edits apply at once. +- **Form keywords** beyond JSON Schema, which the UI reads but never works out itself: + - `x-source`: where a field's default comes from, shown while the field holds it. + - `x-inherited`: `{values, source}` a list already gets from elsewhere, shown locked and not part + of its value. + - `x-disabled-when`: on a field in a group, `{sibling: value, …}`. The field is greyed out while + every named sibling holds its value, and keeps what it holds for when it no longer does. - **Placeholders** carry `placeholder: true`: the daemon's own row for a session create in flight, or one that failed. Deleting one cancels its create. A session restarting is `starting` too, but carries no flag. diff --git a/docs/PROVIDERS.md b/docs/PROVIDERS.md index a5a7770..0b0ee65 100644 --- a/docs/PROVIDERS.md +++ b/docs/PROVIDERS.md @@ -244,11 +244,18 @@ container is Enclave's to manage. Why: the default container stays free for the next `enclave` start in a terminal. A restart or Continue of an ended session whose container runs again (a new `enclave` start in a terminal) is refused (`409`) and stops nothing; the next inventory check adopts the new session. +- **Allow all network access** in the Container settings passes `--allow-all-network`, or + `--allow-all-network=false` to restrict a session whose Enclave config allows all network. It + defaults to the config's `allow_all_network`; with the QEMU backend it is locked on, as Enclave + forces it there. While it is on, Extra allowed domains is greyed out and not passed. Enclave's + network policy mode (`enclave network set-mode`) is not in `enclave config --json`, so a session + under an `unrestricted` mode runs unrestricted whatever the checkbox says. - **CLI session settings:** a CLI session has no recorded launch config (a session HomeShell started that is started again in a terminal under its name drops its own), so its restart or Continue starts with the options Enclave recorded for the container, as far as the create form models - them (features, directories, ports, bridge ports, domains, host config). They become its launch - config, so [drift](ARCHITECTURE.md#enclave-sessions) and the settings editor apply from then on. + them (features, directories, ports, bridge ports, all network, domains, host config). They + become its launch config, so [drift](ARCHITECTURE.md#enclave-sessions) and the settings editor + apply from then on. Other options and the tool's arguments restart as Enclave resolves them now (GAP 11). - **CLI gaps** that limit it are in `provider/enclave/gaps.go`: no container event stream, `stop` also removes, no `start`, no published-port URL (so no web-IDE link), no `logs`, no shell diff --git a/webapp/apps/web-e2e/src/api/session-restart.spec.ts b/webapp/apps/web-e2e/src/api/session-restart.spec.ts index 534dd4f..9c59f58 100644 --- a/webapp/apps/web-e2e/src/api/session-restart.spec.ts +++ b/webapp/apps/web-e2e/src/api/session-restart.spec.ts @@ -110,6 +110,69 @@ test.describe('session restart API', () => { ); }); + test('the container group offers all network access, which disables the domains', async ({ + request, + }) => { + const projectId = await createProject(request, 'hs-restart-e2e-'); + const wsId = await createWorkstream(request, projectId, 'restart'); + const [group] = await ( + await request.get( + `/api/projects/${projectId}/workstreams/${wsId}/session-schemas`, + ) + ).json(); + const container = group.options.find( + (candidate: { id: string }) => candidate.id === 'sandboxed', + ).schema.properties.enclave; + const names = Object.keys(container.properties); + expect(names.indexOf('allowAllNetwork')).toBe( + names.indexOf('allowDomains') - 1, + ); + expect(container.properties.allowAllNetwork).toMatchObject({ + type: 'boolean', + title: 'Allow all network access', + default: false, + }); + expect(container.properties.allowDomains['x-disabled-when']).toEqual({ + allowAllNetwork: true, + }); + }); + + test('a session allowed all network keeps it across a restart, until turned off', async ({ + request, + }) => { + const allowed = { + ...created, + enclave: { ...created.enclave, allowAllNetwork: true }, + }; + const sessionPath = await sandboxedSession(request, allowed); + expect((await awaitLaunchConfig(request, sessionPath)).config).toEqual( + allowed, + ); + + let res = await request.post(`${sessionPath}/restart`, { + data: { config: allowed, fresh: false }, + }); + expect(res.status()).toBe(202); + expect((await awaitLaunchConfig(request, sessionPath)).config).toEqual( + allowed, + ); + + // Turned off, it is Enclave's default again, so it is not recorded. + res = await request.post(`${sessionPath}/restart`, { + data: { + config: { + ...created, + enclave: { ...created.enclave, allowAllNetwork: false }, + }, + fresh: false, + }, + }); + expect(res.status()).toBe(202); + expect((await awaitLaunchConfig(request, sessionPath)).config).toEqual( + created, + ); + }); + test('the providers report which can restart a session', async ({ request, }) => { diff --git a/webapp/apps/web-e2e/src/ui/session-settings.spec.ts b/webapp/apps/web-e2e/src/ui/session-settings.spec.ts index a07c276..3b27b42 100644 --- a/webapp/apps/web-e2e/src/ui/session-settings.spec.ts +++ b/webapp/apps/web-e2e/src/ui/session-settings.spec.ts @@ -185,6 +185,42 @@ test('the container group summarizes its changes and sends them nested', async ( }); }); +test('allowing all network greys out the extra domains and keeps them', async ({ + page, + request, +}) => { + const { card, projectId, workstreamId } = await emptyCard(page, request); + const form = await openSandboxedForm(page, card); + await form.getByRole('button', { name: /^Container / }).click(); + const domains = form.getByRole('textbox', { + name: 'Add to Extra allowed domains', + }); + await domains.fill('api.example.com'); + await domains.press('Enter'); + + const allowAll = form.getByRole('checkbox', { + name: 'Allow all network access', + }); + await expect(allowAll).not.toBeChecked(); + await expect(allowAll).toHaveAccessibleDescription( + /the agent sees the real ones/, + ); + await allowAll.check(); + await expect(domains).toHaveAttribute('aria-disabled', 'true'); + await expect(form.getByText('api.example.com')).toBeVisible(); + await expect(form.getByTestId('group-summary')).toHaveText( + 'Allow all network access · Extra allowed domains +1', + ); + + await form.getByRole('button', { name: 'Start session' }).click(); + await expect(form).toHaveCount(0); + const { launched } = await launchConfigOf(request, projectId, workstreamId); + expect(launched.config).toEqual({ + model: 'sonnet', + enclave: { allowAllNetwork: true, allowDomains: ['api.example.com'] }, + }); +}); + test('a session started on the defaults records an empty group', async ({ page, request, diff --git a/webapp/packages/components/src/lib/schema-form.spec.tsx b/webapp/packages/components/src/lib/schema-form.spec.tsx index d8fc64e..f2c9f6a 100644 --- a/webapp/packages/components/src/lib/schema-form.spec.tsx +++ b/webapp/packages/components/src/lib/schema-form.spec.tsx @@ -527,6 +527,66 @@ describe('SchemaField group', () => { }); }); +describe('SchemaField group with a field another one disables', () => { + const network: SchemaProp = { + type: 'object', + title: 'Container', + properties: { + allowAllNetwork: { + type: 'boolean', + title: 'Allow all network access', + default: false, + }, + allowDomains: { + type: 'array', + title: 'Extra allowed domains', + items: { type: 'string' }, + default: [], + 'x-disabled-when': { allowAllNetwork: true }, + }, + }, + }; + + it('greys the field out while the rule holds, keeping its value', () => { + const onValue = vi.fn(); + render( + , + ); + const input = screen.getByRole('textbox', { + name: 'Add to Extra allowed domains', + }); + expect(input.getAttribute('aria-disabled')).not.toBe('true'); + + fireEvent.click( + screen.getByRole('checkbox', { name: 'Allow all network access' }), + ); + expect(input.getAttribute('aria-disabled')).toBe('true'); + fireEvent.click( + screen.getByRole('button', { name: 'Delete cdn.example.com' }), + ); + fireEvent.click( + screen.getByRole('button', { + name: 'Reset Extra allowed domains to its default', + }), + ); + expect(onValue).toHaveBeenLastCalledWith({ + allowAllNetwork: true, + allowDomains: ['cdn.example.com'], + }); + + fireEvent.click( + screen.getByRole('checkbox', { name: 'Allow all network access' }), + ); + expect(input.getAttribute('aria-disabled')).not.toBe('true'); + expect(screen.getByText('cdn.example.com')).toBeTruthy(); + }); +}); + describe('firstField', () => { it('passes over the fields of a collapsed group', () => { render(); diff --git a/webapp/packages/components/src/lib/schema-form.tsx b/webapp/packages/components/src/lib/schema-form.tsx index ba808fa..556470e 100644 --- a/webapp/packages/components/src/lib/schema-form.tsx +++ b/webapp/packages/components/src/lib/schema-form.tsx @@ -18,6 +18,7 @@ import { defaultsOf, fieldsOf, isDefault, + isDisabledBy, isLocked, kindOf, pathHolds, @@ -41,7 +42,9 @@ export * from './schema-values'; * items) or a list of chips (anything else). Conditional keywords * (if/then/allOf) are intentionally not interpreted here: providers keep * disjoint shapes as separate schemas so the client never has to evaluate - * schema logic (domain logic lives in the daemon). + * schema logic (domain logic lives in the daemon). The one dependency between + * fields is a group field's `x-disabled-when`: sibling values, stated by the + * provider, that grey the field out (see `isDisabledBy`). * * Optionality: a field with a schema `default` starts at that value; a *required* * enum with no default starts at its first option; an *optional* enum with no @@ -455,6 +458,7 @@ function SchemaGroup({ {fields.map(({ key, prop: child, required }) => { const modified = !isDefault(child, values[key], required); const childTitle = child.title ?? key; + const childDisabled = disabled || isDisabledBy(child, values); return (
onChange({ ...values, [key]: next })} @@ -478,14 +482,14 @@ function SchemaGroup({ type="button" className={groupStyles.reset} onClick={() => { - if (!disabled) { + if (!childDisabled) { onChange({ ...values, [key]: defaultOf(child, required), }); } }} - aria-disabled={disabled} + aria-disabled={childDisabled} aria-label={`Reset ${childTitle} to its default`} title="Changed from the default. Reset it." > diff --git a/webapp/packages/components/src/lib/schema-values.spec.ts b/webapp/packages/components/src/lib/schema-values.spec.ts index 3ac89b5..4eb054c 100644 --- a/webapp/packages/components/src/lib/schema-values.spec.ts +++ b/webapp/packages/components/src/lib/schema-values.spec.ts @@ -6,6 +6,7 @@ import { defaultsOf, fieldsOf, isDefault, + isDisabledBy, itemNounOf, kindOf, pathHolds, @@ -330,3 +331,29 @@ describe('changedPaths', () => { ]); }); }); + +describe('isDisabledBy', () => { + const domains: SchemaProp = { + type: 'array', + items: { type: 'string' }, + 'x-disabled-when': { allowAllNetwork: true }, + }; + + it('holds while every sibling it names has the given value', () => { + expect(isDisabledBy(domains, { allowAllNetwork: true })).toBe(true); + expect(isDisabledBy(domains, { allowAllNetwork: false })).toBe(false); + expect(isDisabledBy(domains, {})).toBe(false); + const both: SchemaProp = { + 'x-disabled-when': { a: true, b: 'x' }, + }; + expect(isDisabledBy(both, { a: true, b: 'x' })).toBe(true); + expect(isDisabledBy(both, { a: true, b: 'y' })).toBe(false); + }); + + it('never holds without a rule, or with an empty one', () => { + expect(isDisabledBy({ type: 'string' }, { allowAllNetwork: true })).toBe( + false, + ); + expect(isDisabledBy({ 'x-disabled-when': {} }, {})).toBe(false); + }); +}); diff --git a/webapp/packages/components/src/lib/schema-values.ts b/webapp/packages/components/src/lib/schema-values.ts index dc14522..9c8f273 100644 --- a/webapp/packages/components/src/lib/schema-values.ts +++ b/webapp/packages/components/src/lib/schema-values.ts @@ -59,6 +59,11 @@ export interface SchemaProp extends Schema { 'x-source'?: string; /** Values already in effect from elsewhere; not part of the field's value. */ 'x-inherited'?: SchemaInherited; + /** + * Of a group's field: the sibling values that make it take no input, such as + * domains to allow while all network is allowed (see `isDisabledBy`). + */ + 'x-disabled-when'?: Record; } export type ConfigValue = @@ -127,6 +132,25 @@ export function isLocked(prop: SchemaProp): boolean { return prop.type === 'boolean' && prop.readOnly === true; } +/** + * Whether a group's field is greyed out by its siblings: every sibling its + * `x-disabled-when` names holds the value given there. The provider states the + * rule; the form only compares values. Its value stays as it was, for when the + * rule no longer holds. + */ +export function isDisabledBy( + prop: SchemaProp, + siblings: Readonly>, +): boolean { + const rule = prop['x-disabled-when']; + if (!isObject(rule)) return false; + const conditions = Object.entries(rule); + return ( + conditions.length > 0 && + conditions.every(([key, value]) => sameValue(siblings[key], value)) + ); +} + /** * The initial value of one field, with `override` taking precedence — except * over a locked field, which holds its default, and over a choice the field From 8ecca53cdd89d2848f67fd56bd9a87fc982e4195 Mon Sep 17 00:00:00 2001 From: fismif Date: Wed, 18 Nov 2026 13:44:47 +0100 Subject: [PATCH 2/3] fix: Mute the whole list box while a list field is disabled Only the Add input greyed out, so a list disabled by x-disabled-when, or by a form in flight, kept its enabled look in a screenshot. --- webapp/apps/web-e2e/src/ui/session-settings.spec.ts | 5 +++++ .../packages/components/src/lib/schema-fields.module.css | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/webapp/apps/web-e2e/src/ui/session-settings.spec.ts b/webapp/apps/web-e2e/src/ui/session-settings.spec.ts index 3b27b42..fa4e8b5 100644 --- a/webapp/apps/web-e2e/src/ui/session-settings.spec.ts +++ b/webapp/apps/web-e2e/src/ui/session-settings.spec.ts @@ -6,6 +6,7 @@ import { } from '@playwright/test'; import { expect, test } from '../fixtures'; import { pollFor, sessionsOf } from '../api/workstream-helpers'; +import { styleOf } from './contrast'; import { loadApp } from './keyboard-helpers'; import { selectProject, @@ -201,12 +202,16 @@ test('allowing all network greys out the extra domains and keeps them', async ({ const allowAll = form.getByRole('checkbox', { name: 'Allow all network access', }); + // The box around the domains and their chips, not just the input in it. + const boxOpacity = () => styleOf(domains.locator('..'), 'opacity'); await expect(allowAll).not.toBeChecked(); await expect(allowAll).toHaveAccessibleDescription( /the agent sees the real ones/, ); + expect(await boxOpacity()).toBe('1'); await allowAll.check(); await expect(domains).toHaveAttribute('aria-disabled', 'true'); + expect(Number(await boxOpacity())).toBeLessThan(1); await expect(form.getByText('api.example.com')).toBeVisible(); await expect(form.getByTestId('group-summary')).toHaveText( 'Allow all network access · Extra allowed domains +1', diff --git a/webapp/packages/components/src/lib/schema-fields.module.css b/webapp/packages/components/src/lib/schema-fields.module.css index 9fb7e2c..0443bc4 100644 --- a/webapp/packages/components/src/lib/schema-fields.module.css +++ b/webapp/packages/components/src/lib/schema-fields.module.css @@ -255,10 +255,17 @@ cursor: text; } -.chipBox:hover:not(:focus-within) { +.chipBox:hover:not(:focus-within, :has(> input[aria-disabled='true'])) { border-color: var(--hs-text-muted, #8494a7); } +/* While the list takes no input, the box and its values look it, as a + * locked row does, and stay legible. */ +.chipBox:has(> input[aria-disabled='true']) { + opacity: 0.6; + cursor: not-allowed; +} + .chipBox:focus-within { outline: 1px solid var(--hs-accent, #2dd4bf); outline-offset: -1px; From 37f37992fd6858ab503ab70d832b04cf3476b34f Mon Sep 17 00:00:00 2001 From: fismif Date: Wed, 18 Nov 2026 14:42:47 +0100 Subject: [PATCH 3/3] fix: Address review of all-network access MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Drop the QEMU case: HomeShell always starts sessions with --background, which Enclave's QEMU backend does not support, so it could never run. - Say HomeShell does not yet ask `enclave network print --json` for the network policy mode, rather than that it cannot see it, and that --allow-all-network=false cannot override an unrestricted mode. - An unrestricted session still runs an observing gateway; the domains do not apply because unrestricted mode has no allowlist. - Drift skips allow_domains while both the session and the config allow all network, so sessions started that way before are not flagged. - Keep the chip × at full opacity inside a disabled list box, so the box's dimming is the only one. Refs eclipse-enclave/homeshell#15 --- daemon/internal/provider/enclave/drift.go | 7 +++- .../internal/provider/enclave/drift_test.go | 37 +++++++++++++++++++ daemon/internal/provider/enclave/sandbox.go | 9 ++--- .../internal/provider/enclave/sandbox_test.go | 6 --- .../provider/enclave/sandboxschema/schema.go | 30 ++++++--------- .../enclave/sandboxschema/schema_test.go | 21 ++--------- docs/ARCHITECTURE.md | 3 +- docs/PROVIDERS.md | 8 ++-- .../web-e2e/src/ui/session-settings.spec.ts | 6 +++ .../src/lib/schema-fields.module.css | 5 +++ 10 files changed, 78 insertions(+), 54 deletions(-) diff --git a/daemon/internal/provider/enclave/drift.go b/daemon/internal/provider/enclave/drift.go index 25d6bf1..3bbf6fc 100644 --- a/daemon/internal/provider/enclave/drift.go +++ b/daemon/internal/provider/enclave/drift.go @@ -129,14 +129,19 @@ func (p *Provider) outdatedSettings(ctx context.Context, container Container, to // changedOptions names the options whose running value differs from current, // sorted. An option either side does not report is unknown rather than changed, // and so is one Enclave reports as null: it could not resolve it, as `features` -// when the features cannot be listed. +// when the features cannot be listed. `allow_domains` is not compared when both +// sides allow all network: unrestricted mode has no allowlist for it to change. func changedOptions(running map[string]json.RawMessage, current sandboxschema.EffectiveConfig) []string { + unrestricted := sameJSON(running["allow_all_network"], []byte("true")) && current.Bool("allow_all_network") var changed []string for name, value := range running { option, ok := current[name] if !ok || isNull(value) || isNull(option.Value) { continue } + if name == "allow_domains" && unrestricted { + continue + } if !sameJSON(value, option.Value) { changed = append(changed, name) } diff --git a/daemon/internal/provider/enclave/drift_test.go b/daemon/internal/provider/enclave/drift_test.go index 4d19aac..5f5c51e 100644 --- a/daemon/internal/provider/enclave/drift_test.go +++ b/daemon/internal/provider/enclave/drift_test.go @@ -36,6 +36,43 @@ func TestChangedOptions(t *testing.T) { } } +// A session started with extra domains under all network was passed them, but +// the domains change nothing while both sides allow all network. +func TestChangedOptionsAllowDomainsUnderAllNetwork(t *testing.T) { + tests := []struct { + name string + running, config string + want []string + }{ + {name: "both allow all network", running: `true`, config: `true`, want: nil}, + {name: "only the session allows all network", running: `true`, config: `false`, + want: []string{"allow_all_network", "allow_domains"}}, + {name: "only the config allows all network", running: `false`, config: `true`, + want: []string{"allow_all_network", "allow_domains"}}, + {name: "neither allows all network", running: `false`, config: `false`, want: []string{"allow_domains"}}, + // Unknown on the session's side is not taken as allowed, so the domains are compared. + {name: "the session does not report it", running: "", config: `true`, want: []string{"allow_domains"}}, + {name: "the session reports null", running: `null`, config: `true`, want: []string{"allow_domains"}}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + current := sandboxschema.EffectiveConfig{ + "allow_all_network": option(tt.config, "project"), + "allow_domains": option(`[]`, "default"), + } + running := map[string]json.RawMessage{ + "allow_domains": json.RawMessage(`["api.example.com"]`), + } + if tt.running != "" { + running["allow_all_network"] = json.RawMessage(tt.running) + } + if got := changedOptions(running, current); !slices.Equal(got, tt.want) { + t.Errorf("changedOptions = %q; want %q", got, tt.want) + } + }) + } +} + // driftProvider is sandboxProvider listing one container of its workstream, // running with options, whose launch HomeShell recorded when launch is set. func driftProvider(t *testing.T, options map[string]json.RawMessage, launch *domain.LaunchConfig) (*Provider, *fakeCLI) { diff --git a/daemon/internal/provider/enclave/sandbox.go b/daemon/internal/provider/enclave/sandbox.go index 9bafb05..516f510 100644 --- a/daemon/internal/provider/enclave/sandbox.go +++ b/daemon/internal/provider/enclave/sandbox.go @@ -212,12 +212,9 @@ func sandboxFlags(choice sandboxChoice, base sandboxschema.Base) []string { flags = append(flags, extendList("--bridge-port", config.List("bridge_ports"), bridge)...) // Boolean flags take an explicit value, and the command line beats Enclave's // config, so a session can also restrict what the config allows. With all - // network allowed there is no allowlist for the domains to extend. The QEMU - // backend always allows all network and rejects `--allow-domain`, so there a - // recorded restriction is dropped too. - qemu := config.String("backend") == "qemu" - allowAllNetwork := config.Bool("allow_all_network") || qemu - if !qemu && choice.AllowAllNetwork != nil && *choice.AllowAllNetwork != allowAllNetwork { + // network allowed there is no allowlist for the domains to extend. + allowAllNetwork := config.Bool("allow_all_network") + if choice.AllowAllNetwork != nil && *choice.AllowAllNetwork != allowAllNetwork { allowAllNetwork = *choice.AllowAllNetwork if allowAllNetwork { flags = append(flags, "--allow-all-network") diff --git a/daemon/internal/provider/enclave/sandbox_test.go b/daemon/internal/provider/enclave/sandbox_test.go index f223b11..3cb47f1 100644 --- a/daemon/internal/provider/enclave/sandbox_test.go +++ b/daemon/internal/provider/enclave/sandbox_test.go @@ -133,7 +133,6 @@ func TestSandboxFlagsForAllNetwork(t *testing.T) { tests := []struct { name string configured bool - qemu bool choice sandboxChoice want []string }{ @@ -151,8 +150,6 @@ func TestSandboxFlagsForAllNetwork(t *testing.T) { want: []string{"--allow-all-network"}}, {name: "nor while the config allows it", configured: true, choice: sandboxChoice{AllowDomains: []string{"cdn.example.com"}}}, - {name: "the QEMU backend ignores a restriction, and the domains it would reject", configured: true, qemu: true, - choice: sandboxChoice{AllowAllNetwork: ptr(false), AllowDomains: []string{"cdn.example.com"}}}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -160,9 +157,6 @@ func TestSandboxFlagsForAllNetwork(t *testing.T) { if tt.configured { base.Config["allow_all_network"] = option(`true`, "project") } - if tt.qemu { - base.Config["backend"] = option(`"qemu"`, "global") - } if got := sandboxFlags(tt.choice, base); !slices.Equal(got, tt.want) { t.Errorf("sandboxFlags = %q; want %q", got, tt.want) } diff --git a/daemon/internal/provider/enclave/sandboxschema/schema.go b/daemon/internal/provider/enclave/sandboxschema/schema.go index d987303..ce8a91a 100644 --- a/daemon/internal/provider/enclave/sandboxschema/schema.go +++ b/daemon/internal/provider/enclave/sandboxschema/schema.go @@ -217,7 +217,7 @@ func Schema(base Base) json.RawMessage { props = props.add("allowAllNetwork", allowAllNetworkProp(config)) - // Without the gateway there is no allowlist to extend, so the domains are + // Unrestricted mode has no allowlist to extend, so the domains are // greyed out while all network is allowed, and kept for when it no longer is. props = props.add("allowDomains", withInherited(map[string]any{ "type": "array", @@ -255,26 +255,18 @@ func Schema(base Base) json.RawMessage { // allowAllNetworkProp is the checkbox that turns Enclave's network restrictions // off for a session (`--allow-all-network`), defaulting to what Enclave's config // says. A config that allows all network can still be overridden for one session -// (`--allow-all-network=false`); the QEMU backend cannot, as it has no restricted -// network, so there the checkbox is locked on. Enclave's network policy mode is -// not in `enclave config --json`, so a global "unrestricted" mode goes unseen. +// (`--allow-all-network=false`). Enclave's network policy mode, global or +// project, is not asked for yet (`enclave network print --json` would report +// it), and the flag cannot override an "unrestricted" mode. func allowAllNetworkProp(config EffectiveConfig) map[string]any { - const consequence = "The container can reach any host. Enclave also stops shielding your agent tokens, " + - "so the agent sees the real ones." - prop := map[string]any{ - "type": "boolean", - "title": "Allow all network access", - "description": consequence, - "default": config.Bool("allow_all_network"), - "x-source": sourceLabel(config["allow_all_network"].Source), - } - if config.String("backend") == "qemu" { - prop["description"] = "Enclave's QEMU backend always allows all network access. " + consequence - prop["default"] = true - prop["readOnly"] = true - prop["x-source"] = sourceLabel(config["backend"].Source) + return map[string]any{ + "type": "boolean", + "title": "Allow all network access", + "description": "The container can reach any host. Enclave also stops shielding your agent tokens, " + + "so the agent sees the real ones.", + "default": config.Bool("allow_all_network"), + "x-source": sourceLabel(config["allow_all_network"].Source), } - return prop } // retiredSettings are settings the group no longer offers. They are accepted on diff --git a/daemon/internal/provider/enclave/sandboxschema/schema_test.go b/daemon/internal/provider/enclave/sandboxschema/schema_test.go index b6ea2f5..13cfa07 100644 --- a/daemon/internal/provider/enclave/sandboxschema/schema_test.go +++ b/daemon/internal/provider/enclave/sandboxschema/schema_test.go @@ -206,22 +206,15 @@ func TestSchemaWithoutFeatures(t *testing.T) { func TestSchemaAllowAllNetwork(t *testing.T) { tests := []struct { - name string - config map[string]ConfigOption - wantDefault bool - wantSource string - wantReadOnly bool + name string + config map[string]ConfigOption + wantDefault bool + wantSource string }{ {name: "restricted by default", wantDefault: false, wantSource: "Enclave defaults"}, {name: "allowed by Enclave's project config", config: map[string]ConfigOption{"allow_all_network": option(`true`, "project")}, wantDefault: true, wantSource: "Enclave project config"}, - {name: "forced by the QEMU backend", - config: map[string]ConfigOption{ - "allow_all_network": option(`true`, "default"), - "backend": option(`"qemu"`, "global"), - }, - wantDefault: true, wantSource: "Enclave global config", wantReadOnly: true}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -238,16 +231,10 @@ func TestSchemaAllowAllNetwork(t *testing.T) { t.Errorf("allowAllNetwork default = %v from %v; want %v from %v", field["default"], field["x-source"], tt.wantDefault, tt.wantSource) } - if readOnly, _ := field["readOnly"].(bool); readOnly != tt.wantReadOnly { - t.Errorf("allowAllNetwork readOnly = %v; want %v", readOnly, tt.wantReadOnly) - } description, _ := field["description"].(string) if !strings.Contains(description, "real ones") { t.Errorf("allowAllNetwork description = %q; want it to warn that the agent sees real tokens", description) } - if tt.wantReadOnly && !strings.Contains(description, "QEMU") { - t.Errorf("allowAllNetwork description = %q; want it to say the QEMU backend forces it", description) - } if got := props["allowDomains"]["x-disabled-when"]; !equalJSON(got, map[string]any{"allowAllNetwork": true}) { t.Errorf("allowDomains x-disabled-when = %v; want it disabled while all network is allowed", got) } diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 944abc0..f51e45b 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -441,7 +441,8 @@ the agent's PTY and serves screen snapshots on a unix socket; the wire format is (`provider/enclave/restart.go` `completeReplacements`). Cancelled, as by a shutdown, the restart stops the new container, so the session is left to end and be continued. - **Outdated settings.** Every 30 s (`provider/enclave/drift.go`) the provider compares each - session's options with what Enclave's config now resolves. + session's options with what Enclave's config now resolves. `allow_domains` is skipped while both + allow all network: unrestricted mode has no allowlist for it to change. - **Sandbox settings** come from Enclave's config and features, cached briefly (`provider/enclave/sandbox.go`); HomeShell passes them through. - **CLI sessions.** The same check adopts sessions started with the `enclave` CLI diff --git a/docs/PROVIDERS.md b/docs/PROVIDERS.md index 0b0ee65..dc06adc 100644 --- a/docs/PROVIDERS.md +++ b/docs/PROVIDERS.md @@ -246,10 +246,10 @@ container is Enclave's to manage. refused (`409`) and stops nothing; the next inventory check adopts the new session. - **Allow all network access** in the Container settings passes `--allow-all-network`, or `--allow-all-network=false` to restrict a session whose Enclave config allows all network. It - defaults to the config's `allow_all_network`; with the QEMU backend it is locked on, as Enclave - forces it there. While it is on, Extra allowed domains is greyed out and not passed. Enclave's - network policy mode (`enclave network set-mode`) is not in `enclave config --json`, so a session - under an `unrestricted` mode runs unrestricted whatever the checkbox says. + defaults to the config's `allow_all_network`. While it is on, Extra allowed domains is greyed out + and not passed. HomeShell does not yet ask `enclave network print --json` for the network policy + mode (`enclave network set-mode`), so a session under an `unrestricted` mode runs unrestricted + whatever the checkbox says; the flag cannot override that mode. - **CLI session settings:** a CLI session has no recorded launch config (a session HomeShell started that is started again in a terminal under its name drops its own), so its restart or Continue starts with the options Enclave recorded for the container, as far as the create form models diff --git a/webapp/apps/web-e2e/src/ui/session-settings.spec.ts b/webapp/apps/web-e2e/src/ui/session-settings.spec.ts index fa4e8b5..cf81941 100644 --- a/webapp/apps/web-e2e/src/ui/session-settings.spec.ts +++ b/webapp/apps/web-e2e/src/ui/session-settings.spec.ts @@ -213,6 +213,12 @@ test('allowing all network greys out the extra domains and keeps them', async ({ await expect(domains).toHaveAttribute('aria-disabled', 'true'); expect(Number(await boxOpacity())).toBeLessThan(1); await expect(form.getByText('api.example.com')).toBeVisible(); + // The box's dimming is the only one, so the chip's × stays legible. + const chipRemove = form.getByRole('button', { + name: 'Delete api.example.com', + }); + await expect(chipRemove).toHaveAttribute('aria-disabled', 'true'); + expect(await styleOf(chipRemove, 'opacity')).toBe('1'); await expect(form.getByTestId('group-summary')).toHaveText( 'Allow all network access · Extra allowed domains +1', ); diff --git a/webapp/packages/components/src/lib/schema-fields.module.css b/webapp/packages/components/src/lib/schema-fields.module.css index 0443bc4..8b56d40 100644 --- a/webapp/packages/components/src/lib/schema-fields.module.css +++ b/webapp/packages/components/src/lib/schema-fields.module.css @@ -266,6 +266,11 @@ cursor: not-allowed; } +/* The box's dimming is the only one: a chip × would otherwise fade twice. */ +.chipBox:has(> input[aria-disabled='true']) .chipRemove { + opacity: 1; +} + .chipBox:focus-within { outline: 1px solid var(--hs-accent, #2dd4bf); outline-offset: -1px;