mirror of
https://github.com/openai/codex.git
synced 2026-11-20 07:06:24 +00:00
Persist Daybreak preferences in thread metadata (#42854)
## Why Clients need a per-thread Daybreak toggle that survives restarts and can be restored on resume without changing the access program of an active or future turn. ## What changed - Add experimental `daybreakEnabled` support to `thread/metadata/update` and expose the saved value on thread responses. - Store the preference in SQLite, including for threads without a first turn, and preserve it through reads, resumes, reconciliation, and restarts. - Copy the preference when forking a thread while keeping subsequent updates independent. - Keep `daybreakEnabled` separate from the per-turn `cyberAccessProgram` field; app-server does not derive one from the other. ## Testing - Cover persistence across restarts, cold reads, reconciliation, and forks. - Verify metadata updates do not alter the access program of active or later turns. GitOrigin-RevId: bcf987a9fcd7b0ac8a88b1c8f0df06b33ed8ad6e
This commit is contained in:
1 parent
4636819a35
commit
3921a30d6b
47 files changed
+555
-52
No files matched your search
@@ -64,6 +64,8 @@ pub struct ThreadItem {
|
||||
pub section: Option<codex_state::ThreadSection>,
|
||||
/// Canonical project assignment in SQLite-owned metadata.
|
||||
pub project_id: Option<String>,
|
||||
/// Saved Daybreak choice in SQLite-owned metadata, when available.
|
||||
pub daybreak_enabled: Option<bool>,
|
||||
/// Working directory from session metadata.
|
||||
pub cwd: Option<PathBuf>,
|
||||
/// Git branch from session metadata.
|
||||
@@ -848,6 +850,7 @@ async fn build_thread_item(
|
||||
preview,
|
||||
section: None,
|
||||
project_id: None,
|
||||
daybreak_enabled: None,
|
||||
cwd,
|
||||
git_branch,
|
||||
git_sha,
|
||||
|
||||
@@ -1289,6 +1289,7 @@ fn fill_missing_thread_item_metadata(item: &mut ThreadItem, state_item: ThreadIt
|
||||
preview,
|
||||
section,
|
||||
project_id,
|
||||
daybreak_enabled,
|
||||
cwd,
|
||||
git_branch,
|
||||
git_sha,
|
||||
@@ -1319,6 +1320,7 @@ fn fill_missing_thread_item_metadata(item: &mut ThreadItem, state_item: ThreadIt
|
||||
}
|
||||
item.section = section;
|
||||
item.project_id = project_id;
|
||||
item.daybreak_enabled = daybreak_enabled;
|
||||
item.model = model;
|
||||
item.reasoning_effort = reasoning_effort;
|
||||
if item.cwd.is_none() {
|
||||
@@ -2036,6 +2038,7 @@ fn thread_item_from_state_metadata(
|
||||
preview: item.preview,
|
||||
section: item.section,
|
||||
project_id: item.project_id,
|
||||
daybreak_enabled: item.daybreak_enabled,
|
||||
cwd: Some(item.cwd),
|
||||
git_branch: item.git_branch,
|
||||
git_sha: item.git_sha,
|
||||
|
||||
@@ -1600,6 +1600,7 @@ fn fill_missing_thread_item_metadata_preserves_identity_and_prefers_state_git_fi
|
||||
first_user_message: Some("filesystem message".to_string()),
|
||||
preview: Some("filesystem preview".to_string()),
|
||||
project_id: None,
|
||||
daybreak_enabled: None,
|
||||
section: None,
|
||||
cwd: None,
|
||||
git_branch: Some("filesystem-branch".to_string()),
|
||||
@@ -1628,6 +1629,7 @@ fn fill_missing_thread_item_metadata_preserves_identity_and_prefers_state_git_fi
|
||||
first_user_message: Some("state message".to_string()),
|
||||
preview: Some("state preview".to_string()),
|
||||
project_id: None,
|
||||
daybreak_enabled: Some(true),
|
||||
section: Some(codex_state::ThreadSection {
|
||||
id: codex_state::PINNED_THREAD_SECTION_ID.to_string(),
|
||||
name: codex_state::PINNED_THREAD_SECTION_NAME.to_string(),
|
||||
@@ -1658,6 +1660,7 @@ fn fill_missing_thread_item_metadata_preserves_identity_and_prefers_state_git_fi
|
||||
|
||||
assert_eq!(item.path, filesystem_path);
|
||||
assert_eq!(item.thread_id, Some(filesystem_thread_id));
|
||||
assert_eq!(item.daybreak_enabled, Some(true));
|
||||
assert_eq!(
|
||||
item.section,
|
||||
Some(codex_state::ThreadSection {
|
||||
|
||||
@@ -725,6 +725,7 @@ async fn test_list_conversations_latest_first() {
|
||||
first_user_message: Some("Hello from user".to_string()),
|
||||
preview: Some("Hello from user".to_string()),
|
||||
project_id: None,
|
||||
daybreak_enabled: None,
|
||||
section: None,
|
||||
cwd: Some(Path::new(".").to_path_buf()),
|
||||
git_branch: None,
|
||||
@@ -750,6 +751,7 @@ async fn test_list_conversations_latest_first() {
|
||||
first_user_message: Some("Hello from user".to_string()),
|
||||
preview: Some("Hello from user".to_string()),
|
||||
project_id: None,
|
||||
daybreak_enabled: None,
|
||||
section: None,
|
||||
cwd: Some(Path::new(".").to_path_buf()),
|
||||
git_branch: None,
|
||||
@@ -775,6 +777,7 @@ async fn test_list_conversations_latest_first() {
|
||||
first_user_message: Some("Hello from user".to_string()),
|
||||
preview: Some("Hello from user".to_string()),
|
||||
project_id: None,
|
||||
daybreak_enabled: None,
|
||||
section: None,
|
||||
cwd: Some(Path::new(".").to_path_buf()),
|
||||
git_branch: None,
|
||||
@@ -893,6 +896,7 @@ async fn test_pagination_cursor() {
|
||||
first_user_message: Some("Hello from user".to_string()),
|
||||
preview: Some("Hello from user".to_string()),
|
||||
project_id: None,
|
||||
daybreak_enabled: None,
|
||||
section: None,
|
||||
cwd: Some(Path::new(".").to_path_buf()),
|
||||
git_branch: None,
|
||||
@@ -918,6 +922,7 @@ async fn test_pagination_cursor() {
|
||||
first_user_message: Some("Hello from user".to_string()),
|
||||
preview: Some("Hello from user".to_string()),
|
||||
project_id: None,
|
||||
daybreak_enabled: None,
|
||||
section: None,
|
||||
cwd: Some(Path::new(".").to_path_buf()),
|
||||
git_branch: None,
|
||||
@@ -979,6 +984,7 @@ async fn test_pagination_cursor() {
|
||||
first_user_message: Some("Hello from user".to_string()),
|
||||
preview: Some("Hello from user".to_string()),
|
||||
project_id: None,
|
||||
daybreak_enabled: None,
|
||||
section: None,
|
||||
cwd: Some(Path::new(".").to_path_buf()),
|
||||
git_branch: None,
|
||||
@@ -1004,6 +1010,7 @@ async fn test_pagination_cursor() {
|
||||
first_user_message: Some("Hello from user".to_string()),
|
||||
preview: Some("Hello from user".to_string()),
|
||||
project_id: None,
|
||||
daybreak_enabled: None,
|
||||
section: None,
|
||||
cwd: Some(Path::new(".").to_path_buf()),
|
||||
git_branch: None,
|
||||
@@ -1057,6 +1064,7 @@ async fn test_pagination_cursor() {
|
||||
first_user_message: Some("Hello from user".to_string()),
|
||||
preview: Some("Hello from user".to_string()),
|
||||
project_id: None,
|
||||
daybreak_enabled: None,
|
||||
section: None,
|
||||
cwd: Some(Path::new(".").to_path_buf()),
|
||||
git_branch: None,
|
||||
@@ -1235,6 +1243,7 @@ async fn test_get_thread_contents() {
|
||||
first_user_message: Some("Hello from user".to_string()),
|
||||
preview: Some("Hello from user".to_string()),
|
||||
project_id: None,
|
||||
daybreak_enabled: None,
|
||||
section: None,
|
||||
cwd: Some(Path::new(".").to_path_buf()),
|
||||
git_branch: None,
|
||||
@@ -1641,6 +1650,7 @@ async fn test_timestamp_only_cursor_skips_same_second_filesystem_ties() {
|
||||
first_user_message: Some("Hello from user".to_string()),
|
||||
preview: Some("Hello from user".to_string()),
|
||||
project_id: None,
|
||||
daybreak_enabled: None,
|
||||
section: None,
|
||||
cwd: Some(Path::new(".").to_path_buf()),
|
||||
git_branch: None,
|
||||
@@ -1666,6 +1676,7 @@ async fn test_timestamp_only_cursor_skips_same_second_filesystem_ties() {
|
||||
first_user_message: Some("Hello from user".to_string()),
|
||||
preview: Some("Hello from user".to_string()),
|
||||
project_id: None,
|
||||
daybreak_enabled: None,
|
||||
section: None,
|
||||
cwd: Some(Path::new(".").to_path_buf()),
|
||||
git_branch: None,
|
||||
|
||||
Reference in new issue
Block a user