Tutta la UI passa in ui.html (WebView2): header, schermata iniziale con suggerimenti, composer a scheda con selettori modello/effort, messaggi aggiunti al DOM senza ricaricare la pagina, pulsanti Copia, attesa animata, tema chiaro/scuro di Windows. Gui.cs diventa un host sottile che dialoga con la pagina via WebMessage. La finestra ha proporzioni 16:10 calcolate sull'area utile dello schermo. Documentazione aggiornata. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
45 lines
1.1 KiB
C#
45 lines
1.1 KiB
C#
using System.Diagnostics;
|
|
using System.Windows.Forms;
|
|
|
|
if (args.Length == 0)
|
|
{
|
|
// WebView2 richiede un thread STA, che i top-level statements non danno
|
|
var ui = new Thread(() =>
|
|
{
|
|
ApplicationConfiguration.Initialize();
|
|
Application.SetColorMode(SystemColorMode.System);
|
|
Application.Run(new Gui());
|
|
});
|
|
ui.SetApartmentState(ApartmentState.STA);
|
|
ui.Start();
|
|
ui.Join();
|
|
return 0;
|
|
}
|
|
|
|
var psi = NewClaude(string.Join(' ', args));
|
|
try
|
|
{
|
|
using var p = Process.Start(psi)!; // stdout/stderr ereditati: streaming in tempo reale
|
|
p.StandardInput.Close();
|
|
p.WaitForExit();
|
|
return p.ExitCode;
|
|
}
|
|
catch (System.ComponentModel.Win32Exception)
|
|
{
|
|
Console.Error.WriteLine("'claude' non trovato nel PATH.");
|
|
return 127;
|
|
}
|
|
|
|
static ProcessStartInfo NewClaude(string prompt)
|
|
{
|
|
var psi = new ProcessStartInfo("claude")
|
|
{
|
|
WorkingDirectory = AppContext.BaseDirectory,
|
|
UseShellExecute = false,
|
|
RedirectStandardInput = true, // evita l'attesa di stdin di claude
|
|
};
|
|
psi.ArgumentList.Add("-p");
|
|
psi.ArgumentList.Add(prompt);
|
|
return psi;
|
|
}
|