Add appearance metadata to thread sections (#37898)

## What changed

- Add optional `icon` and `color` appearance fields to custom thread sections and expose them through the app-server protocol.
- Persist appearance metadata in SQLite and include it when listing sections or returning threads.
- Let `threadSection/update` preserve an omitted appearance, clear it with `null`, or replace it with a new value.
- Reject appearance fields larger than 64 bytes.

## Testing

- Cover protocol compatibility, persistence across restart, update and clear behavior, and field-length validation.

GitOrigin-RevId: 8f55ce4f42f8bd17aa5416848a85845f681953df
This commit is contained in:
joeytrasatti-openai authored and copyberry committed 2026-08-10 23:32:42 +00:00
1 parent 92912d6d84
commit 1549756b78
54 files changed
+939 -47

No files matched your search

@@ -686,6 +686,7 @@ mod tests {
metadata.section = Some(codex_state::ThreadSection {
id: codex_state::PINNED_THREAD_SECTION_ID.to_string(),
name: codex_state::PINNED_THREAD_SECTION_NAME.to_string(),
appearance: None,
});
metadata.section_position = Some(2_000_000);
metadata.section_entered_at = Some(recency_at);
@@ -26,6 +26,7 @@ pub(super) async fn list_thread_sections(
.map(|section| StoredThreadSection {
id: section.id,
name: section.name,
appearance: section.appearance,
})
.collect(),
next_cursor: page.next_cursor,
@@ -38,13 +39,14 @@ pub(super) async fn create_thread_section(
) -> ThreadStoreResult<StoredThreadSection> {
let state_db = state_db(store, "threadSection/create")?;
let section = state_db
.create_thread_section(&params.name)
.create_thread_section(&params.name, params.appearance)
.await
.map_err(|err| section_error("create", err))?;
Ok(StoredThreadSection {
id: section.id,
name: section.name,
appearance: section.appearance,
})
}
@@ -54,13 +56,14 @@ pub(super) async fn rename_thread_section(
) -> ThreadStoreResult<Option<StoredThreadSection>> {
let state_db = state_db(store, "threadSection/update")?;
let section = state_db
.rename_thread_section(&params.section_id, &params.name)
.rename_thread_section(&params.section_id, &params.name, params.appearance)
.await
.map_err(|err| section_error("update", err))?;
Ok(section.map(|section| StoredThreadSection {
id: section.id,
name: section.name,
appearance: section.appearance,
}))
}
@@ -19,6 +19,7 @@ async fn local_thread_sections_require_sqlite_and_preserve_section_identity() {
unsupported_store
.create_thread_section(CreateThreadSectionParams {
name: "Research".to_string(),
appearance: None,
})
.await,
Err(ThreadStoreError::Unsupported {
@@ -35,9 +36,14 @@ async fn local_thread_sections_require_sqlite_and_preserve_section_identity() {
let store = LocalThreadStore::new(config, Some(runtime));
assert!(store.supports_thread_sections());
let appearance = codex_state::ThreadSectionAppearance {
icon: Some("folder".to_string()),
color: Some("purple".to_string()),
};
let section = store
.create_thread_section(CreateThreadSectionParams {
name: "Research".to_string(),
appearance: Some(appearance.clone()),
})
.await
.expect("create section");
@@ -54,6 +60,7 @@ async fn local_thread_sections_require_sqlite_and_preserve_section_identity() {
.rename_thread_section(RenameThreadSectionParams {
section_id: section.id.clone(),
name: "Planning".to_string(),
appearance: None,
})
.await
.expect("rename section");
@@ -62,6 +69,7 @@ async fn local_thread_sections_require_sqlite_and_preserve_section_identity() {
Some(StoredThreadSection {
id: section.id.clone(),
name: "Planning".to_string(),
appearance: Some(appearance),
})
);
@@ -168,6 +168,7 @@ mod tests {
metadata.section = Some(codex_state::ThreadSection {
id: codex_state::PINNED_THREAD_SECTION_ID.to_string(),
name: codex_state::PINNED_THREAD_SECTION_NAME.to_string(),
appearance: None,
});
runtime
.upsert_thread(&metadata)
@@ -897,6 +897,7 @@ mod tests {
Some(codex_state::ThreadSection {
id: codex_state::PINNED_THREAD_SECTION_ID.to_string(),
name: codex_state::PINNED_THREAD_SECTION_NAME.to_string(),
appearance: None,
})
);
let pinned_metadata = runtime
@@ -909,6 +910,7 @@ mod tests {
Some(codex_state::ThreadSection {
id: codex_state::PINNED_THREAD_SECTION_ID.to_string(),
name: codex_state::PINNED_THREAD_SECTION_NAME.to_string(),
appearance: None,
})
);
assert_eq!(pinned_metadata.preview.as_deref(), Some("Hello from user"));
@@ -951,6 +953,7 @@ mod tests {
Some(codex_state::ThreadSection {
id: codex_state::PINNED_THREAD_SECTION_ID.to_string(),
name: codex_state::PINNED_THREAD_SECTION_NAME.to_string(),
appearance: None,
})
);
assert_eq!(