mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-02 20:43:36 +00:00
fix: address Gemini code review suggestions
Fixed two critical code quality issues identified in code review: 1. Auth Method Selector - Tailwind CSS Dynamic Classes: - Replaced dynamic class name concatenation with static class mapping - Tailwind JIT compiler requires complete class names at build time - Added getBadgeClasses() helper function with predefined color mappings - Prevents broken styling from unparseable dynamic classes 2. Claude CLI Detector - Async Terminal Detection: - Moved execSync loop to async/await pattern to prevent UI blocking - Refactored Linux terminal detection to run before Promise constructor - Prevents main process freezing during terminal emulator detection - Improves responsiveness on Linux systems Both fixes improve code reliability and user experience.
This commit is contained in:
@@ -611,7 +611,39 @@ class ClaudeCliDetector {
|
||||
}
|
||||
send("Opening system terminal for authentication...\n");
|
||||
|
||||
return await new Promise((resolve, reject) => {
|
||||
// Helper function to check if a command exists asynchronously
|
||||
const commandExists = (cmd) => {
|
||||
return new Promise((resolve) => {
|
||||
require("child_process").exec(
|
||||
`which ${cmd}`,
|
||||
{ timeout: 1000 },
|
||||
(error) => {
|
||||
resolve(!error);
|
||||
}
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
// For Linux, find available terminal first (async)
|
||||
let linuxTerminal = null;
|
||||
if (platform !== "win32" && platform !== "darwin") {
|
||||
const terminals = [
|
||||
["gnome-terminal", ["--", claudePath, "setup-token"]],
|
||||
["konsole", ["-e", claudePath, "setup-token"]],
|
||||
["xterm", ["-e", claudePath, "setup-token"]],
|
||||
["x-terminal-emulator", ["-e", `${claudePath} setup-token`]],
|
||||
];
|
||||
|
||||
for (const [term, termArgs] of terminals) {
|
||||
const exists = await commandExists(term);
|
||||
if (exists) {
|
||||
linuxTerminal = { command: term, args: termArgs };
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
// Open command in external terminal since Claude CLI requires TTY
|
||||
let command, args;
|
||||
|
||||
@@ -629,27 +661,8 @@ class ClaudeCliDetector {
|
||||
'tell application "Terminal" to activate',
|
||||
];
|
||||
} else {
|
||||
// Linux: Try common terminal emulators
|
||||
const terminals = [
|
||||
["gnome-terminal", ["--", claudePath, "setup-token"]],
|
||||
["konsole", ["-e", claudePath, "setup-token"]],
|
||||
["xterm", ["-e", claudePath, "setup-token"]],
|
||||
["x-terminal-emulator", ["-e", `${claudePath} setup-token`]],
|
||||
];
|
||||
|
||||
// Try to find an available terminal
|
||||
for (const [term, termArgs] of terminals) {
|
||||
try {
|
||||
execSync(`which ${term}`, { stdio: "ignore" });
|
||||
command = term;
|
||||
args = termArgs;
|
||||
break;
|
||||
} catch {
|
||||
// Terminal not found, try next
|
||||
}
|
||||
}
|
||||
|
||||
if (!command) {
|
||||
// Linux: Use the terminal we found earlier
|
||||
if (!linuxTerminal) {
|
||||
reject({
|
||||
success: false,
|
||||
error:
|
||||
@@ -658,6 +671,8 @@ class ClaudeCliDetector {
|
||||
});
|
||||
return;
|
||||
}
|
||||
command = linuxTerminal.command;
|
||||
args = linuxTerminal.args;
|
||||
}
|
||||
|
||||
console.log(
|
||||
|
||||
Reference in New Issue
Block a user