mirror of
https://github.com/Twigpine/zero.git
synced 2026-11-08 09:49:34 -10:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a9a3e4aeda |
No files matched your search
@@ -731,6 +731,7 @@ func runInteractiveTUIWithSetup(stderr io.Writer, deps appDeps, permissionMode a
|
||||
lastKnownMCPConfig := mcpConfig
|
||||
return deps.runTUI(context.Background(), tui.Options{
|
||||
Cwd: workspaceRoot,
|
||||
Version: version,
|
||||
Theme: theme,
|
||||
SavedTheme: resolved.Preferences.Theme,
|
||||
UserConfigPath: userConfigPath,
|
||||
|
||||
@@ -62,6 +62,7 @@ const dragEdgeScrollStep = 1
|
||||
type model struct {
|
||||
ctx context.Context
|
||||
cwd string
|
||||
appVersion string
|
||||
userCommands []usercommands.Command // file-sourced /commands (.zero/commands)
|
||||
loadSkills func() []skills.Skill // lazy installed-skills loader for /skills + /<skill-name>
|
||||
userConfigPath string
|
||||
@@ -747,6 +748,7 @@ func newModel(ctx context.Context, options Options) model {
|
||||
m := model{
|
||||
ctx: ctx,
|
||||
cwd: cwd,
|
||||
appVersion: strings.TrimSpace(options.Version),
|
||||
swarmDoneAt: map[string]time.Time{},
|
||||
userCommands: loadedUserCommands,
|
||||
loadSkills: options.LoadSkills,
|
||||
|
||||
@@ -22,6 +22,7 @@ import (
|
||||
// Options configures the reusable Zero terminal UI shell.
|
||||
type Options struct {
|
||||
Cwd string
|
||||
Version string // CLI build version, shown on the home screen; empty hides it
|
||||
UserConfigPath string
|
||||
DoctorUserConfigPath string
|
||||
ProjectConfigPath string
|
||||
|
||||
+21
-3
@@ -92,10 +92,14 @@ func (m model) emptyStateLines(width int) []string {
|
||||
// emptyStateExamples seeds the first prompt with a few representative asks.
|
||||
const emptyStateExamples = `Try "explain this codebase" · "fix the failing test" · "add a --json flag"`
|
||||
|
||||
// emptyStateOrientation renders a faint "cwd · branch · model" line for the home
|
||||
// screen, omitting any piece that's unknown. Empty when nothing is known.
|
||||
// emptyStateOrientation renders a faint "version · cwd · branch · model" line
|
||||
// for the home screen, omitting any piece that's unknown. Empty when nothing
|
||||
// is known.
|
||||
func (m model) emptyStateOrientation() string {
|
||||
parts := make([]string, 0, 3)
|
||||
parts := make([]string, 0, 4)
|
||||
if version := displayVersion(m.appVersion); version != "" {
|
||||
parts = append(parts, version)
|
||||
}
|
||||
if cwd := strings.TrimSpace(m.cwd); cwd != "" {
|
||||
parts = append(parts, shortenPath(cwd))
|
||||
}
|
||||
@@ -111,6 +115,20 @@ func (m model) emptyStateOrientation() string {
|
||||
return zeroTheme.faint.Render(strings.Join(parts, " · "))
|
||||
}
|
||||
|
||||
// displayVersion formats the CLI build version for display: numeric releases
|
||||
// gain a "v" prefix (0.2.0 → v0.2.0), anything else (dev, git SHAs) passes
|
||||
// through unchanged. Empty stays empty so unset builds show nothing.
|
||||
func displayVersion(version string) string {
|
||||
version = strings.TrimSpace(version)
|
||||
if version == "" {
|
||||
return ""
|
||||
}
|
||||
if version[0] >= '0' && version[0] <= '9' {
|
||||
return "v" + version
|
||||
}
|
||||
return version
|
||||
}
|
||||
|
||||
func zeroWordmarkLines() []string {
|
||||
lines := make([]string, 0, minInt(len(zeroWordmarkPrefixLines), len(zeroWordmarkOLines)))
|
||||
for index := 0; index < len(zeroWordmarkPrefixLines) && index < len(zeroWordmarkOLines); index++ {
|
||||
|
||||
@@ -21,6 +21,29 @@ func TestEmptyStateShowsBrandAndTaglineOnly(t *testing.T) {
|
||||
assertNotContains(t, view, "fix the failing test in internal/tools")
|
||||
}
|
||||
|
||||
func TestEmptyStateShowsVersion(t *testing.T) {
|
||||
m := newModel(context.Background(), Options{Version: "0.2.0"})
|
||||
m.width, m.height = 100, 30
|
||||
|
||||
view := plainRender(t, m.View())
|
||||
assertContains(t, view, "v0.2.0")
|
||||
}
|
||||
|
||||
func TestDisplayVersion(t *testing.T) {
|
||||
cases := []struct{ in, want string }{
|
||||
{"0.2.0", "v0.2.0"},
|
||||
{"v0.2.0", "v0.2.0"},
|
||||
{"dev", "dev"},
|
||||
{" ", ""},
|
||||
{"", ""},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
if got := displayVersion(tc.in); got != tc.want {
|
||||
t.Fatalf("displayVersion(%q) = %q, want %q", tc.in, got, tc.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestEmptyStateDisappearsAfterFirstRow(t *testing.T) {
|
||||
m := newModel(context.Background(), Options{})
|
||||
m.width, m.height = 100, 30
|
||||
|
||||
Reference in new issue
Block a user