using AxCopilot.Handlers;
using AxCopilot.Services;
namespace AxCopilot.ViewModels;
///
/// Phase L3-9: 런처 하단 미니 위젯 데이터 바인딩 프로퍼티.
/// LauncherWindow.Widgets.cs의 타이머에서 UpdateWidgets()를 호출합니다.
///
public partial class LauncherViewModel
{
// ─── 시스템 모니터 ────────────────────────────────────────────────────────
/// 위젯 텍스트 예: "CPU 34% RAM 62% C:42%"
public string Widget_PerfText
{
get
{
var p = PerformanceMonitorService.Instance;
return $"CPU {p.CpuPercent:F0}% RAM {p.RamPercent:F0}% {p.DiskCText}";
}
}
// ─── 뽀모도로 ─────────────────────────────────────────────────────────────
/// 위젯 텍스트 예: "집중 18:42" / "휴식 04:58" / "대기 25:00"
public string Widget_PomoText
{
get
{
var p = PomodoroService.Instance;
var rem = p.Remaining;
var timeStr = $"{(int)rem.TotalMinutes:D2}:{rem.Seconds:D2}";
return p.Mode switch
{
PomodoroMode.Focus => $"집중 {timeStr}",
PomodoroMode.Break => $"휴식 {timeStr}",
_ => $"대기 {timeStr}",
};
}
}
/// 뽀모도로 실행 중이면 true → 위젯 색상 강조에 사용
public bool Widget_PomoRunning => PomodoroService.Instance.IsRunning;
// ─── 빠른 메모 ────────────────────────────────────────────────────────────
private int _noteCount;
/// 위젯 텍스트 예: "메모 3건" / "메모 없음"
public string Widget_NoteText => _noteCount > 0 ? $"메모 {_noteCount}건" : "메모 없음";
// ─── 서버 상태 ────────────────────────────────────────────────────────────
public bool Widget_OllamaOnline => ServerStatusService.Instance.OllamaOnline;
public bool Widget_LlmOnline => ServerStatusService.Instance.LlmOnline;
public bool Widget_McpOnline => ServerStatusService.Instance.McpOnline;
public string Widget_McpName => ServerStatusService.Instance.McpName;
// ─── 갱신 메서드 ──────────────────────────────────────────────────────────
/// 1초마다 LauncherWindow.Widgets.cs에서 호출 — UI 바인딩 갱신.
public void UpdateWidgets()
{
// 메모 건수 갱신 (파일 I/O 최소화: 5회마다 1회만)
_widgetRefreshTick++;
if (_widgetRefreshTick % 5 == 0)
_noteCount = NoteHandler.GetNoteCount();
OnPropertyChanged(nameof(Widget_PerfText));
OnPropertyChanged(nameof(Widget_PomoText));
OnPropertyChanged(nameof(Widget_PomoRunning));
OnPropertyChanged(nameof(Widget_NoteText));
OnPropertyChanged(nameof(Widget_OllamaOnline));
OnPropertyChanged(nameof(Widget_LlmOnline));
OnPropertyChanged(nameof(Widget_McpOnline));
OnPropertyChanged(nameof(Widget_McpName));
}
private int _widgetRefreshTick;
}