Skip to content

armgit / Wake

Public Imported from GitHub
0

All your AI agent sessions in one place — browse, search, resume. Rust + GPUI.

Rust

Add experimental Windows support

Claude7f5b80245b6f
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 7803491..0e0521f 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: false
matrix:
- os: [macos-14, ubuntu-24.04]
+ os: [macos-14, ubuntu-24.04, windows-2022]
steps:
- uses: actions/checkout@v4
diff --git a/Cargo.lock b/Cargo.lock
index 5ff7920..de12299 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -6815,6 +6815,7 @@ dependencies = [
"serde",
"serde_json",
"wake-core",
+ "winresource",
]
[[package]]
@@ -6831,6 +6832,7 @@ dependencies = [
"tempfile",
"trash",
"walkdir",
+ "windows-sys 0.61.2",
"zstd",
]
@@ -7647,6 +7649,16 @@ dependencies = [
"windows-sys 0.59.0",
]
+[[package]]
+name = "winresource"
+version = "0.1.31"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0986a8b1d586b7d3e4fe3d9ea39fb451ae22869dcea4aa109d287a374d866087"
+dependencies = [
+ "toml 1.1.4+spec-1.1.0",
+ "version_check",
+]
+
[[package]]
name = "winsafe"
version = "0.0.19"
diff --git a/README.md b/README.md
index 7063ba9..1da2740 100644
--- a/README.md
+++ b/README.md
@@ -2,12 +2,12 @@
[![License](https://img.shields.io/github/license/iAmCorey/Wake?style=flat-square)](LICENSE)
[![Release](https://img.shields.io/github/v/release/iAmCorey/Wake?style=flat-square)](https://github.com/iAmCorey/Wake/releases/latest)
-[![Platform](https://img.shields.io/badge/platform-macOS%2014%2B%20%7C%20Linux%20beta-007AFF?style=flat-square)](https://github.com/iAmCorey/Wake/releases/latest)
+[![Platform](https://img.shields.io/badge/platform-macOS%2014%2B%20%7C%20Linux%20beta%20%7C%20Windows%20beta-007AFF?style=flat-square)](https://github.com/iAmCorey/Wake/releases/latest)
[![Downloads](https://img.shields.io/github/downloads/iAmCorey/Wake/total?style=flat-square)](https://github.com/iAmCorey/Wake/releases)
[![Stars](https://img.shields.io/github/stars/iAmCorey/Wake?style=flat-square)](https://github.com/iAmCorey/Wake/stargazers)
[![CI](https://img.shields.io/github/actions/workflow/status/iAmCorey/Wake/ci.yml?branch=main&label=CI&style=flat-square)](https://github.com/iAmCorey/Wake/actions/workflows/ci.yml)
-A native desktop app that gathers every coding-agent session on your machine into one place — browse, full-text search, and resume any conversation in seconds. Built with **Rust + GPUI** (gpui 0.2 + gpui-component 0.5). macOS first; experimental Linux support since v0.2.5.
+A native desktop app that gathers every coding-agent session on your machine into one place — browse, full-text search, and resume any conversation in seconds. Built with **Rust + GPUI** (gpui 0.2 + gpui-component 0.5). macOS first; experimental Linux support since v0.2.5, experimental Windows support since v0.2.6.
Your agent history is scattered across `~/.claude`, `~/.codex`, and ten other private directories. Wake reads them all, read-only, and gives you one fast window into it. Everything stays local: no network requests, ever.
@@ -51,7 +51,7 @@ Cursor IDE chats, Windsurf, and Trae encrypt their local data; Amp, Factory (Dro
- Agent data directories are opened **read-only**; Wake never writes to another tool's files or databases
- Credential files (`auth.json` and friends) are never read
- Zero network requests — Wake never constructs or calls an HTTP client (GPUI's dependency tree bundles one; Wake doesn't reach for it)
-- Wake's own index lives at `~/Library/Application Support/wake/wake.db` and can be rebuilt from scratch at any time (stars/pins live in a separate table and survive rebuilds)
+- Wake's own index lives at `~/Library/Application Support/wake/wake.db` (Linux: `~/.local/share/wake`, Windows: `%APPDATA%\wake`) and can be rebuilt from scratch at any time (stars/pins live in a separate table and survive rebuilds)
## Performance
@@ -82,6 +82,18 @@ scripts/make-linux.sh # builds dist/wake-<version>-linux-<arch>.tar.gz an
The data layer, rendering and search are fully tested on Linux; terminal-resume targets and desktop integration have seen less real-desktop mileage yet — issues welcome.
+### Windows (experimental)
+
+Build from source (requires a Rust toolchain with the MSVC target):
+
+```powershell
+git clone https://github.com/iAmCorey/Wake; cd Wake
+powershell -ExecutionPolicy Bypass -File scripts/make-windows.ps1 # builds dist/wake-<version>-windows-<arch>.zip
+# or just: cargo run -p wake
+```
+
+Resume opens sessions in Windows Terminal, PowerShell, Command Prompt, Alacritty or WezTerm (whichever are installed); delete goes to the Recycle Bin. Agent data lives in the same `~/.claude`-style directories under your user profile, so everything indexed on macOS/Linux is indexed here too. Same beta caveat as Linux: the data layer is fully tested, desktop integration has seen less mileage — issues welcome.
+
## Development
```bash
@@ -109,7 +121,7 @@ crates/
│ ├── scanner.rs # single-pass scan: meta + FTS in one go, mtime incremental
│ ├── watcher.rs # notify-based file watching → per-file incremental updates
│ ├── db.rs # rusqlite (WAL): sessions / messages / messages_fts / user_data / tombstones
-│ └── services/ # terminal resume (AppleScript) / export / trash
+│ └── services/ # terminal resume (per-platform: AppleScript / argv / Win32) / export / trash
└── wake # GPUI app (three-pane workbench + ⌘K palette)
```
diff --git a/crates/wake-core/Cargo.toml b/crates/wake-core/Cargo.toml
index a1d8a52..c083bdd 100644
--- a/crates/wake-core/Cargo.toml
+++ b/crates/wake-core/Cargo.toml
@@ -15,11 +15,21 @@ notify.workspace = true
chrono.workspace = true
zstd.workspace = true
-# Linux 废纸篓:freedesktop Trash spec 的纯库实现(macOS 走 Finder/osascript,
-# 行为已验证不动;Windows 未做)
-[target.'cfg(target_os = "linux")'.dependencies]
+# Linux/Windows 废纸篓:freedesktop Trash spec / IFileOperation 回收站的
+# 纯库实现(macOS 走 Finder/osascript,行为已验证不动)
+[target.'cfg(any(target_os = "linux", target_os = "windows"))'.dependencies]
trash = "5"
+# Win32 原语:MessageBox 致命弹窗 + CF_UNICODETEXT 剪贴板(clip.exe 按控制台
+# codepage 解码 stdin,非 ASCII 命令必乱,不走子进程管道)
+[target.'cfg(target_os = "windows")'.dependencies]
+windows-sys = { version = "0.61", features = [
+ "Win32_Foundation",
+ "Win32_System_DataExchange",
+ "Win32_System_Memory",
+ "Win32_UI_WindowsAndMessaging",
+] }
+
[dev-dependencies]
tempfile = "3"
diff --git a/crates/wake-core/src/db.rs b/crates/wake-core/src/db.rs
index 9371d7a..af7eb2e 100644
--- a/crates/wake-core/src/db.rs
+++ b/crates/wake-core/src/db.rs
@@ -832,8 +832,9 @@ pub fn now_ms() -> i64 {
chrono::Utc::now().timestamp_millis()
}
-/// 索引库路径:~/Library/Application Support/wake/wake.db
-/// (从旧 vibex 路径一次性迁移,保留收藏等 user_data)
+/// 索引库路径:<dirs::data_dir>/wake/wake.db —— macOS 为
+/// ~/Library/Application Support,Linux 为 ~/.local/share,Windows 为
+/// %APPDATA%(从旧 vibex 路径一次性迁移,保留收藏等 user_data)
pub fn default_db_path() -> std::path::PathBuf {
let data = dirs::data_dir().unwrap_or_else(|| std::path::PathBuf::from("."));
let dir = data.join("wake");
diff --git a/crates/wake-core/src/services/terminal/mod.rs b/crates/wake-core/src/services/terminal/mod.rs
index b1c7dd4..190cf93 100644
--- a/crates/wake-core/src/services/terminal/mod.rs
+++ b/crates/wake-core/src/services/terminal/mod.rs
@@ -1,7 +1,12 @@
//! 会话恢复 / 系统集成服务。策略层(恢复命令拼装、CLI 解析、打开/选中/
-//! 删除的平台无关流程)在本文件;macos.rs / linux.rs 只提供原语(起终端、
-//! 开目录、选中文件、进废纸篓、弹对话框、写剪贴板),两边导出同形接口
-//! (TerminalApp 变体集合各异,UI 只遍历不点名)。
+//! 删除的平台无关流程)在本文件;macos.rs / linux.rs / windows.rs 只提供
+//! 原语(起终端、开目录、选中文件、进废纸篓、弹对话框、写剪贴板),各端
+//! 导出同形接口(TerminalApp 变体集合各异,UI 只遍历不点名)。
+//!
+//! POSIX 双端(macOS/Linux)共享本文件的 login shell 探测与 posix_quote
+//! 拼装;Windows 的三个前提全不成立(无 login shell、引号不是 POSIX 规则、
+//! 命令方言按终端宿主分 cmd/PowerShell 两派),这三件事经 probe_clis /
+//! compose_command / launch_in 三个接缝交回 windows.rs,策略流程本身不分叉。
use crate::models::{AgentId, SessionMeta};
use std::collections::HashMap;
@@ -19,9 +24,14 @@ mod linux;
#[cfg(target_os = "linux")]
use linux as platform;
-// 公共层的 shell 拼装 / login shell / posix_quote 全建立在 POSIX 假设上,
-// 新平台(Windows)进来必须给出自己的模块并重审这些前提,不能静默沿用
-#[cfg(not(any(target_os = "macos", target_os = "linux")))]
+#[cfg(target_os = "windows")]
+mod windows;
+#[cfg(target_os = "windows")]
+use windows as platform;
+
+// 公共层默认走 POSIX 假设,新平台进来必须给出自己的模块并重审 probe_clis /
+// compose_command / launch_in 三个接缝(windows.rs 是完整先例),不能静默沿用
+#[cfg(not(any(target_os = "macos", target_os = "linux", target_os = "windows")))]
compile_error!("wake terminal services: unsupported platform — add a platform module (POSIX assumptions throughout)");
pub use platform::{ensure_app_icons, installed_terminals, terminals_for, TerminalApp};
@@ -33,11 +43,12 @@ pub struct ResumeOutcome {
pub error: Option<String>,
}
-/// GUI 进程 PATH 不含 ~/.local/bin 等,经 login shell 批量解析并缓存
+/// GUI 进程 PATH 不全(macOS/Linux 缺 ~/.local/bin 等),批量解析并缓存
static CLI_CACHE: Mutex<Option<HashMap<String, Option<String>>>> = Mutex::new(None);
/// 解析 PATH 用的 login shell:macOS 固定 zsh(系统默认);Linux 尊重 $SHELL
/// (bash/zsh/fish 对 `-lic` 与 `command -v` 语义一致),缺省 /bin/bash
+#[cfg(not(target_os = "windows"))]
fn login_shell() -> String {
if cfg!(target_os = "macos") {
return "/bin/zsh".to_string();
@@ -48,29 +59,41 @@ fn login_shell() -> String {
.unwrap_or_else(|| "/bin/bash".to_string())
}
+/// 批量探测缺失 bin 的绝对路径(POSIX:login shell 里 `command -v`,把
+/// 用户 rc 文件加进 PATH 的目录一并覆盖)。Windows 的 GUI 进程 PATH 来自
+/// 注册表、天然完整,探测在 windows.rs 用 PATH×PATHEXT 纯 Rust 遍历。
+#[cfg(not(target_os = "windows"))]
+fn probe_clis(missing: &[&str]) -> HashMap<String, String> {
+ let script = missing
+ .iter()
+ .map(|b| format!("printf '%s\\t' {b}; command -v {b} || echo"))
+ .collect::<Vec<_>>()
+ .join("; ");
+ let out = Command::new(login_shell()).args(["-lic", &script]).output();
+ let stdout = out
+ .ok()
+ .map(|o| String::from_utf8_lossy(&o.stdout).to_string())
+ .unwrap_or_default();
+ let mut found = HashMap::new();
+ for line in stdout.lines() {
+ if let Some((name, path)) = line.split_once('\t') {
+ if path.starts_with('/') {
+ found.insert(name.trim().to_string(), path.trim().to_string());
+ }
+ }
+ }
+ found
+}
+
+#[cfg(target_os = "windows")]
+use windows::probe_clis;
+
fn resolve_clis(bins: &[&str]) -> HashMap<String, Option<String>> {
let mut cache = CLI_CACHE.lock().unwrap();
let map = cache.get_or_insert_with(HashMap::new);
let missing: Vec<&str> = bins.iter().filter(|b| !map.contains_key(**b)).copied().collect();
if !missing.is_empty() {
- let script = missing
- .iter()
- .map(|b| format!("printf '%s\\t' {b}; command -v {b} || echo"))
- .collect::<Vec<_>>()
- .join("; ");
- let out = Command::new(login_shell()).args(["-lic", &script]).output();
- let stdout = out
- .ok()
- .map(|o| String::from_utf8_lossy(&o.stdout).to_string())
- .unwrap_or_default();
- let mut found: HashMap<&str, String> = HashMap::new();
- for line in stdout.lines() {
- if let Some((name, path)) = line.split_once('\t') {
- if path.starts_with('/') {
- found.insert(name.trim(), path.trim().to_string());
- }
- }
- }
+ let found = probe_clis(&missing);
for b in missing {
map.insert(b.to_string(), found.get(b).cloned());
}
@@ -144,6 +167,7 @@ fn resume_args(agent: AgentId, id: &str) -> Option<(Vec<String>, bool)> {
}
/// POSIX 单引号 quote
+#[cfg(not(target_os = "windows"))]
pub fn posix_quote(s: &str) -> String {
if !s.is_empty()
&& s.chars()
@@ -154,8 +178,53 @@ pub fn posix_quote(s: &str) -> String {
format!("'{}'", s.replace('\'', r"'\''"))
}
+/// 展示/剪贴板/启动共用的一条可执行命令。POSIX 双端就是实际启动串;
+/// Windows 版(windows.rs)是 PowerShell 方言的"手动可粘"形态,实际启动
+/// 由 launch_in 按终端宿主重拼。
+#[cfg(not(target_os = "windows"))]
+fn compose_command(cli: &str, args: &[String], cwd: Option<&str>) -> String {
+ let core = std::iter::once(cli)
+ .chain(args.iter().map(|s| s.as_str()))
+ .map(posix_quote)
+ .collect::<Vec<_>>()
+ .join(" ");
+ match cwd {
+ Some(dir) => format!("cd {} && {core}", posix_quote(dir)),
+ None => core,
+ }
+}
+
+#[cfg(target_os = "windows")]
+use windows::compose_command;
+
+/// 起终端跑恢复命令。POSIX 双端直接投喂拼好的 command;Windows 忽略
+/// command、拿结构化件重拼(cmd 宿主 cmd 方言、其余 PowerShell 方言)——
+/// 一条字符串塞不进两种引号规则,接缝只能开在这里。
+#[cfg(not(target_os = "windows"))]
+fn launch_in(
+ term: TerminalApp,
+ _cli: &str,
+ _args: &[String],
+ _cwd: Option<&str>,
+ command: &str,
+) -> anyhow::Result<()> {
+ platform::launch_shell(term, command)
+}
+
+#[cfg(target_os = "windows")]
+fn launch_in(
+ term: TerminalApp,
+ cli: &str,
+ args: &[String],
+ cwd: Option<&str>,
+ _command: &str,
+) -> anyhow::Result<()> {
+ windows::launch_shell(term, cli, args, cwd)
+}
+
/// 保守 percent-encode(RFC 3986 unreserved 之外全编;keep_slash 供
-/// file:// URL 保路径分隔)。两平台共用,编码集只此一份。
+/// file:// URL 保路径分隔)。POSIX 两端共用,编码集只此一份。
+#[cfg(not(target_os = "windows"))]
pub(crate) fn percent_encode(s: &str, keep_slash: bool) -> String {
use std::fmt::Write;
let mut out = String::with_capacity(s.len());
@@ -198,16 +267,8 @@ pub fn resume_session_in(meta: &SessionMeta, term: TerminalApp) -> ResumeOutcome
};
};
let cwd_ok = !meta.project_path.is_empty() && Path::new(&meta.project_path).is_dir();
- let core = std::iter::once(cli.as_str())
- .chain(args.iter().map(|s| s.as_str()))
- .map(posix_quote)
- .collect::<Vec<_>>()
- .join(" ");
- let command = if cwd_ok {
- format!("cd {} && {core}", posix_quote(&meta.project_path))
- } else {
- core
- };
+ let cwd = cwd_ok.then(|| meta.project_path.as_str());
+ let command = compose_command(&cli, &args, cwd);
if requires_cwd && !cwd_ok {
let hint = clipboard_fallback(&command);
return ResumeOutcome {
@@ -217,7 +278,7 @@ pub fn resume_session_in(meta: &SessionMeta, term: TerminalApp) -> ResumeOutcome
};
}
- let result = platform::launch_shell(term, &command);
+ let result = launch_in(term, &cli, &args, cwd, &command);
match result {
Ok(()) => ResumeOutcome {
ok: true,
@@ -248,8 +309,8 @@ fn clipboard_fallback(command: &str) -> String {
/// 删除会话文件到系统回收站(可恢复)。虚拟路径 `<db>#<id>` 与已消失的
/// 文件在此过滤(不变量 3:SQLite 型只 tombstone),平台原语只收真实路径。
-/// 部分失败语义:平台实现可能删到一半报错(macOS 逐文件、Linux 批量),
-/// 调用方按"整批可疑"处理即可——已进回收站的文件可恢复,无害。
+/// 部分失败语义:平台实现可能删到一半报错(macOS 逐文件、Linux/Windows
+/// 批量),调用方按"整批可疑"处理即可——已进回收站的文件可恢复,无害。
pub fn trash_paths(paths: &[String]) -> anyhow::Result<()> {
let existing: Vec<&str> = paths
.iter()
@@ -287,9 +348,12 @@ pub fn reveal_in_file_manager(path: &str) {
std::thread::spawn(move || platform::reveal_path(&real));
}
-/// 把 text 经管道写给 `bin args…` 的 stdin(剪贴板工具用),按退出码报成败
-/// ——"copied to clipboard" 的用户提示以此为据,不能 spawn 成功就算数。
+/// 把 text 经管道写给 `bin args…` 的 stdin(POSIX 剪贴板工具用),按退出码
+/// 报成败——"copied to clipboard" 的用户提示以此为据,不能 spawn 成功就算数。
/// 三家 Linux 工具与 pbcopy 都在拿到内容后自行 fork 常驻,wait 即刻返回。
+/// Windows 不走子进程管道(clip.exe 按控制台 codepage 解码,非 ASCII 必乱),
+/// windows.rs 直接调 Win32 剪贴板。
+#[cfg(not(target_os = "windows"))]
pub(crate) fn pipe_to(bin: &str, args: &[&str], text: &str) -> bool {
use std::io::Write;
let Ok(mut child) = Command::new(bin).args(args).stdin(std::process::Stdio::piped()).spawn()
@@ -305,7 +369,8 @@ pub(crate) fn pipe_to(bin: &str, args: &[&str], text: &str) -> bool {
/// 起子进程并**收尸**,spawn 失败上抛。`status()` 不能用:把调用线程阻塞
/// 到进程结束(文件管理器冷启上百毫秒);裸 `spawn()` 丢掉 Child 也不行:
/// Unix 上 Child 的 Drop 不 wait,实测点几次就攒几个 `<defunct>`,直到
-/// Wake 退出才回收。故 spawn 后交给一个短命线程 wait。
+/// Wake 退出才回收。故 spawn 后交给一个短命线程 wait。Windows 无僵尸进程
+/// 概念,但 wait 同样及时归还进程句柄,三端共用。
fn spawn_and_reap(mut cmd: Command) -> std::io::Result<()> {
let mut child = cmd.spawn()?;
std::thread::spawn(move || {
diff --git a/crates/wake-core/src/services/terminal/windows.rs b/crates/wake-core/src/services/terminal/windows.rs
new file mode 100644
index 0000000..0b29be4
--- /dev/null
+++ b/crates/wake-core/src/services/terminal/windows.rs
@@ -0,0 +1,352 @@
+//! Windows 平台原语:终端宿主(Windows Terminal / PowerShell / cmd /
+//! Alacritty / WezTerm)、回收站(trash crate → IFileOperation)、资源管理器
+//! 进入/选中、Win32 剪贴板与 MessageBox。接口与 macos.rs / linux.rs 同形,
+//! 策略在 mod.rs;mod.rs 的三个 POSIX 前提(login shell、posix_quote、单一
+//! shell 方言)在本端由 probe_clis / compose_command / launch_shell 接管。
+//!
+//! 方言分两派:cmd 宿主用 cmd 方言内联注入(raw_arg 直达,无 argv 引号层);
+//! 其余宿主一律装 PowerShell 会话——脚本全单引号、不含双引号,经宿主的
+//! argv 重引号往返无损(cmd 方言的内层双引号过不了 wt 这类会重拼命令行的
+//! 宿主)。展示/剪贴板形态同为 PowerShell 方言:现代 Windows 的默认 shell,
+//! pwsh / Windows PowerShell / wt 默认 profile 粘贴均可跑。
+
+use super::{spawn_and_reap, ResumeOutcome};
+use crate::models::{AgentId, SessionMeta};
+use std::collections::HashMap;
+use std::os::windows::process::CommandExt;
+use std::path::{Path, PathBuf};
+use std::process::Command;
+
+/// 子进程创建旗标(文档钉死的值,不为两个常量拉 windows-sys feature):
+/// NEW_CONSOLE 给控制台宿主开自己的窗;NO_WINDOW 压掉 console 子系统
+/// launcher(wt.exe / wezterm.exe)从 GUI 进程起动时闪现的空控制台,
+/// 对 GUI 子进程无效果、可安全统一加。
+const CREATE_NEW_CONSOLE: u32 = 0x0000_0010;
+const CREATE_NO_WINDOW: u32 = 0x0800_0000;
+
+/// Open In 下拉的目标终端(Windows 家族)。wt/pwsh/powershell/cmd 覆盖
+/// 系统自带面(cmd 与 Windows PowerShell 必装,探测恒真),第三方只列
+/// 装了的。Ghostty/kitty 无 Windows 发行版,不列。
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub enum TerminalApp {
+ /// Windows Terminal(wt)——Win11 默认终端宿主
+ WindowsTerminal,
+ /// PowerShell 7+(pwsh),与内置 Windows PowerShell 是两个产品
+ Pwsh,
+ WindowsPowershell,
+ Cmd,
+ Alacritty,
+ WezTerm,
+}
+
+impl TerminalApp {
+ /// 声明序即偏好序(installed_terminals 保序,UI 回退取首个)
+ const ALL: [TerminalApp; 6] = [
+ TerminalApp::WindowsTerminal,
+ TerminalApp::Pwsh,
+ TerminalApp::WindowsPowershell,
+ TerminalApp::Cmd,
+ TerminalApp::Alacritty,
+ TerminalApp::WezTerm,
+ ];
+
+ /// 命名对齐 wt 自己的 profile 名("PowerShell" = 7+,"Windows PowerShell"
+ /// = 内置 5.1),用户在 wt 里见到的就是这两个词
+ pub fn display_name(&self) -> &'static str {
+ match self {
+ TerminalApp::WindowsTerminal => "Windows Terminal",
+ TerminalApp::Pwsh => "PowerShell",
+ TerminalApp::WindowsPowershell => "Windows PowerShell",
+ TerminalApp::Cmd => "Command Prompt",
+ TerminalApp::Alacritty => "Alacritty",
+ TerminalApp::WezTerm => "WezTerm",
+ }
+ }
+
+ /// 稳定短 id(图标缓存文件名、last-used 记忆用)。恰好也全部是可执行名,
+ /// 探测与启动直接复用(PATHEXT 扩展名由 probe_clis 补)
+ pub fn id(&self) -> &'static str {
+ match self {
+ TerminalApp::WindowsTerminal => "wt",
+ TerminalApp::Pwsh => "pwsh",
+ TerminalApp::WindowsPowershell => "powershell",
+ TerminalApp::Cmd => "cmd",
+ TerminalApp::Alacritty => "alacritty",
+ TerminalApp::WezTerm => "wezterm",
+ }
+ }
+}
+
+/// PATH × PATHEXT 纯 Rust 遍历,语义即 CreateProcess 的查找规则。不走
+/// where.exe:它把输出编码成控制台 codepage,非 ASCII 用户名的路径经
+/// from_utf8_lossy 必坏;env::var/Path 全程 Unicode,无此折损,也免掉
+/// GUI 进程起 console 子进程的窗口闪现。无扩展名裸文件(npm 的 bash
+/// shim)不参与候选,天然滤掉。
+pub(super) fn probe_clis(missing: &[&str]) -> HashMap<String, String> {
+ let mut found = HashMap::new();
+ let path_var = std::env::var_os("PATH").unwrap_or_default();
+ let dirs: Vec<PathBuf> = std::env::split_paths(&path_var).collect();
+ let exts: Vec<String> = std::env::var("PATHEXT")
+ .unwrap_or_else(|_| ".COM;.EXE;.BAT;.CMD".into())
+ .split(';')
+ .filter(|e| e.starts_with('.'))
+ .map(str::to_string)
+ .collect();
+ for want in missing {
+ 'dirs: for dir in &dirs {
+ if dir.as_os_str().is_empty() {
+ continue;
+ }
+ for ext in &exts {
+ let cand = dir.join(format!("{want}{ext}"));
+ // WindowsApps 的 app-execution alias(wt.exe)是 0 字节
+ // reparse 文件,is_file 为真、可直接 spawn
+ if cand.is_file() {
+ found.insert(want.to_string(), cand.to_string_lossy().to_string());
+ break 'dirs;
+ }
+ }
+ }
+ }
+ found
+}
+
+/// PowerShell 单引号字面量:唯一转义是 ' → ''。`$`、反引号、反斜杠全是
+/// 普通字符,且命令行经 CreateProcessW 以 UTF-16 直达,无 codepage 折损
+fn ps_quote(s: &str) -> String {
+ format!("'{}'", s.replace('\'', "''"))
+}
+
+/// cmd 方言 quote:整体双引号包裹(Windows 文件名不允许 `"`,无内层转义
+/// 面);`%` 在引号内仍会展开是 cmd 关不掉的固有行为,路径/会话 id 命中
+/// 概率视为零。裸词直通条件比 POSIX 版多放行 `\`(盘符路径)。
+fn cmd_quote(s: &str) -> String {
+ if !s.is_empty()
+ && s.chars()
+ .all(|c| c.is_ascii_alphanumeric() || "_-./:\\=".contains(c))
+ {
+ return s.to_string();
+ }
+ format!("\"{s}\"")
+}
+
+/// 展示/剪贴板形态 = PowerShell 方言:`Set-Location -LiteralPath 'dir';
+/// & 'cli' 'args…'`。-LiteralPath 防路径里的 `[ ]` 被当通配符;分隔用 `;`
+/// 而非 `&&`——Windows PowerShell 5.1 不认 `&&`,而 cwd 已在 mod.rs 验过
+/// 存在,cd 失败只剩竞态窗口。cmd 用户是唯一粘不动的群体,而 cmd 宿主由
+/// launch_shell 直接注入、不经剪贴板,失败兜底选覆盖面最大的方言。
+pub(super) fn compose_command(cli: &str, args: &[String], cwd: Option<&str>) -> String {
+ let core = ps_call(cli, args);
+ match cwd {
+ Some(dir) => format!("Set-Location -LiteralPath {}; {core}", ps_quote(dir)),
+ None => core,
+ }
+}
+
+/// 纯调用段(无 cd、无分号):`& 'cli' 'args…'`。wt 宿主用它配合 `-d`
+/// 传工作目录——wt 对命令行做无视引号的 `;` 分面板切分,脚本里带分号
+/// 必被腰斩,cd 只能交给 wt 自己的 -d。
+fn ps_call(cli: &str, args: &[String]) -> String {
+ let mut core = format!("& {}", ps_quote(cli));
+ for a in args {
+ core.push(' ');
+ core.push_str(&ps_quote(a));
+ }
+ core
+}
+
+/// wt 命令行的 `;` 转义(wt 文档规定 `\;`;引号不豁免,对 option 值同样
+/// 生效)。路径/id 里出现分号是合法但极罕见的形态,统一转义兜住。
+fn wt_escape(s: &str) -> String {
+ s.replace(';', "\\;")
+}
+
+/// Windows 无深链类恢复目标(Kooky 仅 macOS),全部走 shell 命令
+pub(super) fn deep_link_resume(_meta: &SessionMeta, _term: TerminalApp) -> Option<ResumeOutcome> {
+ None
+}
+
+/// 已安装终端(启动后不变,进程内缓存;PATH 遍历是纯文件系统操作,首扫
+/// 即毫秒级)
+pub fn installed_terminals() -> &'static [TerminalApp] {
+ use std::sync::OnceLock;
+ static CACHE: OnceLock<Vec<TerminalApp>> = OnceLock::new();
+ CACHE.get_or_init(|| {
+ let bins: Vec<&str> = TerminalApp::ALL.iter().map(|t| t.id()).collect();
+ let found = super::resolve_clis(&bins);
+ TerminalApp::ALL
+ .into_iter()
+ .filter(|t| matches!(found.get(t.id()), Some(Some(_))))
+ .collect()
+ })
+}
+
+/// 某会话可用的恢复目标(Windows 无按 agent 过滤的目标,一律全量)
+pub fn terminals_for(_agent: AgentId) -> Vec<TerminalApp> {
+ installed_terminals().to_vec()
+}
+
+/// wt/第三方宿主内装的 shell:优先 pwsh(用户装了 7+ 就是它的默认),
+/// 缺席退必装的 Windows PowerShell
+fn powershell_bin() -> Option<String> {
+ super::resolve_cli("pwsh").or_else(|| super::resolve_cli("powershell"))
+}
+
+/// 按宿主方言起终端。keep-open 与 POSIX 的 `exec $SHELL` 同位:cmd 用
+/// `/K`,PowerShell 用 `-NoExit`,命令跑完留在交互提示符。
+pub(super) fn launch_shell(
+ term: TerminalApp,
+ cli: &str,
+ args: &[String],
+ cwd: Option<&str>,
+) -> anyhow::Result<()> {
+ let bin = term.id();
+ let exe = super::resolve_cli(bin).ok_or_else(|| anyhow::anyhow!("{bin} not found"))?;
+ let mut cmd = Command::new(&exe);
+ match term {
+ TerminalApp::Cmd => {
+ // cmd 方言内联注入。raw_arg 绕过 std 的 argv 引号规则——cmd 不做
+ // argv 解析,std 把整串再包一层引号反而会毁掉内层结构;串首是
+ // `cd`/裸词而非引号,cmd 的引号保全规则生效,内层 "…" 原样送达
+ let mut line = String::from("/K ");
+ if let Some(dir) = cwd {
+ // /d:跨盘符 cd 也生效(会话在 D: 而 cmd 起在 C: 的情形)
+ line.push_str(&format!("cd /d {} && ", cmd_quote(dir)));
+ }
+ line.push_str(&cmd_quote(cli));
+ for a in args {
+ line.push(' ');
+ line.push_str(&cmd_quote(a));
+ }
+ cmd.raw_arg(line);
+ cmd.creation_flags(CREATE_NEW_CONSOLE);
+ }
+ TerminalApp::Pwsh | TerminalApp::WindowsPowershell => {
+ cmd.args(["-NoLogo", "-NoExit", "-Command", &compose_command(cli, args, cwd)]);
+ cmd.creation_flags(CREATE_NEW_CONSOLE);
+ }
+ TerminalApp::WindowsTerminal => {
+ // wt 装 PowerShell 会话。工作目录走 wt 自己的 -d,脚本只剩纯调用
+ // 段(见 ps_call);所有透传参数过 wt_escape——wt 的 `;` 切分
+ // 无视引号,不转义的分号会把命令行腰斩成两个面板
+ let ps = powershell_bin().ok_or_else(|| anyhow::anyhow!("PowerShell not found"))?;
+ if let Some(dir) = cwd {
+ cmd.args(["-d", &wt_escape(dir)]);
+ }
+ cmd.args([&wt_escape(&ps), "-NoLogo", "-NoExit", "-Command", &wt_escape(&ps_call(cli, args))]);
+ cmd.creation_flags(CREATE_NO_WINDOW);
+ }
+ TerminalApp::Alacritty | TerminalApp::WezTerm => {
+ // 第三方宿主装 PowerShell 会话:脚本全单引号、无内层双引号,经
+ // 宿主的 argv 重引号(std → 宿主 → CreateProcess)往返无损;
+ // 两家 argv 直传、无 wt 那套 `;` 语义,cd 留在脚本里
+ let ps = powershell_bin().ok_or_else(|| anyhow::anyhow!("PowerShell not found"))?;
+ if term == TerminalApp::WezTerm {
+ cmd.args(["start", "--"]);
+ } else {
+ cmd.arg("-e");
+ }
+ cmd.args([ps.as_str(), "-NoLogo", "-NoExit", "-Command", &compose_command(cli, args, cwd)]);
+ cmd.creation_flags(CREATE_NO_WINDOW);
+ }
+ }
+ spawn_and_reap(cmd)?;
+ Ok(())
+}
+
+/// 终端图标提取:Windows 得走 SHGetFileInfo/ExtractIcon + HICON→PNG 编码
+/// 一整条 GDI 链,v1 不做——UI 对无图标的终端行本就有无图兜底。与 Linux
+/// 同策略,顺手在启动的 background 线程里预热 installed_terminals。
+pub fn ensure_app_icons(_cache_dir: &Path) -> HashMap<String, PathBuf> {
+ let _ = installed_terminals();
+ HashMap::new()
+}
+
+/// Win32 剪贴板(CF_UNICODETEXT),UTF-16 直达。别家占着剪贴板时
+/// OpenClipboard 会瞬时失败(剪贴板管理器常见),小步重试几轮;仍失败
+/// 返回 false——调用方(clipboard_fallback)据此决定还敢不敢说 "copied"。
+pub(super) fn copy_to_clipboard(text: &str) -> bool {
+ use windows_sys::Win32::System::DataExchange::{
+ CloseClipboard, EmptyClipboard, OpenClipboard, SetClipboardData,
+ };
+ use windows_sys::Win32::System::Memory::{GlobalAlloc, GlobalLock, GlobalUnlock, GMEM_MOVEABLE};
+ const CF_UNICODETEXT: u32 = 13;
+
+ let wide: Vec<u16> = text.encode_utf16().chain(std::iter::once(0)).collect();
+ let bytes = wide.len() * 2;
+ unsafe {
+ let mut opened = false;
+ for _ in 0..5 {
+ if OpenClipboard(std::ptr::null_mut()) != 0 {
+ opened = true;
+ break;
+ }
+ std::thread::sleep(std::time::Duration::from_millis(20));
+ }
+ if !opened {
+ return false;
+ }
+ let ok = 'set: {
+ if EmptyClipboard() == 0 {
+ break 'set false;
+ }
+ let hmem = GlobalAlloc(GMEM_MOVEABLE, bytes);
+ if hmem.is_null() {
+ break 'set false;
+ }
+ let dst = GlobalLock(hmem);
+ if dst.is_null() {
+ // hmem 就地泄漏:一次性小块,不为它多拉 GlobalFree 绑定
+ break 'set false;
+ }
+ std::ptr::copy_nonoverlapping(wide.as_ptr().cast::<u8>(), dst.cast::<u8>(), bytes);
+ GlobalUnlock(hmem);
+ // 成功后内存归系统所有,不得再碰
+ !SetClipboardData(CF_UNICODETEXT, hmem).is_null()
+ };
+ CloseClipboard();
+ ok
+ }
+}
+
+/// 批量删进回收站(trash crate → IFileOperation + FOF_ALLOWUNDO,资源管理
+/// 器里可恢复;COM 初始化由 trash 自理;收 mod.rs 已过滤的真实路径)
+pub(super) fn trash_existing(paths: &[&str]) -> anyhow::Result<()> {
+ trash::delete_all(paths).map_err(|e| anyhow::anyhow!("Failed to move to Recycle Bin: {e}"))
+}
+
+/// 致命错误对话框:MessageBoxW。release 构建挂 windows 子系统,stderr
+/// 无处可去,这是 GPUI 窗口起不来时唯一的可见通道。
+pub(super) fn alert_dialog(message: &str) {
+ use windows_sys::Win32::UI::WindowsAndMessaging::{
+ MessageBoxW, MB_ICONERROR, MB_OK, MB_SETFOREGROUND, MB_TOPMOST,
+ };
+ let wide = |s: &str| s.encode_utf16().chain(std::iter::once(0)).collect::<Vec<u16>>();
+ let text = wide(message);
+ let caption = wide("Wake can't start");
+ unsafe {
+ MessageBoxW(
+ std::ptr::null_mut(),
+ text.as_ptr(),
+ caption.as_ptr(),
+ MB_OK | MB_ICONERROR | MB_TOPMOST | MB_SETFOREGROUND,
+ );
+ }
+}
+
+/// 在资源管理器里进入目录(explorer 常驻单实例、前台进程即刻退出,
+/// 且退出码恒非零,spawn 成功即算送达)
+pub(super) fn open_dir(path: &str) {
+ let mut cmd = Command::new("explorer.exe");
+ cmd.arg(path);
+ let _ = spawn_and_reap(cmd);
+}
+
+/// 选中文件(收 mod.rs 已剥好虚拟后缀的真实路径)。`/select,"path"` 必须
+/// 整体一个参数且引号形制固定——explorer 自解析命令行、不吃 argv 转义,
+/// raw_arg 原样直达。
+pub(super) fn reveal_path(path: &str) {
+ let mut cmd = Command::new("explorer.exe");
+ cmd.raw_arg(format!("/select,\"{path}\""));
+ let _ = spawn_and_reap(cmd);
+}
diff --git a/crates/wake/Cargo.toml b/crates/wake/Cargo.toml
index 1cb5fe1..a553299 100644
--- a/crates/wake/Cargo.toml
+++ b/crates/wake/Cargo.toml
@@ -19,3 +19,10 @@ gpui-component = { version = "0.5", features = ["tree-sitter-languages"] }
futures = "0.3"
chrono.workspace = true
dirs.workspace = true
+
+# exe 图标 + 版本资源(build.rs 里按 CARGO_CFG_TARGET_OS 判目标生效)。
+# 不做 target 门控:build-dependencies 的 [target.*] 匹配语义在 host/target
+# 之间有历史歧义,门控错方向 build.rs 直接解析失败;它是纯 Rust 小依赖,
+# 三平台无条件编译换四种 host×target 组合全对
+[build-dependencies]
+winresource = "0.1"
diff --git a/crates/wake/assets/icon.ico b/crates/wake/assets/icon.ico
new file mode 100644
index 0000000..929f944
Binary files /dev/null and b/crates/wake/assets/icon.ico differ
diff --git a/crates/wake/build.rs b/crates/wake/build.rs
new file mode 100644
index 0000000..d060ca2
--- /dev/null
+++ b/crates/wake/build.rs
@@ -0,0 +1,21 @@
+//! Windows 资源嵌入:exe 图标 + 版本信息。图标资源 ID 必须是 1——gpui 的
+//! Windows 后端用 `LoadImageW(module, MAKEINTRESOURCE(1))` 取窗口/任务栏图
+//! (winresource 的 set_icon 默认即 ID 1),资源管理器则自取最小 ID 做文件图。
+//! 其余平台此脚本是空转;icon.ico 由 icon.svg 预生成入库
+//! (scripts/make-windows.ps1 头注有再生成命令)。
+
+fn main() {
+ // 按编译目标而非宿主判断:交叉构建(如 Linux 上 cargo check windows 目标)
+ // 也要走这支;宿主没有 rc/windres 工具链时降级为警告,不挡 check
+ if std::env::var("CARGO_CFG_TARGET_OS").as_deref() != Ok("windows") {
+ return;
+ }
+ println!("cargo:rerun-if-changed=assets/icon.ico");
+ let mut res = winresource::WindowsResource::new();
+ res.set_icon("assets/icon.ico");
+ res.set("ProductName", "Wake");
+ res.set("FileDescription", "Wake — coding agent session manager");
+ if let Err(e) = res.compile() {
+ println!("cargo:warning=Windows resources skipped (icon/version info): {e}");
+ }
+}
diff --git a/crates/wake/src/format.rs b/crates/wake/src/format.rs
index cb93281..d398a1e 100644
--- a/crates/wake/src/format.rs
+++ b/crates/wake/src/format.rs
@@ -63,23 +63,29 @@ fn cached_home() -> Option<&'static str> {
pub fn tilde_path(p: &str) -> String {
// 边界必须落在分隔符上:裸 starts_with 会把 HOME 的同名前缀兄弟目录
// 也折叠掉(HOME=/Users/al 时 /Users/al-data → "~-data",一个并不存在
- // 的 HOME 相对路径)。自定义 CODEX_HOME / XDG_DATA_HOME 让这种根变得可能
+ // 的 HOME 相对路径)。自定义 CODEX_HOME / XDG_DATA_HOME 让这种根变得可能。
+ // 分隔符判定走 std::path::is_separator:Windows 上 `\` 与 `/` 都算
match cached_home() {
Some(h) => match p.strip_prefix(h) {
- Some(rest) if rest.is_empty() || rest.starts_with('/') => format!("~{rest}"),
+ Some(rest) if rest.is_empty() || rest.starts_with(std::path::is_separator) => {
+ format!("~{rest}")
+ }
_ => p.to_string(),
},
None => p.to_string(),
}
}
-/// 手输路径的 `~` 前缀展开(tilde_path 的逆;仅前缀,边界同样落在分隔符上)
+/// 手输路径的 `~` 前缀展开(tilde_path 的逆;仅前缀,边界同样落在分隔符上
+/// ——Windows 用户手输 `~\foo` 同样认)
pub fn expand_tilde(p: &str) -> String {
match p.strip_prefix('~') {
- Some(rest) if rest.is_empty() || rest.starts_with('/') => match cached_home() {
- Some(h) => format!("{h}{rest}"),
- None => p.to_string(),
- },
+ Some(rest) if rest.is_empty() || rest.starts_with(std::path::is_separator) => {
+ match cached_home() {
+ Some(h) => format!("{h}{rest}"),
+ None => p.to_string(),
+ }
+ }
_ => p.to_string(),
}
}
@@ -95,11 +101,13 @@ pub fn display_file_path(path: &str) -> String {
.map(|(db, _)| db)
.unwrap_or(path);
let tilde = tilde_path(p);
- let parts: Vec<&str> = tilde.split('/').collect();
+ let parts: Vec<&str> = tilde.split(std::path::is_separator).collect();
match (parts.first(), parts.get(1), parts.last()) {
- // 超过 根/次级/…/文件 四段的深路径折叠中段
+ // 超过 根/次级/…/文件 四段的深路径折叠中段(重拼用本平台主分隔符,
+ // Windows 展示 `~\a\…\file` 与系统一致)
(Some(root), Some(second), Some(file)) if parts.len() > 4 => {
- format!("{root}/{second}/…/{file}")
+ let s = std::path::MAIN_SEPARATOR;
+ format!("{root}{s}{second}{s}…{s}{file}")
}
_ => tilde,
}
diff --git a/crates/wake/src/main.rs b/crates/wake/src/main.rs
index d7b8190..02d1350 100644
--- a/crates/wake/src/main.rs
+++ b/crates/wake/src/main.rs
@@ -1,3 +1,8 @@
+// release 挂 windows 子系统:双击启动不带控制台黑窗。debug 保留控制台,
+// eprintln 的诊断日志还有处落;GUI 子系统下致命错误走 MessageBox
+//(wake-core 的 show_fatal_alert),不依赖 stderr。
+#![cfg_attr(all(target_os = "windows", not(debug_assertions)), windows_subsystem = "windows")]
+
mod assets;
mod format;
mod theme;
@@ -53,8 +58,10 @@ fn main() {
let bounds = Bounds::centered(None, size(px(1180.), px(760.)), cx);
// macOS:隐藏系统标题栏、内容顶到窗顶,traffic light 悬浮在侧栏上;
- // Linux:标准服务端装饰(appears_transparent 仅 macOS/Windows 生效;
- // GNOME Wayland 不给 SSD 时暂无标题栏,已知限制,实机验收后再定 CSD)。
+ // Linux/Windows:标准系统标题栏(appears_transparent=false)。Windows
+ // 后端按此保留原生 caption(min/max/close、snap layouts、深色模式随
+ // 系统由 gpui 设 DWMWA_USE_IMMERSIVE_DARK_MODE),title 即窗名;
+ // GNOME Wayland 不给 SSD 时回落 CSD,见 window_decorations 注释。
// cfg! 而非 #[cfg]:两支在任一平台都参与类型检查,别让另一支只有 CI 见得到
let titlebar = if cfg!(target_os = "macos") {
TitlebarOptions {
@@ -82,7 +89,8 @@ fn main() {
// workbench 又按 Server 不挂 TitleBar,彻底没有关窗/拖拽面。
// 请求 Client 后:Wayland 全家走 CSD(TitleBar 补位),X11 侧
// gpui 探测 compositor 不支持 CSD 时仍自动回报 Server(WM 标题
- // 栏照常、TitleBar 不挂),macOS 忽略此字段
+ // 栏照常、TitleBar 不挂),macOS/Windows 忽略此字段(Windows
+ // 后端不实现 request_decorations,runtime 恒报 Server)
window_decorations: Some(WindowDecorations::Client),
..Default::default()
},
diff --git a/crates/wake/src/ui.rs b/crates/wake/src/ui.rs
index 2db104f..c17406a 100644
--- a/crates/wake/src/ui.rs
+++ b/crates/wake/src/ui.rs
@@ -25,14 +25,25 @@ pub const FONT_MSG_BODY: Pixels = px(13.);
pub const FONT_MSG_THINKING: Pixels = px(11.5);
// ---------------- 平台文案 ----------------
-// 同一处 UI 在不同平台叫不同名字/键(Finder vs 文件管理器、⌘ vs Ctrl),
-// 文案引用这里的常量,别在 render 里散落字面量。cfg! 表达式让两支在任一
-// 平台都过类型检查(名词与 wake-core terminal 的平台实现对应:macos=Finder)。
-
-pub const SHOW_IN_FM: &str =
- if cfg!(target_os = "macos") { "Show in Finder" } else { "Show in File Manager" };
-pub const REVEAL_IN_FM: &str =
- if cfg!(target_os = "macos") { "Reveal in Finder" } else { "Reveal in File Manager" };
+// 同一处 UI 在不同平台叫不同名字/键(Finder vs File Explorer vs 文件管理器、
+// ⌘ vs Ctrl),文案引用这里的常量,别在 render 里散落字面量。cfg! 表达式让
+// 各支在任一平台都过类型检查(名词与 wake-core terminal 的平台实现对应:
+// macos=Finder,windows=资源管理器官方英文名 File Explorer)。
+
+pub const SHOW_IN_FM: &str = if cfg!(target_os = "macos") {
+ "Show in Finder"
+} else if cfg!(target_os = "windows") {
+ "Show in File Explorer"
+} else {
+ "Show in File Manager"
+};
+pub const REVEAL_IN_FM: &str = if cfg!(target_os = "macos") {
+ "Reveal in Finder"
+} else if cfg!(target_os = "windows") {
+ "Reveal in File Explorer"
+} else {
+ "Reveal in File Manager"
+};
/// ⌘K 面板的唯一绑定串——main.rs 的 bind_keys 与下方徽标同源,改键只动这里
pub const SEARCH_KEYSTROKE: &str = "secondary-k";
diff --git a/crates/wake/src/workbench.rs b/crates/wake/src/workbench.rs
index 7e70952..bab88f0 100644
--- a/crates/wake/src/workbench.rs
+++ b/crates/wake/src/workbench.rs
@@ -1262,12 +1262,16 @@ impl Workbench {
cx: &mut Context<Self>,
) -> bool {
let expanded = expand_tilde(raw_text.trim());
- let path = if expanded.len() > 1 {
- expanded.trim_end_matches('/').to_string()
+ // 尾分隔符归一(展示与重叠判定都吃这份);裸根("/"、"C:\")剪完会
+ // 失去绝对性,原样保留。is_absolute 三端同判据——starts_with('/')
+ // 会把所有 Windows 盘符路径误拒
+ let trimmed = expanded.trim_end_matches(std::path::is_separator);
+ let path = if std::path::Path::new(trimmed).is_absolute() {
+ trimmed.to_string()
} else {
expanded
};
- if path.is_empty() || !path.starts_with('/') {
+ if path.is_empty() || !std::path::Path::new(&path).is_absolute() {
window.push_notification(Notification::warning("Enter an absolute folder path"), cx);
return false;
}
@@ -2123,11 +2127,13 @@ impl Workbench {
None
};
- // macOS 恒挂 TitleBar(traffic light 占位 + 拖拽区);Linux 按运行时装饰
- // 状态:系统给了标题栏(Server)就不挂——TitleBar 的 Linux 实现无条件画
- // min/max/close 三按钮,会与系统标题栏成双套控制;系统不给(GNOME
- // Wayland 无 SSD 回落 Client)才挂,此时它是唯一的拖拽区与窗口按钮
- // (按钮图标 window-*.svg 在 assets 注册表,缺了就是隐形热区)
+ // macOS 恒挂 TitleBar(traffic light 占位 + 拖拽区);Linux/Windows 按
+ // 运行时装饰状态:系统给了标题栏(Server)就不挂——TitleBar 的非 mac
+ // 实现无条件画 min/max/close 三按钮,会与系统标题栏成双套控制;系统
+ // 不给(GNOME Wayland 无 SSD 回落 Client)才挂,此时它是唯一的拖拽区
+ // 与窗口按钮(按钮图标 window-*.svg 在 assets 注册表,缺了就是隐形
+ // 热区)。Windows 走 appears_transparent=false 的原生 caption,装饰
+ // 恒报 Server,这里天然不挂。
let show_titlebar = cfg!(target_os = "macos")
|| matches!(window.window_decorations(), Decorations::Client { .. });
v_flex()
diff --git a/scripts/make-windows.ps1 b/scripts/make-windows.ps1
new file mode 100644
index 0000000..e5b098e
--- /dev/null
+++ b/scripts/make-windows.ps1
@@ -0,0 +1,34 @@
+# 构建 Windows 发行产物:release 二进制(图标/版本资源由 build.rs 嵌入)
+# 打成 zip。在 Windows 上跑(CI 或本机);macOS/Linux 打包各走
+# make-app.sh / make-linux.sh,互不认识对方的产物。
+# 用法: powershell -ExecutionPolicy Bypass -File scripts/make-windows.ps1
+#
+# assets/icon.ico 由 icon.svg 预生成入库,改了 SVG 后再生成(任一平台):
+# rsvg-convert -w 1024 -h 1024 crates/wake/assets/icon.svg -o /tmp/icon-1024.png
+# python3 -c "from PIL import Image; Image.open('/tmp/icon-1024.png').convert('RGBA').save(
+# 'crates/wake/assets/icon.ico', sizes=[(16,16),(24,24),(32,32),(48,48),(64,64),(128,128),(256,256)])"
+
+$ErrorActionPreference = "Stop"
+Set-Location (Join-Path $PSScriptRoot "..")
+
+$version = (Select-String -Path Cargo.toml -Pattern '^version = "(.*)"').Matches[0].Groups[1].Value
+$arch = if ($env:PROCESSOR_ARCHITECTURE -eq "ARM64") { "arm64" } else { "x86_64" }
+$targetDir = if ($env:CARGO_TARGET_DIR) { $env:CARGO_TARGET_DIR } else { "target" }
+
+cargo build --release -p wake
+if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
+
+# 二进制名 Wake.exe 来自 [[bin]](macOS 菜单栏取进程名所需);Windows 惯例
+# 首字母大写正好同形,不再改名
+$stageRoot = Join-Path ([System.IO.Path]::GetTempPath()) "wake-stage"
+$stage = Join-Path $stageRoot "wake-$version-windows-$arch"
+if (Test-Path $stage) { Remove-Item -Recurse -Force $stage }
+New-Item -ItemType Directory -Path $stage -Force | Out-Null
+Copy-Item (Join-Path $targetDir "release/Wake.exe") (Join-Path $stage "Wake.exe")
+
+New-Item -ItemType Directory -Path dist -Force | Out-Null
+$zip = "dist/wake-$version-windows-$arch.zip"
+if (Test-Path $zip) { Remove-Item -Force $zip }
+Compress-Archive -Path $stage -DestinationPath $zip
+
+Get-Item $zip | ForEach-Object { "{0} ({1:N1} MB)" -f $_.FullName, ($_.Length / 1MB) }