File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
crates/chat-cli/src/cli/chat/cli Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -76,7 +76,23 @@ impl PersistSubcommand {
76
76
) ?;
77
77
} ,
78
78
Self :: Load { path } => {
79
- let contents = tri ! ( os. fs. read_to_string( & path) . await , "import from" , & path) ;
79
+ // Try the original path first
80
+ let original_result = ctx. fs . read_to_string ( & path) . await ;
81
+
82
+ // If the original path fails and doesn't end with .json, try with .json appended
83
+ let contents = if original_result. is_err ( ) && !path. ends_with ( ".json" ) {
84
+ let json_path = format ! ( "{}.json" , path) ;
85
+ match ctx. fs . read_to_string ( & json_path) . await {
86
+ Ok ( content) => content,
87
+ Err ( _) => {
88
+ // If both paths fail, return the original error for better user experience
89
+ tri ! ( original_result, "import from" , & path)
90
+ } ,
91
+ }
92
+ } else {
93
+ tri ! ( original_result, "import from" , & path)
94
+ } ;
95
+
80
96
let mut new_state: ConversationState = tri ! ( serde_json:: from_str( & contents) , "import from" , & path) ;
81
97
new_state. reload_serialized_state ( os) . await ;
82
98
session. conversation = new_state;
You can’t perform that action at this time.
0 commit comments