qwen-code/packages/desktop-shell/scripts/resolve-log-root.js
易良 27c398c3c8
fix(desktop): read Windows smoke log from LocalAppData (#8381)
* fix(desktop): read Windows smoke log from LocalAppData

* fix(desktop): validate Windows smoke log path

* test(desktop): guard smoke log fallback branch and capture ordering (#8381)

* fix(desktop): cross-check smoke appId against tauri config and fail closed on log rotation (#8381)

* fix(desktop): reset smoke log baseline on truncation and test behavior (#8381)

The Tauri app truncates the log on every startup (main.rs:
fs::write(&log_path, b"")), so the second smoke run on any non-ephemeral
Windows machine always failed with "truncated or rotated".  Reset the
baseline and keep polling instead of aborting.

Extract resolveLogRoot into a tiny module so test-release.js can verify
the platform/env resolution behaviorally rather than regex-matching
source text.  Hoist the duplicated tauri.conf.json parse, add logPath to
the timeout diagnostic, and note the shared-log hermeticity constraint.

* test(desktop): pin stale-log protection wiring in smoke source guard (#8381)

* test(desktop): extract sliceNewLog helper and harden ordering assertion (#8381)

* test(desktop): pin resolveLogRoot and dual readNewLog sites in smoke guard (#8381)

* fix(desktop): log path in smoke errors; warn only on real truncation (#8381)

* fix(desktop): make smoke truncation warning reachable; relax guard regexes (#8381)

* fix(desktop): rebase smoke log baseline on truncation; embed full log on timeout (#8381)

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* fix(desktop): drop dead truncation flags from smoke log reader (#8381)

* fix(desktop): isolate packaged smoke settings

---------

Co-authored-by: qwen-code-ci-bot <qwen-code-ci-bot@users.noreply.github.com>
Co-authored-by: Qwen Code Bot <qwen-code-bot@users.noreply.github.com>
Co-authored-by: Qwen Code <qwen-code@users.noreply.github.com>
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-08-03 11:04:09 +00:00

30 lines
906 B
JavaScript

import path from 'node:path';
export function resolveLogRoot(
platform,
env,
{ isolatedHome, isolatedState, appId },
) {
if (platform === 'darwin') {
return path.join(isolatedHome, 'Library', 'Logs', appId);
}
if (platform === 'win32') {
const localAppData = env.LOCALAPPDATA;
if (!localAppData) {
throw new Error(
'LOCALAPPDATA is required to locate Windows desktop logs.',
);
}
// Tauri resolves app_log_dir() via SHGetKnownFolderPath on Windows,
// ignoring the LOCALAPPDATA env override used on other platforms.
return path.join(localAppData, appId, 'logs');
}
return path.join(isolatedState, appId, 'logs');
}
export function sliceNewLog(contents, previousLog) {
if (!contents.startsWith(previousLog)) {
return { text: contents, baseline: '' };
}
return { text: contents.slice(previousLog.length), baseline: previousLog };
}