Skip to content

mission control for agent skills

Discovery: show scan freshness in the modal

Alvin Unreal5da24ff7a237
diff --git a/internal/tui/helpers.go b/internal/tui/helpers.go
index bff0edb..606bbf8 100644
--- a/internal/tui/helpers.go
+++ b/internal/tui/helpers.go
@@ -3,12 +3,30 @@ package tui
import (
"fmt"
"strings"
+ "time"
"github.com/alvinunreal/lazyskills/internal/compat"
"github.com/charmbracelet/lipgloss"
"github.com/muesli/reflow/wordwrap"
)
+// humanizeSince renders a coarse, git-style relative age ("just now", "5m ago").
+func humanizeSince(t time.Time) string {
+ d := time.Since(t)
+ switch {
+ case d < 5*time.Second:
+ return "just now"
+ case d < time.Minute:
+ return fmt.Sprintf("%ds ago", int(d.Seconds()))
+ case d < time.Hour:
+ return fmt.Sprintf("%dm ago", int(d.Minutes()))
+ case d < 24*time.Hour:
+ return fmt.Sprintf("%dh ago", int(d.Hours()))
+ default:
+ return fmt.Sprintf("%dd ago", int(d.Hours()/24))
+ }
+}
+
func wrap(s string, width int) string {
if width <= 8 || len(s) <= width {
return s
diff --git a/internal/tui/tui.go b/internal/tui/tui.go
index f4f23e1..06b8a60 100644
--- a/internal/tui/tui.go
+++ b/internal/tui/tui.go
@@ -1,10 +1,13 @@
package tui
import (
+ "time"
+
"github.com/charmbracelet/bubbles/viewport"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
+ "github.com/alvinunreal/lazyskills/internal/actions"
"github.com/alvinunreal/lazyskills/internal/model"
"github.com/alvinunreal/lazyskills/internal/runner"
"github.com/alvinunreal/lazyskills/internal/scan"
@@ -43,9 +46,10 @@ type DiscoveredSkill struct {
}
type SourceDiscovery struct {
- Status DiscoveryStatus
- Skills []DiscoveredSkill
- Error string
+ Status DiscoveryStatus
+ Skills []DiscoveredSkill
+ Error string
+ ScannedAt time.Time
}
type appModel struct {
@@ -79,7 +83,8 @@ type appModel struct {
discovery map[string]SourceDiscovery
modalSelected int
modalSource string
- pendingG bool // saw a lone "g"; a second "g" jumps to top
+ pendingG bool // saw a lone "g"; a second "g" jumps to top
+ pendingAction *actions.CommandPreview // action awaiting confirm (decoupled from selection)
}
type paneLayout struct {
diff --git a/internal/tui/tui_test.go b/internal/tui/tui_test.go
index df3c5ee..7a14dd0 100644
--- a/internal/tui/tui_test.go
+++ b/internal/tui/tui_test.go
@@ -7,6 +7,7 @@ import (
"path/filepath"
"strings"
"testing"
+ "time"
"github.com/charmbracelet/bubbles/viewport"
tea "github.com/charmbracelet/bubbletea"
@@ -769,6 +770,38 @@ func TestScopeFilterKeys(t *testing.T) {
}
}
+func TestHumanizeSince(t *testing.T) {
+ now := time.Now()
+ cases := []struct {
+ at time.Time
+ want string
+ }{
+ {now.Add(-2 * time.Second), "just now"},
+ {now.Add(-30 * time.Second), "30s ago"},
+ {now.Add(-5 * time.Minute), "5m ago"},
+ {now.Add(-3 * time.Hour), "3h ago"},
+ {now.Add(-50 * time.Hour), "2d ago"},
+ }
+ for _, c := range cases {
+ if got := humanizeSince(c.at); got != c.want {
+ t.Errorf("humanizeSince(%v) = %q, want %q", c.at, got, c.want)
+ }
+ }
+}
+
+func TestModalShowsScanFreshness(t *testing.T) {
+ m := appModel{width: 120, height: 32, modalSource: "owner/repo", detailModal: true, result: model.ScanResult{Skills: []*model.Skill{
+ {Name: "Existing", Scope: model.ScopeProject, LocalLock: &model.LocalLockEntry{Source: "owner/repo"}},
+ }}}
+ m.discovery = map[string]SourceDiscovery{
+ "owner/repo": {Status: DiscoveryReady, ScannedAt: time.Now().Add(-5 * time.Minute)},
+ }
+ out := strings.Join(m.sourceModalDetailLines(80), "\n")
+ if !strings.Contains(out, "scanned 5m ago") {
+ t.Fatalf("expected scan freshness in modal, got %q", out)
+ }
+}
+
func TestTopBottomJumpKeys(t *testing.T) {
m := appModel{width: 120, height: 32, result: model.ScanResult{Skills: []*model.Skill{
{Name: "One", Scope: model.ScopeProject},
diff --git a/internal/tui/update.go b/internal/tui/update.go
index 3f5b2c6..778e27c 100644
--- a/internal/tui/update.go
+++ b/internal/tui/update.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os/exec"
"strings"
+ "time"
tea "github.com/charmbracelet/bubbletea"
@@ -42,8 +43,9 @@ func (m appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.syncViewport()
case discoveryResultMsg:
disc := SourceDiscovery{
- Status: DiscoveryReady,
- Skills: msg.skills,
+ Status: DiscoveryReady,
+ Skills: msg.skills,
+ ScannedAt: time.Now(),
}
if msg.err != nil {
disc.Status = DiscoveryFailed
diff --git a/internal/tui/view.go b/internal/tui/view.go
index 1d7670a..f887bf4 100644
--- a/internal/tui/view.go
+++ b/internal/tui/view.go
@@ -725,8 +725,12 @@ func (m appModel) sourceModalDetailLines(width int) []string {
lines = append(lines, "")
- lines = append(lines, sectionHeaderStyle.Render("Available Skills:"))
+ availHeader := sectionHeaderStyle.Render("Available Skills:")
disc, ok := m.discovery[groupName]
+ if ok && disc.Status == DiscoveryReady && !disc.ScannedAt.IsZero() {
+ availHeader += " " + dimStyle.Render("scanned "+humanizeSince(disc.ScannedAt))
+ }
+ lines = append(lines, availHeader)
_, _, isRemote := parseRemoteGitHubSource(groupName)
if !ok {
discoverable, reason := m.isSourceDiscoverable(groupName)