Skip to content

Commit f2acced

Browse files
Cmochanceclaude
andauthored
chore(login): a11y aria-label on cancel button + bound mac PATH probe (#31)
Two small UX/perf fixes flagged by the local 3-agent reviews on PR #27 and PR #29: - Login button now sets `aria-label` reflecting its dual role: "Log into <profile>" when idle, "Cancel login for <profile>" while a login is in flight. The visible label was already updated (spinner + red "取消") and the `title` attribute carried the cancel hint, but many screen readers prefer aria-label and ignore title; this makes the dual semantics announced consistently across assistive tech. New i18n keys `profileLoginCancelAria` / `profileLoginReadyAria` (en + zh-CN). - mac `suggested_codex_cli_paths` walked the entire `PATH` and stat'd `<entry>/codex` for every component, blocking the `get_codex_cli_status` Tauri command for seconds when PATH includes NFS / SMB / slow drives. Now bounded by a 500 ms soft deadline: fixed locations (Codex.app bundle, Homebrew, npm-global, etc) are checked first since those are guaranteed-fast local stats, then the bounded PATH walk fills in whatever remaining suggestions fit in the deadline. Worst case: dialog still opens promptly even on a pathologically slow PATH. Both are pure refinements — no behavior change on the happy path. Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
1 parent c3fa8ef commit f2acced

3 files changed

Lines changed: 22 additions & 0 deletions

File tree

src-tauri/mac/runtime/process.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,15 @@ impl CodexPathResolver for MacosCodexPathResolver {
254254
}
255255
}
256256

257+
/// Soft cap on how long the PATH walk can spend stat'ing entries
258+
/// before we bail and return what we have. Each `is_file` probe blocks
259+
/// the Tauri command thread; an NFS / SMB entry on PATH can stall for
260+
/// seconds. Fixed locations (Codex.app bundle, Homebrew, /usr/local,
261+
/// npm-global / bun / volta) are checked first because they're
262+
/// guaranteed-fast local stats — by the time we hit the bounded PATH
263+
/// walk we've usually already collected the realistic candidates.
264+
const PATH_PROBE_DEADLINE: Duration = Duration::from_millis(500);
265+
257266
pub fn suggested_codex_cli_paths(codex_home: Option<&Path>) -> Vec<PathBuf> {
258267
let mut suggestions: Vec<PathBuf> = Vec::new();
259268
let managed_shim = codex_home.map(managed_shim_path);
@@ -280,7 +289,11 @@ pub fn suggested_codex_cli_paths(codex_home: Option<&Path>) -> Vec<PathBuf> {
280289
}
281290

282291
if let Some(path) = env::var_os("PATH") {
292+
let deadline = std::time::Instant::now() + PATH_PROBE_DEADLINE;
283293
for entry in env::split_paths(&path) {
294+
if std::time::Instant::now() >= deadline {
295+
break;
296+
}
284297
push(entry.join("codex"));
285298
}
286299
}

src-tauri/shared/front/i18n.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,8 @@ const enMessages = {
210210
"Codex CLI not found. Pick the binary location to continue.",
211211
codexCliRetryLogin: "Save & retry login",
212212
profileLoginCancelHint: "Login in progress — click to cancel",
213+
profileLoginCancelAria: "Cancel login for {profile}",
214+
profileLoginReadyAria: "Log into {profile}",
213215
loginCancelled: "Login cancelled.",
214216
loginCancelFailed: "Failed to cancel login.",
215217
settingsCodexCli: "Codex CLI path",
@@ -429,6 +431,8 @@ const messages: Record<Locale, Messages> = {
429431
codexCliNotFoundToast: "找不到 codex CLI,请先指定它的位置。",
430432
codexCliRetryLogin: "保存并重试登录",
431433
profileLoginCancelHint: "登录进行中,点击取消",
434+
profileLoginCancelAria: "取消 {profile} 的登录",
435+
profileLoginReadyAria: "登录 {profile}",
432436
loginCancelled: "已取消登录。",
433437
loginCancelFailed: "取消登录失败。",
434438
settingsCodexCli: "Codex CLI 路径",

src-tauri/shared/front/render.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,11 @@ export function renderProfiles(
604604
? t(state.locale, "profileLoginDisabled")
605605
: t(state.locale, "profileLoginReady")
606606
}"
607+
aria-label="${
608+
loginRunning
609+
? t(state.locale, "profileLoginCancelAria", { profile: profile.folder_name })
610+
: t(state.locale, "profileLoginReadyAria", { profile: profile.folder_name })
611+
}"
607612
data-login-profile="${profile.folder_name}"
608613
${loginDisabled ? "disabled" : ""}
609614
>

0 commit comments

Comments
 (0)