Skip to content

fix(windows): 拆分 Capsule 平台承载并恢复完整视口#188

Closed
Cooper-X-Oak wants to merge 3 commits into
Open-Less:mainfrom
Cooper-X-Oak:codex/windows-capsule-upstream-redo
Closed

fix(windows): 拆分 Capsule 平台承载并恢复完整视口#188
Cooper-X-Oak wants to merge 3 commits into
Open-Less:mainfrom
Cooper-X-Oak:codex/windows-capsule-upstream-redo

Conversation

@Cooper-X-Oak
Copy link
Copy Markdown
Contributor

摘要

Fixes #139.

这个 PR 解决的单一目标是:
修复 Windows Capsule 宿主 viewport 被系统窗口非客户区吃掉后,胶囊本体被压进更小矩形、出现白框 / 宿主矩形可见 / 底部裁切的问题。

这个 PR 基于最新 upstream/main 干净重放,只包含这次 Capsule 修复所需的最小改动,不依赖之前本地工作树的其他上下文。

修复 / 新增 / 改进

  • Capsule.tsx 拆成平台路由,只负责 win -> WindowsCapsule、非 Windows -> SharedCapsule
  • 抽出 useCapsuleState.ts,统一承接 capsule 状态订阅与动作命令
  • 保留共享状态层,但将 Windows 视觉承载与非 Windows 视觉承载分离
  • 在 Windows Tauri 宿主侧补偿 capsule window bounds,恢复 Capsule WebView 的真实 viewport 到目标尺寸
  • 为 Windows capsule 宿主补齐最小平台配置,避免默认窗口边框继续吞掉 client area
  • 更新 Windows UI 配置校验,约束 Windows runtime 负责宿主承载切换

兼容

  • 不包含:macOS 修复、helper-window lifecycle 主线、hotkey、QA 浮窗、first-show / siw、issue 治理
  • 对现有用户 / 本地环境 / 构建流程的影响:
    • Windows Capsule 宿主尺寸从“看起来收紧”改为“实际 viewport 对齐目标 pill 尺寸”
    • 非 Windows Capsule 视觉路径保持在 SharedCapsule
    • 不引入新的远端依赖或构建产物

测试计划

  • 命令:npm run build

  • 结果:通过

  • 证据路径:本地 clean worktree 终端构建记录;Vite build 完成,无阻塞错误

  • 命令:cargo check --manifest-path Cargo.toml

  • 结果:通过

  • 证据路径:openless-all/app/src-tauri 目录下本地 clean worktree 检查记录;Rust backend check 完成,仅有既有 warning

  • 命令:本地 debug 运行 + WebView2 remote debugging 读取 Capsule layout metrics

  • 结果:通过

  • 证据路径:本地验证结果显示 Capsule innerWidth/innerHeight 从修复前的 164x44 恢复到 196x52,对应胶囊完整显示,不再被宿主矩形裁切

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @Cooper-X-Oak, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cad8536884

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread openless-all/app/src-tauri/src/lib.rs Outdated
Comment on lines +434 to +442
#[cfg(target_os = "windows")]
use window_vibrancy::apply_mica;
if let Err(e) = window.set_decorations(false) {
log::warn!("[main] disable native decorations failed: {e}");
}
if let Err(e) = apply_mica(window, None) {
log::warn!("[main] mica failed: {e}");
}
apply_windows_rounded_frame(window);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Guard Windows-only main-window calls with cfg

Wrap the Windows-specific calls in configure_main_window_for_platform with #[cfg(target_os = "windows")] (or an equivalent block). As written, window.set_decorations(false), apply_mica(...), and apply_windows_rounded_frame(...) are emitted for non-Windows targets too, but apply_mica is only imported on Windows and apply_windows_rounded_frame is itself Windows-gated, so non-Windows builds fail when compiling this function.

Useful? React with 👍 / 👎.

@Cooper-X-Oak
Copy link
Copy Markdown
Contributor Author

补充验证证据:

  1. GitHub CI
  1. 本地实际拉起应用验证
  • 基于 clean worktree codex/windows-capsule-upstream-redo
  • 实际启动 openless-all/app/src-tauri/target/debug/openless.exe
  • 通过 WebView2 remote debugging 触发 Capsule 显示并抓图
  • 本地运行时指标:Capsule innerWidth=196innerHeight=52devicePixelRatio=1.5
  • 运行时截图已在本地生成并核对,胶囊本体完整显示,不再出现之前的宿主矩形压缩与底部裁切
  1. 本地命令验证
  • npm run build:通过
  • cargo check --manifest-path Cargo.toml:通过

@Cooper-X-Oak
Copy link
Copy Markdown
Contributor Author

Cooper-X-Oak commented May 2, 2026

补充验证证据:

  1. GitHub CI
  1. 本地实际拉起应用验证
  • 基于 clean worktree codex/windows-capsule-upstream-redo
  • 实际启动 openless-all/app/src-tauri/target/debug/openless.exe
  • 通过 WebView2 remote debugging 触发 Capsule 显示并抓图
  • 本地运行时指标:Capsule innerWidth=196innerHeight=52devicePixelRatio=1.5
  • 运行时截图已在本地生成并核对,胶囊本体完整显示,不再出现之前的宿主矩形压缩与底部裁切
  1. 本地命令验证
  • npm run build:通过
  • cargo check --manifest-path Cargo.toml:通过
capsule-runtime-proof-cdp

@H-Chris233
Copy link
Copy Markdown
Collaborator

Codex:P1
cfg没写完整,只包住了一条语句
这会导致其他两端构建失败

@Cooper-X-Oak Cooper-X-Oak reopened this May 2, 2026
@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@Cooper-X-Oak
Copy link
Copy Markdown
Contributor Author

已处理 review 提到的 #[cfg(target_os = windows)] 包裹范围问题。

  • 新增提交:7dcca31 fix(tauri): scope windows capsule host runtime branch
  • 现在 configure_main_window_for_platform(...) 中 Windows 专属的 set_decorations / apply_mica / apply_windows_rounded_frame 已经收进完整的 Windows cfg block
  • 已重新运行 cargo check --manifest-path Cargo.toml,通过

这条修正只处理 review 提到的 cfg 包裹问题,不改变 #190 那条翻译态 Capsule 标题条问题的独立边界。

@Open-Less Open-Less deleted a comment from github-actions Bot May 2, 2026
@Open-Less Open-Less deleted a comment from github-actions Bot May 2, 2026
@H-Chris233
Copy link
Copy Markdown
Collaborator

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7dcca318e0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 146 to 148
coordinator.start_qa_hotkey_listener();
if std::env::var("OPENLESS_SHOW_MAIN_ON_START").ok().as_deref() == Some("1") {
show_main_window(app.handle());
}

Ok(())
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restore OPENLESS_SHOW_MAIN_ON_START startup hook

The setup path now returns immediately after starting listeners and no longer checks OPENLESS_SHOW_MAIN_ON_START, so the existing Windows automation paths that still set this variable (for example scripts/windows-cold-start.ps1 in ForceImmediateShow mode and other smoke scripts) have lost their explicit backend-driven “show + focus main window” override. This is a regression in test/dev workflow behavior because those flows can no longer force the foreground activation path that previously called show_main_window (show/unminimize/set_focus).

Useful? React with 👍 / 👎.

@H-Chris233
Copy link
Copy Markdown
Collaborator

Codex:p2
请修复(少的hook请加回来)

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.

[windows] Capsule 生命周期未对齐 macOS,导致死区 / 截图可选中 / 拖拽卡顿

2 participants