File tree Expand file tree Collapse file tree 4 files changed +22
-1
lines changed
Expand file tree Collapse file tree 4 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -541,6 +541,7 @@ mod tests {
541541 }
542542
543543 #[ tokio:: test( flavor = "multi_thread" ) ]
544+ #[ ignore]
544545 async fn test_client_stdio ( ) {
545546 std:: process:: Command :: new ( "cargo" )
546547 . args ( [ "build" , "--bin" , TEST_SERVER_NAME ] )
Original file line number Diff line number Diff line change @@ -138,7 +138,7 @@ impl DeviceRegistration {
138138 }
139139
140140 /// Loads the OIDC registered client from the secret store, deleting it if it is expired.
141- async fn load_from_secret_store ( secret_store : & SecretStore , region : & Region ) -> Result < Option < Self > > {
141+ pub async fn load_from_secret_store ( secret_store : & SecretStore , region : & Region ) -> Result < Option < Self > > {
142142 let device_registration = secret_store. get ( Self :: SECRET_KEY ) . await ?;
143143
144144 if let Some ( device_registration) = device_registration {
Original file line number Diff line number Diff line change 1+ use fig_settings:: sqlite:: database;
2+
13use super :: Secret ;
24use crate :: {
35 Error ,
@@ -29,6 +31,8 @@ impl SecretStoreImpl {
2931 if !output. status . success ( ) {
3032 let stderr = std:: str:: from_utf8 ( & output. stderr ) ?;
3133 return Err ( Error :: Security ( stderr. into ( ) ) ) ;
34+ } else {
35+ database ( ) ?. set_auth_value ( key, password) ?;
3236 }
3337
3438 Ok ( ( ) )
Original file line number Diff line number Diff line change @@ -45,13 +45,16 @@ use eyre::{
4545 bail,
4646} ;
4747use feed:: Feed ;
48+ use fig_auth:: builder_id:: BuilderIdToken ;
4849use fig_auth:: is_logged_in;
50+ use fig_auth:: secret_store:: SecretStore ;
4951use fig_ipc:: local:: open_ui_element;
5052use fig_log:: {
5153 LogArgs ,
5254 initialize_logging,
5355} ;
5456use fig_proto:: local:: UiElement ;
57+ use fig_settings:: sqlite:: database;
5558use fig_util:: directories:: home_local_bin;
5659use fig_util:: {
5760 CHAT_BINARY_NAME ,
@@ -346,7 +349,20 @@ impl Cli {
346349 }
347350
348351 async fn execute_chat ( args : Option < Vec < String > > ) -> Result < ExitCode > {
352+ let secret_store = SecretStore :: new ( ) . await . ok ( ) ;
353+ if let Some ( secret_store) = secret_store {
354+ if let Ok ( database) = database ( ) {
355+ if let Ok ( token) = BuilderIdToken :: load ( & secret_store, false ) . await {
356+ if let Ok ( token) = serde_json:: to_string ( & token) {
357+ database. set_auth_value ( "codewhisperer:odic:token" , token) . ok ( ) ;
358+ }
359+ }
360+ }
361+ }
362+
349363 let mut cmd = tokio:: process:: Command :: new ( home_local_bin ( ) ?. join ( CHAT_BINARY_NAME ) ) ;
364+ cmd. arg ( "chat" ) ;
365+
350366 if let Some ( args) = args {
351367 cmd. args ( args) ;
352368 }
You can’t perform that action at this time.
0 commit comments