mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-17 09:02:08 +00:00
Copy OAuth login URL to clipboard for mobile SSH users (#415)
This commit is contained in:
parent
5f91baa29e
commit
9e3b1408f3
1 changed files with 12 additions and 1 deletions
|
|
@ -1994,15 +1994,26 @@ export class InteractiveMode {
|
||||||
await this.session.modelRegistry.authStorage.login(providerId as OAuthProvider, {
|
await this.session.modelRegistry.authStorage.login(providerId as OAuthProvider, {
|
||||||
onAuth: (info: { url: string; instructions?: string }) => {
|
onAuth: (info: { url: string; instructions?: string }) => {
|
||||||
this.chatContainer.addChild(new Spacer(1));
|
this.chatContainer.addChild(new Spacer(1));
|
||||||
// Use OSC 8 hyperlink escape sequence for clickable link
|
|
||||||
|
// OSC 8 hyperlink for desktop terminals that support clicking
|
||||||
const hyperlink = `\x1b]8;;${info.url}\x07Click here to login\x1b]8;;\x07`;
|
const hyperlink = `\x1b]8;;${info.url}\x07Click here to login\x1b]8;;\x07`;
|
||||||
this.chatContainer.addChild(new Text(theme.fg("accent", hyperlink), 1, 0));
|
this.chatContainer.addChild(new Text(theme.fg("accent", hyperlink), 1, 0));
|
||||||
|
|
||||||
|
// OSC 52 to copy URL to clipboard (works over SSH, e.g., Termux)
|
||||||
|
const urlBase64 = Buffer.from(info.url).toString("base64");
|
||||||
|
process.stdout.write(`\x1b]52;c;${urlBase64}\x07`);
|
||||||
|
this.chatContainer.addChild(
|
||||||
|
new Text(theme.fg("dim", "(URL copied to clipboard - paste in browser)"), 1, 0),
|
||||||
|
);
|
||||||
|
|
||||||
if (info.instructions) {
|
if (info.instructions) {
|
||||||
this.chatContainer.addChild(new Spacer(1));
|
this.chatContainer.addChild(new Spacer(1));
|
||||||
this.chatContainer.addChild(new Text(theme.fg("warning", info.instructions), 1, 0));
|
this.chatContainer.addChild(new Text(theme.fg("warning", info.instructions), 1, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.ui.requestRender();
|
this.ui.requestRender();
|
||||||
|
|
||||||
|
// Try to open browser on desktop
|
||||||
const openCmd =
|
const openCmd =
|
||||||
process.platform === "darwin"
|
process.platform === "darwin"
|
||||||
? "open"
|
? "open"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue