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 {
541
541
}
542
542
543
543
#[ tokio:: test( flavor = "multi_thread" ) ]
544
+ #[ ignore]
544
545
async fn test_client_stdio ( ) {
545
546
std:: process:: Command :: new ( "cargo" )
546
547
. args ( [ "build" , "--bin" , TEST_SERVER_NAME ] )
Original file line number Diff line number Diff line change @@ -138,7 +138,7 @@ impl DeviceRegistration {
138
138
}
139
139
140
140
/// 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 > > {
142
142
let device_registration = secret_store. get ( Self :: SECRET_KEY ) . await ?;
143
143
144
144
if let Some ( device_registration) = device_registration {
Original file line number Diff line number Diff line change
1
+ use fig_settings:: sqlite:: database;
2
+
1
3
use super :: Secret ;
2
4
use crate :: {
3
5
Error ,
@@ -29,6 +31,8 @@ impl SecretStoreImpl {
29
31
if !output. status . success ( ) {
30
32
let stderr = std:: str:: from_utf8 ( & output. stderr ) ?;
31
33
return Err ( Error :: Security ( stderr. into ( ) ) ) ;
34
+ } else {
35
+ database ( ) ?. set_auth_value ( key, password) ?;
32
36
}
33
37
34
38
Ok ( ( ) )
Original file line number Diff line number Diff line change @@ -45,13 +45,16 @@ use eyre::{
45
45
bail,
46
46
} ;
47
47
use feed:: Feed ;
48
+ use fig_auth:: builder_id:: BuilderIdToken ;
48
49
use fig_auth:: is_logged_in;
50
+ use fig_auth:: secret_store:: SecretStore ;
49
51
use fig_ipc:: local:: open_ui_element;
50
52
use fig_log:: {
51
53
LogArgs ,
52
54
initialize_logging,
53
55
} ;
54
56
use fig_proto:: local:: UiElement ;
57
+ use fig_settings:: sqlite:: database;
55
58
use fig_util:: directories:: home_local_bin;
56
59
use fig_util:: {
57
60
CHAT_BINARY_NAME ,
@@ -346,7 +349,20 @@ impl Cli {
346
349
}
347
350
348
351
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
+
349
363
let mut cmd = tokio:: process:: Command :: new ( home_local_bin ( ) ?. join ( CHAT_BINARY_NAME ) ) ;
364
+ cmd. arg ( "chat" ) ;
365
+
350
366
if let Some ( args) = args {
351
367
cmd. args ( args) ;
352
368
}
You can’t perform that action at this time.
0 commit comments