File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -59,13 +59,18 @@ func psTable(ps []desktop.BackendStatus) string {
5959 modelName = stripDefaultsFromModelName (modelName )
6060 }
6161
62- lastUsed := "in use"
63- if ! status .LastUsed .IsZero () {
62+ var lastUsed string
63+ if status .InUse {
64+ lastUsed = "in use"
65+ } else if ! status .LastUsed .IsZero () {
6466 duration := time .Since (status .LastUsed )
6567 if duration < 0 {
6668 duration = 0
6769 }
6870 lastUsed = units .HumanDuration (duration ) + " ago"
71+ } else {
72+ // This case should not happen if InUse is properly set, but fallback to "in use" for zero time
73+ lastUsed = "in use"
6974 }
7075
7176 table .Append ([]string {
Original file line number Diff line number Diff line change @@ -586,6 +586,8 @@ type BackendStatus struct {
586586 Mode string `json:"mode"`
587587 // LastUsed represents when this backend was last used (if it's idle)
588588 LastUsed time.Time `json:"last_used,omitempty"`
589+ // InUse indicates whether this backend is currently handling a request
590+ InUse bool `json:"in_use,omitempty"`
589591}
590592
591593func (c * Client ) PS () ([]BackendStatus , error ) {
Original file line number Diff line number Diff line change @@ -64,6 +64,8 @@ type BackendStatus struct {
6464 Mode string `json:"mode"`
6565 // LastUsed represents when this (backend, model, mode) tuple was last used
6666 LastUsed time.Time `json:"last_used,omitempty"`
67+ // InUse indicates whether this backend is currently handling a request
68+ InUse bool `json:"in_use,omitempty"`
6769}
6870
6971// DiskUsage represents the disk usage of the models and default backend.
Original file line number Diff line number Diff line change @@ -319,6 +319,7 @@ func (s *Scheduler) getLoaderStatus(ctx context.Context) []BackendStatus {
319319 ModelName : runnerInfo .modelRef ,
320320 Mode : key .mode .String (),
321321 LastUsed : time.Time {},
322+ InUse : s .loader .references [runnerInfo .slot ] > 0 ,
322323 }
323324
324325 if s .loader .references [runnerInfo .slot ] == 0 {
You can’t perform that action at this time.
0 commit comments