Show startup timing in History
Measure GUI startup from the beginning of Run until the main view has loaded its store and is ready to build the History model. Insert the measurement as the first in-memory History event using the existing RunRecord display path: Application / Started / Startup completed in <duration>. This keeps startup diagnostics visible in the UI without creating a separate application log file. No scheduler, storage, or command log behavior is changed.
This commit is contained in:
+5
-3
@@ -31,6 +31,7 @@ type job = core.Job
|
|||||||
type event = core.RunRecord
|
type event = core.RunRecord
|
||||||
|
|
||||||
func Run() {
|
func Run() {
|
||||||
|
started := time.Now()
|
||||||
// A stable app ID lets Fyne persist desktop preferences consistently across
|
// A stable app ID lets Fyne persist desktop preferences consistently across
|
||||||
// launches and gives tray/window integration a predictable identity.
|
// launches and gives tray/window integration a predictable identity.
|
||||||
a := app.NewWithID(appID)
|
a := app.NewWithID(appID)
|
||||||
@@ -39,7 +40,7 @@ func Run() {
|
|||||||
w := a.NewWindow("PySentry " + core.Version)
|
w := a.NewWindow("PySentry " + core.Version)
|
||||||
configureSystemTray(a, w)
|
configureSystemTray(a, w)
|
||||||
w.Resize(fyne.NewSize(1120, 720))
|
w.Resize(fyne.NewSize(1120, 720))
|
||||||
w.SetContent(newMainView(w))
|
w.SetContent(newMainView(w, started))
|
||||||
w.ShowAndRun()
|
w.ShowAndRun()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,12 +75,13 @@ func configureSystemTray(a fyne.App, w fyne.Window) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func newMainView(w fyne.Window) fyne.CanvasObject {
|
func newMainView(w fyne.Window, started time.Time) fyne.CanvasObject {
|
||||||
store, jobs, err := core.OpenStore()
|
store, jobs, err := core.OpenStore()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return container.NewPadded(widget.NewLabel("Failed to load PySentry configuration: " + err.Error()))
|
return container.NewPadded(widget.NewLabel("Failed to load PySentry configuration: " + err.Error()))
|
||||||
}
|
}
|
||||||
events := collectActivity(jobs)
|
startupDuration := time.Since(started).Round(time.Millisecond)
|
||||||
|
events := append([]event{newEvent(0, "Application", "Started", "Startup completed in "+startupDuration.String())}, collectActivity(jobs)...)
|
||||||
|
|
||||||
// The GUI keeps the loaded jobs slice in memory and persists changes after
|
// The GUI keeps the loaded jobs slice in memory and persists changes after
|
||||||
// each edit/run. This keeps the first version responsive and easy to reason
|
// each edit/run. This keeps the first version responsive and easy to reason
|
||||||
|
|||||||
Reference in New Issue
Block a user