@@ -31,7 +31,6 @@ const tokenSharingScope = "chatgpt.tokens.use.direct" |
31 | 31 | const providerID = Provider.ID.openai |
32 | 32 | const integrationID = Integration.ID.make("openai") |
33 | 33 | const methodID = Integration.MethodID.make("chatgpt-token-sharing") |
34 | | -const newAccountMethodID = Integration.MethodID.make("chatgpt-token-sharing-new") |
35 | 34 | // Each issued client belongs to one ChatGPT account and workspace. Profiles outlive logout so signing in again reuses |
36 | 35 | // the client instead of registering another app in the user's ChatGPT settings. |
37 | 36 | const profilesKey = "chatgpt-profiles" |
@@ -116,18 +115,13 @@ const decodeMetadata = Schema.decodeUnknownOption( |
116 | 115 | }), |
117 | 116 | ) |
118 | 117 |
|
119 | | -const signIn = ( |
120 | | - app: App.Info, |
121 | | - savedClients: () => Effect.Effect<ReadonlyArray<string>>, |
122 | | - storage: Context["storage"], |
123 | | - newAccount = false, |
124 | | -) => |
| 118 | +const signIn = (app: App.Info, savedClients: () => Effect.Effect<ReadonlyArray<string>>, storage: Context["storage"]) => |
125 | 119 | ({ |
126 | 120 | integrationID, |
127 | 121 | method: { |
128 | | - id: newAccount ? newAccountMethodID : methodID, |
| 122 | + id: methodID, |
129 | 123 | type: "oauth", |
130 | | - label: newAccount ? "Use a different ChatGPT account" : "Sign in with ChatGPT", |
| 124 | + label: "Sign in with ChatGPT", |
131 | 125 | }, |
132 | 126 | authorize: () => |
133 | 127 | Effect.gen(function* () { |
@@ -142,7 +136,7 @@ const signIn = ( |
142 | 136 | const expired = yield* expiredClients(storage) |
143 | 137 | // A working saved account means this sign-in adds another one, which needs its own client. |
144 | 138 | const adding = (yield* savedClients()).some((id) => !expired.includes(id)) |
145 | | - const savedID = newAccount || adding || typeof last !== "string" ? undefined : last |
| 139 | + const savedID = adding || typeof last !== "string" ? undefined : last |
146 | 140 | const profile = savedID ? profiles?.[savedID] : undefined |
147 | 141 | // `response` is the browser's pending callback request; a pasted redirect has none. |
148 | 142 | const received = yield* Deferred.make<{ code: string; clientID?: string; response?: ServerResponse }, Error>() |
@@ -222,7 +216,7 @@ const signIn = ( |
222 | 216 | if (profile && identity.subject !== profile.subject) |
223 | 217 | return yield* Effect.fail( |
224 | 218 | new Error( |
225 | | - "ChatGPT signed in with a different account than this connection. Choose “Use a different ChatGPT account” instead.", |
| 219 | + "ChatGPT signed in with a different account than the one you last used. To add another account, connect your last account first, then choose Add account.", |
226 | 220 | ), |
227 | 221 | ) |
228 | 222 | const saved = Option.getOrUndefined(decodeProfiles(yield* storage.get(profilesKey))) |
@@ -281,8 +275,6 @@ export const ChatGPTPlugin = define({ |
281 | 275 | const credentials = yield* Credential.Service |
282 | 276 | const loading = Semaphore.makeUnsafe(1) |
283 | 277 | let chatgpt: Credential.OAuth | undefined |
284 | | - // Offer a separate new-account sign-in once there is an account to switch away from. |
285 | | - let known = false |
286 | 278 | // let available: ReadonlyArray<RemoteModel> | undefined |
287 | 279 | let source: Effect.Success<ReturnType<typeof ctx.integration.connection.active>> |
288 | 280 |
|
@@ -296,9 +288,6 @@ export const ChatGPTPlugin = define({ |
296 | 288 | const clientID = Option.getOrUndefined(decodeMetadata(chatgpt?.metadata))?.clientID |
297 | 289 | if (clientID && (yield* ctx.storage.get(lastClientKey)) === undefined) |
298 | 290 | yield* ctx.storage.set(lastClientKey, clientID) |
299 | | - const wasKnown = known |
300 | | - known = chatgpt !== undefined || typeof (yield* ctx.storage.get(lastClientKey)) === "string" |
301 | | - if (known !== wasKnown) yield* ctx.integration.reload() |
302 | 291 | // if (previous !== IntegrationConnection.key(source)) { |
303 | 292 | // const metadata = Option.getOrUndefined(decodeMetadata(chatgpt?.metadata)) |
304 | 293 | // const stored = metadata ? yield* ctx.storage.get(modelCacheKey(metadata.clientID)) : undefined |
@@ -319,7 +308,6 @@ export const ChatGPTPlugin = define({ |
319 | 308 | ) |
320 | 309 | yield* ctx.integration.transform((editor) => { |
321 | 310 | editor.method.update(signIn(ctx.app, savedClients, ctx.storage)) |
322 | | - if (known) editor.method.update(signIn(ctx.app, savedClients, ctx.storage, true)) |
323 | 311 | }) |
324 | 312 | yield* Effect.forEach( |
325 | 313 | yield* credentials.list(Integration.ID.make("openai")), |
|