Add context-aware items to the command palette
When opened with Ctrl-K, the palette now prepends entries for whatever is currently focused: - Focused scratchpad: Delete / Rename (inline form) / Edit (fire-and- forget zed launch with stdio detached so the TUI is not suspended). - Focused agent: Rename (inline form) / Close. - Focused process: Rename / Delete (drops the entry; SIGKILL if alive) / Stop (SIGTERM, keep entry) / Restart (same argv). The rename UX is a single-field inline form that mirrors the existing spawn-process form, so the modal-input contract is unchanged. scratchpad.Store grows Delete / Rename / Path so the palette can act on a pad file by name. focusedPad is plumbed onto uiState ahead of the scratchpad-focus UI work; until that lands it stays empty and the scratchpad-context entries simply never surface. Tested with palette_context_test.go and a new rename_process_via_palette harness scenario.
This commit is contained in:
@@ -7,7 +7,7 @@ import (
|
||||
)
|
||||
|
||||
func newTestPalette() *paletteState {
|
||||
return newPalette(nil, "", preset.Set{})
|
||||
return newPalette(nil, "", "", preset.Set{})
|
||||
}
|
||||
|
||||
func TestPaletteIgnoresKittyReleaseEvent(t *testing.T) {
|
||||
@@ -49,7 +49,7 @@ func TestPaletteBareEscCancels(t *testing.T) {
|
||||
|
||||
func TestPaletteKittyArrowsNavigate(t *testing.T) {
|
||||
pr := []*preset.Preset{{Name: "a"}, {Name: "b"}, {Name: "c"}}
|
||||
p := newPalette(nil, "", preset.Set{Agents: pr})
|
||||
p := newPalette(nil, "", "", preset.Set{Agents: pr})
|
||||
if p.cursor != 0 {
|
||||
t.Fatalf("initial cursor %d", p.cursor)
|
||||
}
|
||||
@@ -70,7 +70,7 @@ func TestPaletteKittyArrowsNavigate(t *testing.T) {
|
||||
|
||||
func TestPaletteLegacyArrowsStillWork(t *testing.T) {
|
||||
pr := []*preset.Preset{{Name: "a"}, {Name: "b"}}
|
||||
p := newPalette(nil, "", preset.Set{Agents: pr})
|
||||
p := newPalette(nil, "", "", preset.Set{Agents: pr})
|
||||
_, _, adv := p.handleInput([]byte("\x1b[B"), 0)
|
||||
if adv != 3 {
|
||||
t.Fatalf("advance %d", adv)
|
||||
@@ -82,7 +82,7 @@ func TestPaletteLegacyArrowsStillWork(t *testing.T) {
|
||||
|
||||
func TestPaletteKittyEnterAccepts(t *testing.T) {
|
||||
pr := []*preset.Preset{{Name: "x"}}
|
||||
p := newPalette(nil, "", preset.Set{Agents: pr})
|
||||
p := newPalette(nil, "", "", preset.Set{Agents: pr})
|
||||
action, done, _ := p.handleInput([]byte("\x1b[13u"), 0)
|
||||
if !done || action.kind != "spawn-agent" {
|
||||
t.Fatalf("Enter via CSI u didn't accept: action=%+v done=%v", action, done)
|
||||
@@ -112,7 +112,7 @@ func TestPaletteLegacyPrintableTypes(t *testing.T) {
|
||||
// non-empty command line emits the submit action with relaunch reflecting
|
||||
// the checkbox state.
|
||||
func TestPaletteSpawnProcessFormFlow(t *testing.T) {
|
||||
p := newPalette(nil, "", preset.Set{})
|
||||
p := newPalette(nil, "", "", preset.Set{})
|
||||
// The "Spawn process…" entry is the only non-Quit item with an
|
||||
// empty preset list. Locate its index by scanning items.
|
||||
idx := -1
|
||||
@@ -165,7 +165,7 @@ func TestPaletteSpawnProcessFormFlow(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPaletteSpawnProcessFormEmptyCommandCancels(t *testing.T) {
|
||||
p := newPalette(nil, "", preset.Set{})
|
||||
p := newPalette(nil, "", "", preset.Set{})
|
||||
p.mode = paletteModeSpawnForm
|
||||
p.form = &spawnProcessForm{}
|
||||
action, done, _ := p.handleInput([]byte("\r"), 0)
|
||||
@@ -175,7 +175,7 @@ func TestPaletteSpawnProcessFormEmptyCommandCancels(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPaletteSpawnProcessFormEscCancels(t *testing.T) {
|
||||
p := newPalette(nil, "", preset.Set{})
|
||||
p := newPalette(nil, "", "", preset.Set{})
|
||||
p.mode = paletteModeSpawnForm
|
||||
p.form = &spawnProcessForm{cmd: []rune("x")}
|
||||
action, done, _ := p.handleInput([]byte{0x1b}, 0)
|
||||
|
||||
Reference in New Issue
Block a user