@@ -50,117 +50,3 @@ impl App {
5050 session
5151 }
5252}
53- #[ cfg( test) ]
54- mod tests {
55- use super :: * ;
56- use crate :: app:: side:: SideThreadState ;
57- use crate :: app:: test_support:: make_test_app;
58- use crate :: app:: thread_events:: ThreadEventChannel ;
59- use crate :: test_support:: PathBufExt ;
60- use crate :: test_support:: test_path_buf;
61- use codex_config:: types:: ApprovalsReviewer ;
62- use codex_protocol:: protocol:: AskForApproval ;
63- use codex_protocol:: protocol:: SandboxPolicy ;
64- use pretty_assertions:: assert_eq;
65- use std:: path:: PathBuf ;
66-
67- fn test_thread_session ( thread_id : ThreadId , cwd : PathBuf ) -> ThreadSessionState {
68- ThreadSessionState {
69- thread_id,
70- forked_from_id : None ,
71- fork_parent_title : None ,
72- thread_name : None ,
73- model : "gpt-test" . to_string ( ) ,
74- model_provider_id : "test-provider" . to_string ( ) ,
75- service_tier : None ,
76- approval_policy : AskForApproval :: Never ,
77- approvals_reviewer : ApprovalsReviewer :: User ,
78- sandbox_policy : SandboxPolicy :: new_read_only_policy ( ) ,
79- cwd : cwd. abs ( ) ,
80- instruction_source_paths : Vec :: new ( ) ,
81- reasoning_effort : None ,
82- history_log_id : 0 ,
83- history_entry_count : 0 ,
84- network_proxy : None ,
85- rollout_path : Some ( PathBuf :: new ( ) ) ,
86- }
87- }
88-
89- #[ tokio:: test]
90- async fn permission_settings_sync_updates_active_snapshot_without_rewriting_side_thread ( ) {
91- let mut app = make_test_app ( ) . await ;
92- let main_thread_id =
93- ThreadId :: from_string ( "00000000-0000-0000-0000-000000000401" ) . expect ( "valid thread" ) ;
94- let side_thread_id =
95- ThreadId :: from_string ( "00000000-0000-0000-0000-000000000402" ) . expect ( "valid thread" ) ;
96- let main_session = test_thread_session ( main_thread_id, test_path_buf ( "/tmp/main" ) ) ;
97- let side_session = ThreadSessionState {
98- approval_policy : AskForApproval :: OnRequest ,
99- sandbox_policy : SandboxPolicy :: new_workspace_write_policy ( ) ,
100- ..test_thread_session ( side_thread_id, test_path_buf ( "/tmp/side" ) )
101- } ;
102-
103- app. primary_thread_id = Some ( main_thread_id) ;
104- app. active_thread_id = Some ( main_thread_id) ;
105- app. primary_session_configured = Some ( main_session. clone ( ) ) ;
106- app. thread_event_channels . insert (
107- main_thread_id,
108- ThreadEventChannel :: new_with_session (
109- /*capacity*/ 4 ,
110- main_session. clone ( ) ,
111- Vec :: new ( ) ,
112- ) ,
113- ) ;
114- app. thread_event_channels . insert (
115- side_thread_id,
116- ThreadEventChannel :: new_with_session (
117- /*capacity*/ 4 ,
118- side_session. clone ( ) ,
119- Vec :: new ( ) ,
120- ) ,
121- ) ;
122- app. side_threads
123- . insert ( side_thread_id, SideThreadState :: new ( main_thread_id) ) ;
124- app. config . permissions . approval_policy =
125- codex_config:: Constrained :: allow_any ( AskForApproval :: OnRequest ) ;
126- app. config . approvals_reviewer = ApprovalsReviewer :: GuardianSubagent ;
127- app. config . permissions . sandbox_policy =
128- codex_config:: Constrained :: allow_any ( SandboxPolicy :: new_workspace_write_policy ( ) ) ;
129-
130- app. sync_active_thread_permission_settings_to_cached_session ( )
131- . await ;
132-
133- let expected_main_session = ThreadSessionState {
134- approval_policy : AskForApproval :: OnRequest ,
135- approvals_reviewer : ApprovalsReviewer :: GuardianSubagent ,
136- sandbox_policy : SandboxPolicy :: new_workspace_write_policy ( ) ,
137- ..main_session
138- } ;
139- assert_eq ! (
140- app. primary_session_configured,
141- Some ( expected_main_session. clone( ) )
142- ) ;
143-
144- let main_store_session = app
145- . thread_event_channels
146- . get ( & main_thread_id)
147- . expect ( "main thread channel" )
148- . store
149- . lock ( )
150- . await
151- . session
152- . clone ( ) ;
153- assert_eq ! ( main_store_session, Some ( expected_main_session) ) ;
154-
155- let side_store_session = app
156- . thread_event_channels
157- . get ( & side_thread_id)
158- . expect ( "side thread channel" )
159- . store
160- . lock ( )
161- . await
162- . session
163- . clone ( ) ;
164- assert_eq ! ( side_store_session, Some ( side_session) ) ;
165- }
166- }
0 commit comments