You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: specs/ambient-ui/ambient-ui.spec.md
+83-5Lines changed: 83 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -830,25 +830,55 @@ Sessions with an `ambient-code.io/ui/preview-url` annotation SHALL offer a live
830
830
831
831
The preview iframe SHALL be hardened:
832
832
- The `sandbox` attribute SHALL be set with minimal permissions (`allow-scripts allow-same-origin allow-forms`). Top-level navigation (`allow-top-navigation`) and popups (`allow-popups`) SHALL NOT be granted.
833
-
- The UI SHALL validate the preview URL against a configurable allowlist of trusted host patterns (e.g., `*.apps.rosa.example.com`, `*.apps.cluster.local`). URLs not matching the allowlist SHALL be rejected with an error message instead of rendered.
834
-
- A Content-Security-Policy `frame-src` directive SHALL restrict the iframe to the allowlisted hosts.
833
+
- The UI and BFF preview proxy SHALL validate the preview URL against the active Project's `ProjectSettings.spec.preview.allowedHosts` policy. URLs not matching the Project allowlist SHALL be rejected with an error message instead of rendered.
834
+
- The iframe SHALL load a session-scoped BFF route, for example `/api/projects/{projectId}/sessions/{sessionId}/preview?url=...`. The BFF SHALL fetch the Session server-side, read `ambient-code.io/ui/preview-url`, and accept the requested URL only when it equals that annotation value or is a validated navigation/redirect derived from it. Arbitrary `url` parameters outside the Session preview context SHALL be rejected.
835
+
- For every proxied request, including redirects and injected-link navigations, the preview proxy SHALL revalidate the target URL against the effective preview policy. Token relay SHALL be recomputed per target host.
836
+
- The preview proxy SHALL forward the BFF's server-side SSO access token to the preview target only when the matching ProjectSettings host entry has `forwardAmbientToken: true` and the platform token-relay policy permits that host. Hosts with `forwardAmbientToken: false` SHALL render without Ambient token relay. Custom connection tokens entered through the status-bar connection controls SHALL NOT be forwarded to preview targets.
837
+
- A Content-Security-Policy `frame-src` directive SHALL restrict iframes to the same-origin preview proxy and any platform-configured direct-frame hosts. Project-specific preview host trust is enforced server-side by the proxy.
838
+
839
+
When ProjectSettings preview policy is available from the API/SDK, it is authoritative. During rollout before that API is available, preview trust MAY be read from deployment configuration as a read-only, deployment-scoped fallback. Fallback entries imply `forwardAmbientToken: false`. Once a Project has explicit ProjectSettings preview policy, even `allowedHosts: []`, the ProjectSettings policy overrides the deployment fallback for that Project.
835
840
836
841
#### Scenario: Preview mode activation
837
842
838
843
- GIVEN a session with `ambient-code.io/ui/preview-url: "https://app.example.com"` and `ambient-code.io/ui/preview-title: "SSO Login v2"`
839
-
- AND the URL matches the configured preview host allowlist
844
+
- AND the URL matches the active Project's preview host allowlist
840
845
- WHEN the user clicks "Open Preview" in the session detail
841
846
- THEN a near-fullscreen overlay opens with the URL loaded in a sandboxed iframe
842
847
- AND the overlay header shows the preview title, device size toggles (Desktop/Tablet/Mobile), and a Comment button
- GIVEN a session with `ambient-code.io/ui/preview-url: "https://pr-123.checkout.apps.rosa.example.com"`
868
+
- AND the active ProjectSettings allowlist contains `pattern: "pr-*.checkout.apps.rosa.example.com"` with `forwardAmbientToken: true`
869
+
- AND platform token-relay policy permits that host pattern
870
+
- WHEN the user opens the preview
871
+
- THEN the preview proxy forwards the BFF's server-side SSO access token to the preview target
872
+
- AND no custom status-bar connection token is forwarded
873
+
874
+
#### Scenario: Preview token relay denied by platform policy
875
+
876
+
- GIVEN a ProjectSettings allowlist entry with `forwardAmbientToken: true`
877
+
- AND the host pattern is outside the platform token-relay policy
878
+
- WHEN the UI or API attempts to save the ProjectSettings entry
879
+
- THEN the save is rejected
880
+
- AND the preview target is not treated as trusted for Ambient token relay
881
+
852
882
#### Scenario: Device size emulation
853
883
854
884
- GIVEN the preview overlay is open
@@ -966,7 +996,52 @@ No list-watch endpoint exists for sessions today. Polling is the interim mechani
966
996
967
997
The Settings view SHALL provide project-scoped configuration management with tabbed sections.
968
998
969
-
**Tabs:** General (project metadata), Permissions (user/role management), API Keys (key lifecycle), Feature Flags (toggles with confirmation).
999
+
**Tabs:** General (project metadata), Preview (trusted preview hosts), Permissions (user/role management), API Keys (key lifecycle), Feature Flags (toggles with confirmation).
1000
+
1001
+
### Requirement: Preview Trust Configuration
1002
+
1003
+
The Settings view SHALL expose the active Project's `ProjectSettings.spec.preview.allowedHosts` policy. The Preview tab SHALL list trusted host patterns, show whether each pattern forwards the BFF's server-side SSO access token, and allow authorized users to add, edit, or remove entries.
1004
+
1005
+
The UI SHALL persist Preview tab changes through the ProjectSettings API. The UI SHALL NOT write preview trust policy to Project labels or annotations.
1006
+
1007
+
If the ProjectSettings API/SDK support is not available in a deployed version, the Preview tab SHALL show the effective deployment-scoped fallback policy as read-only or hide editing controls entirely. Editing becomes available only when ProjectSettings writes are supported.
1008
+
1009
+
The UI SHALL render the same logical policy that can be applied by YAML:
- GIVEN Project `checkout` has `ProjectSettings.spec.preview.allowedHosts: []`
1042
+
- WHEN a Session in `checkout` has an `ambient-code.io/ui/preview-url` annotation
1043
+
- THEN opening the preview is rejected as untrusted
1044
+
- AND the UI explains that no trusted preview hosts are configured for the Project
970
1045
971
1046
#### Scenario: Feature flag toggle confirmation
972
1047
@@ -1117,6 +1192,7 @@ This section documents API endpoints and capabilities that this spec depends on
1117
1192
1118
1193
| Dependency | Required By | Status | Interim |
1119
1194
|------------|-------------|--------|---------|
1195
+
| `ProjectSettings.spec.preview.allowedHosts` API and SDK support | Live Preview, Settings > Preview | Specified in Ambient Data Model; implementation planned | Use deployment-level preview env allowlist as read-only fallback until ProjectSettings preview policy is available; fallback never enables Ambient token relay |
1120
1196
| Annotation enrichment endpoint (resolve `ambient-code.io/jira/issue` etc. against bound credentials) | Annotation enrichment, Issues view status filtering | Not yet specified | Render raw annotation values as clickable chips |
1121
1197
| `GET /credentials/{cred_id}/role_bindings` (scoped query) | Credential binding display | Planned, not implemented | Use generic `GET /role_bindings` filtered by `credential_id` |
1122
1198
| Cross-resource search endpoint | Global search | Not planned | Client-side aggregation across multiple list endpoints |
@@ -1133,6 +1209,8 @@ This section documents API endpoints and capabilities that this spec depends on
1133
1209
| Annotation registry is a code enum (not dynamic) | Simplicity. Adding a new annotation type is a PR, not a config change. The set of annotations the UI understands should be deliberate and reviewed. |
1134
1210
| Enrichment as graceful degradation | UI ships without enrichment API. Raw annotation values are useful on their own (clickable links). Enriched tooltips are additive. |
1135
1211
| Cost as annotation, not API field | Cost is agent-computed and written as `ambient-code.io/cost/estimate`. No API-level cost computation. |
1212
+
| Preview trust as ProjectSettings, not annotation metadata | Preview host trust is security-sensitive desired state. It belongs in the typed ProjectSettings Kind so it can be validated, authorized, edited via UI/API, and reconciled by `acpctl apply`. Session annotations only point to a preview URL; they do not grant trust. |
1213
+
| Preview rendering trust separated from Ambient token relay trust | Many preview hosts should be frameable without receiving Ambient bearer tokens. `forwardAmbientToken` is explicit per host entry and may be constrained by platform token-relay policy. |
1136
1214
| Tool metrics computed client-side | The API stores raw SessionMessages. Aggregating tool call stats is a UI concern, not an API concern. |
1137
1215
| SSE for sessions, polling for rest | Sessions have real-time SSE streams. Credentials, schedules, and agents change infrequently — polling is sufficient and simpler. |
1138
1216
| Single interaction pattern per entity | Agent rows: navigate to detail page. Session rows: navigate to detail page. Reduces cognitive load per Krug's "Don't Make Me Think." |
0 commit comments