(success: boolean, errorMessage?: string)
| 121 | } |
| 122 | |
| 123 | function callbackPageHtml(success: boolean, errorMessage?: string): string { |
| 124 | const title = success ? 'Connected — Codebuff' : 'Connection Failed — Codebuff' |
| 125 | const heading = success ? '✓ Connected to ChatGPT' : 'Connection Failed' |
| 126 | const headingColor = success ? '#4ade80' : '#f87171' |
| 127 | const body = success |
| 128 | ? 'You can close this tab and return to Codebuff.' |
| 129 | : `${escapeHtml(errorMessage ?? 'Unknown error')}. Return to Codebuff and try /connect:chatgpt again.` |
| 130 | return `<!DOCTYPE html> |
| 131 | <html><head><meta charset="utf-8"><title>${title}</title></head> |
| 132 | <body style="font-family:system-ui,sans-serif;display:flex;justify-content:center;align-items:center;min-height:100vh;margin:0;background:#0a0a0a;color:#e5e5e5"> |
| 133 | <div style="text-align:center;padding:2rem"> |
| 134 | <h1 style="color:${headingColor};margin-bottom:0.5rem">${heading}</h1> |
| 135 | <p style="color:#a3a3a3">${body}</p> |
| 136 | </div></body></html>` |
| 137 | } |
| 138 | |
| 139 | function startCallbackServer(codeVerifier: string): Promise<ChatGptOAuthCredentials> { |
| 140 | const redirectUrl = new URL(CHATGPT_OAUTH_REDIRECT_URI) |
no test coverage detected