Support catalog headings for saved command-prefix notices (#57599)

## What changed

- Add `permissions.approved_command_prefix_saved` to model messages and use valid plain-text headings in saved-prefix notices, with or without full permissions instructions. Reject empty, oversized, control-character, and markup-like headings.
- Keep `Approved command prefix saved:` as the leading marker for older clients and recognize saved-prefix content kinds when trimming rolled-back context.
- Shut down analytics test exporters asynchronously and serialize workspace-switching tests that share authentication environment state.

## Testing

Extend coverage for heading validation, sparse wire values, single-notice emission, rollback with and without metadata, and saved-prefix behavior across model switches.

GitOrigin-RevId: a70175deca64a6339abac2fa69af970f470e3f4f
This commit is contained in:
goodman-oai
2026-10-27 23:53:34 +00:00
committed by copyberry
parent 28cade4f5a
commit e8e6a922c0
18 changed files with 289 additions and 107 deletions
+10 -1
View File
@@ -834,6 +834,10 @@ pub struct PermissionMessages {
/// an empty string suppresses the approved-prefix section.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub approved_prefixes: Option<String>,
/// Optional plain heading for the separate saved-command-prefix notification.
/// The harness formats the prefix list and falls back to its bundled heading for invalid text.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub approved_command_prefix_saved: Option<String>,
/// Single writable-root sentence with exactly one `{{ roots }}` placeholder.
/// Missing, null, empty, invalid, or oversized templates use the bundled sentence.
#[serde(default, skip_serializing_if = "Option::is_none")]
@@ -1456,9 +1460,12 @@ mod tests {
}
#[test]
fn permission_path_messages_preserve_sparse_wire_values() {
fn permission_messages_preserve_sparse_wire_values() {
for input in [
serde_json::json!({}),
serde_json::json!({"approved_command_prefix_saved": null}),
serde_json::json!({"approved_command_prefix_saved": ""}),
serde_json::json!({"approved_command_prefix_saved": "Saved", "approved_prefixes": "Allowed: {{ approved_prefixes }}"}),
serde_json::json!({"writable_root": null, "writable_roots": null}),
serde_json::json!({"writable_root": "", "writable_roots": "Roots: {{ roots }}."}),
serde_json::json!({"omitted_paths": null, "denied_reads": null}),
@@ -1471,6 +1478,8 @@ mod tests {
"read_only": null,
});
for key in [
"approved_command_prefix_saved",
"approved_prefixes",
"writable_root",
"writable_roots",
"omitted_paths",