Skip to content

Fix Windows OAuth link copying / 修复 Windows 授权链接复制 - #16

Merged
VallierDev merged 1 commit into
VallierDev:mainfrom
eerraa:fix/windows-compat
Sep 19, 2026
Merged

VallierDev merged 1 commit into
VallierDev:mainfrom
eerraa:fix/windows-compat

Conversation

@eerraa

@eerraa eerraa commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

English · 简体中文

English

Restore “Copy authorization link” on Windows without changing the login flow or the existing macOS implementation.

Problem and user impact

On Windows, open Add Account and choose “Copy authorization link” to sign in with a browser other than the default. The existing IPC handler unconditionally launches pbcopy, so it returns 无法启动 pbcopy: program not found and leaves the clipboard unchanged. This is a local platform error, not an OAuth rejection; users must manually recover the URL to continue.

Focused fix

The current diff is limited to the Windows clipboard backend: 4 files, one commit. It replaces the earlier multi-topic version of this PR.

  • Dispatch the existing copy_to_clipboard command to a Windows-only module. The existing non-Windows clipboard function body is unchanged; no Linux clipboard helpers or unrelated copy-call migrations are included.
  • Use Windows PowerShell in STA mode with WinForms UnicodeText. A fixed command receives Base64-encoded UTF-8 through stdin: the URL never becomes shell syntax, and console encoding does not add a BOM or alter its characters. The helper does not open a console window.
  • Close stdin, check the exit status, and bound the helper operation to 20 seconds. Failures remain errors rather than being reported as successful copies.

This uses the Windows PowerShell/.NET desktop facilities already present on standard Windows installations; it adds no npm/Cargo dependency. An environment that restricts those facilities will still receive a copy error. Account storage, credentials, PKCE/state, callback handling, and token exchange are not changed.

Verification

At head dae2b74, the dedicated Windows CI passed: frontend build, cargo check --locked --all-targets, the transport test, and a real OS clipboard write/read round-trip covering Unicode/emoji, URL and shell metacharacters, an intentional leading BOM, a long URL, and empty text.

The OS clipboard test is ignored by default and requires an explicitly disposable GitHub Actions runner; ordinary local tests do not overwrite the developer's clipboard. This does not claim live OAuth end-to-end coverage.

Independent review: one commit directly on upstream main (f64a44a). The selectable-URL fallback is a separate, optional UI fix in #17; this backend fix does not require it.


简体中文

让 Windows 上的“复制授权链接”恢复可用,不改登录流程,也不改现有 macOS 剪贴板实现。

问题与用户影响

在 Windows 的“添加账号”中点击“复制授权链接”,本意是把链接粘贴到指定浏览器登录。但现有 IPC 处理函数会直接启动 pbcopy,因此返回 无法启动 pbcopy: program not found,剪贴板内容并未更新。这是本地平台调用失败,并非 OAuth 授权被拒绝;用户只能设法从界面中手动取出链接继续操作。

本次修改范围

当前 diff 已收敛为 4 个文件、1 个提交,仅修复 Windows 剪贴板后端,不再包含这个 PR 最初混在一起的其他修改。

  • Windows 下将现有 copy_to_clipboard 命令转到独立模块。非 Windows 的原有剪贴板函数体保持不变;不增加 Linux 剪贴板工具,也不迁移账号名、会话 ID 等其他复制入口。
  • 使用 Windows PowerShell 的 STA 模式和 WinForms UnicodeText。固定命令通过 stdin 接收 Base64 编码的 UTF-8 文本,URL 不会被拼接成 Shell 代码,也不会因控制台编码而多出 BOM 或改变字符;辅助进程不弹出控制台窗口。
  • 写完后关闭 stdin,检查退出状态,并设置 20 秒超时。复制失败就返回错误,不把失败显示成成功。

使用标准 Windows 安装已有的 Windows PowerShell/.NET 桌面能力,不新增 npm/Cargo 依赖。若系统策略限制这些能力,仍会明确返回复制错误。账号存储、凭据、PKCE/state、回调处理及令牌交换均不修改。

验证依据

当前提交 dae2b74 的独立 Windows CI 已通过:前端构建、cargo check --locked --all-targets、文本传输测试,以及真实系统剪贴板写入后再读回的测试。覆盖 Unicode/emoji、URL 与 Shell 特殊字符、刻意保留的开头 BOM、长 URL 和空文本。

真实剪贴板测试默认忽略,仅允许在明确标记为一次性环境的 GitHub Actions runner 上执行,不会在普通本地测试中覆盖开发者的剪贴板。这里不把剪贴板验证当作真实 OAuth 登录的端到端验证。

**可独立审阅和合并:**仅一个提交,直接基于 upstream main(f64a44a)。#17 单独处理复制失败后的链接展示与重试,本 PR 不依赖它。

@eerraa eerraa changed the title Fix Windows clipboard, OAuth fallback, tray placement and desktop actions Fix Windows OAuth link clipboard writes Sep 19, 2026
@eerraa eerraa changed the title Fix Windows OAuth link clipboard writes Fix Windows OAuth link copying / 修复 Windows 授权链接复制 Sep 19, 2026
@VallierDev
VallierDev merged commit 8de7ef3 into VallierDev:main Sep 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants