(ctx context.Context, name string)
| 143 | } |
| 144 | |
| 145 | func (cli *ChatCLI) handleLoadSession(ctx context.Context, name string) { |
| 146 | if cli.isRemote { |
| 147 | rc := cli.getRemoteClient() |
| 148 | if rc == nil { |
| 149 | fmt.Println(i18n.T("session.error_load", fmt.Errorf("remote client unavailable"))) |
| 150 | return |
| 151 | } |
| 152 | |
| 153 | // Check both sources |
| 154 | localSD, localErr := cli.sessionManager.LoadSessionV2(name) |
| 155 | ctx, cancel := remoteSessionCtx(ctx) |
| 156 | defer cancel() |
| 157 | remoteSD, remoteErr := rc.LoadSessionV2(ctx, name) |
| 158 | |
| 159 | foundLocal := localErr == nil |
| 160 | foundRemote := remoteErr == nil |
| 161 | |
| 162 | switch { |
| 163 | case foundLocal && foundRemote: |
| 164 | // Found in both — ask user |
| 165 | fmt.Println(i18n.T("session.load_found_both", name)) |
| 166 | choice := askSessionChoice( |
| 167 | []string{"session.option_local", "session.option_remote"}, |
| 168 | map[string]string{"l": "local", "r": "remote"}, |
| 169 | "local", |
| 170 | ) |
| 171 | if choice == "remote" { |
| 172 | cli.restoreSessionData(remoteSD) |
| 173 | cli.currentSessionName = name |
| 174 | fmt.Println(i18n.T("session.load_success_remote", name)) |
| 175 | } else { |
| 176 | cli.restoreSessionData(localSD) |
| 177 | cli.currentSessionName = name |
| 178 | fmt.Println(i18n.T("session.load_success", name)) |
| 179 | } |
| 180 | case foundLocal: |
| 181 | cli.restoreSessionData(localSD) |
| 182 | cli.currentSessionName = name |
| 183 | fmt.Println(i18n.T("session.load_success", name)) |
| 184 | case foundRemote: |
| 185 | cli.restoreSessionData(remoteSD) |
| 186 | cli.currentSessionName = name |
| 187 | fmt.Println(i18n.T("session.load_success_remote", name)) |
| 188 | default: |
| 189 | fmt.Println(i18n.T("session.error_load", localErr)) |
| 190 | } |
| 191 | return |
| 192 | } |
| 193 | |
| 194 | // Local only |
| 195 | sd, err := cli.sessionManager.LoadSessionV2(name) |
| 196 | if err != nil { |
| 197 | fmt.Println(i18n.T("session.error_load", err)) |
| 198 | } else { |
| 199 | cli.restoreSessionData(sd) |
| 200 | cli.currentSessionName = name |
| 201 | fmt.Println(i18n.T("session.load_success", name)) |
| 202 | } |
no test coverage detected