-
Notifications
You must be signed in to change notification settings - Fork 496
feat: experimental k9s inspired TUI #1533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
536ac09
0a4e80f
6a315d8
cba11df
17e69f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -11,6 +11,7 @@ import ( | |||||||||||
|
|
||||||||||||
| commonexec "github.com/kagent-dev/kagent/go/core/cli/internal/common/exec" | ||||||||||||
| "github.com/kagent-dev/kagent/go/core/cli/internal/config" | ||||||||||||
| experimentaltui "github.com/kagent-dev/kagent/go/core/cli/internal/experimental_tui" | ||||||||||||
| "github.com/kagent-dev/kagent/go/core/cli/internal/tui" | ||||||||||||
| a2aclient "trpc.group/trpc-go/trpc-a2a-go/client" | ||||||||||||
| "trpc.group/trpc-go/trpc-a2a-go/protocol" | ||||||||||||
|
|
@@ -186,3 +187,8 @@ func waitForAgent(ctx context.Context, agentURL string, timeout time.Duration) e | |||||||||||
| } | ||||||||||||
| } | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| func RunExperimentalTUI(ctx context.Context, cfg *RunCfg) error { | ||||||||||||
| experimentaltui.Run() | ||||||||||||
| return nil | ||||||||||||
| } | ||||||||||||
|
Comment on lines
+192
to
+194
|
||||||||||||
| experimentaltui.Run() | |
| return nil | |
| } | |
| return experimentaltui.Run() | |
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| package experimentaltui | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "os" | ||
|
|
||
| tea "github.com/charmbracelet/bubbletea" | ||
| "github.com/kagent-dev/kagent/go/core/cli/internal/experimental_tui/domain" | ||
| "github.com/kagent-dev/kagent/go/core/cli/internal/experimental_tui/screen" | ||
| ) | ||
|
|
||
| var demoAgents = []domain.Agent{ | ||
| {ID: "1", Name: "Agent Alpha hogehogehogehogehogehogehogehogehogehoge", Status: domain.AgentStatusRunning, Provider: NewDemoProvider()}, | ||
| {ID: "2", Name: "Agent Beta", Status: domain.AgentStatusError, Provider: NewDemoProvider()}, | ||
| {ID: "3", Name: "Agent Gamma", Status: domain.AgentStatusFinished, Provider: NewDemoProvider()}, | ||
| {ID: "4", Name: "Agent Delta", Status: domain.AgentStatusStopped, Provider: NewDemoProvider()}, | ||
| } | ||
|
|
||
| func Run() error { | ||
| m := screen.NewRootModel(screen.NewAgentListModel(demoAgents)) | ||
|
|
||
| p := tea.NewProgram(m) | ||
| if _, err := p.Run(); err != nil { | ||
| fmt.Printf("Error running program: %v", err) | ||
| os.Exit(1) | ||
| } | ||
|
Comment on lines
+19
to
+26
|
||
|
|
||
| return nil | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| package component | ||
|
|
||
| import ( | ||
|
Comment on lines
+1
to
+3
|
||
| "fmt" | ||
| "strings" | ||
|
|
||
| "github.com/charmbracelet/lipgloss" | ||
| "github.com/kagent-dev/kagent/go/core/cli/internal/tui/theme" | ||
| ) | ||
|
|
||
| func RenderUsageGauge(rate float64, width int) string { | ||
| if rate < 0 { | ||
| rate = 0 | ||
| } else if rate > 1 { | ||
| rate = 1 | ||
| } | ||
|
|
||
| filledWidth := int(rate * float64(width)) | ||
| emptyWidth := width - filledWidth | ||
|
|
||
| barColor := theme.ColorPrimary | ||
|
|
||
| filled := lipgloss.NewStyle().Foreground(barColor).Render(strings.Repeat("■", filledWidth)) | ||
| empty := lipgloss.NewStyle().Foreground(theme.ColorBorder).Render(strings.Repeat("■", emptyWidth)) | ||
|
|
||
| return fmt.Sprintf("[%s%s] %3.0f%%", filled, empty, rate*100) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package component | ||
|
|
||
| import ( | ||
| "strings" | ||
|
|
||
| "github.com/charmbracelet/lipgloss" | ||
| "github.com/kagent-dev/kagent/go/core/cli/internal/experimental_tui/domain" | ||
| ) | ||
|
|
||
| var baseStatusStyle = lipgloss.NewStyle(). | ||
| Bold(true). | ||
| Padding(0, 1) | ||
|
|
||
| func RenderStatusBadge(status domain.AgentStatus) string { | ||
| text := strings.ToUpper(string(status)) | ||
|
|
||
| return text | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR description says this command is a "hidden experimental-tui command", but the implementation conditionally registers it only when
ENVIRONMENT == local. If the intent is "hidden but available", prefer always registering the command and marking it hidden via Cobra (e.g.,Hidden: true) rather than gating it behind an environment variable.