detached 1030ae5

Hide /jail when sandbox is already jailed

/jail and /unjail are mutually exclusive actions, so only show the
one that actually applies in the current state.
commit
1030ae584dd090f76e8de9a8ef58c54ee2e5c1cb
author
patriceckhart · · 2026-05-11 16:11 UTC
parent
21b88f6
signature
unsigned
refs
tag: v0.1.76
2 files · +9 -2
M internal/agent/modes/slash_suggest.go +3 -2
@@ -121,12 +121,13 @@ func (s *slashSuggester) allCatalog() []slashCommand {
121121 // baseCatalog returns the built-in commands visible for the current
122122 // interactive state.
123123 func (s *slashSuggester) baseCatalog() []slashCommand {
124+ hide := "/unjail"
124125 if s.jailed {
125- return slashCatalog
126+ hide = "/jail"
126127 }
127128 out := make([]slashCommand, 0, len(slashCatalog)-1)
128129 for _, c := range slashCatalog {
129- if c.Name == "/unjail" {
130+ if c.Name == hide {
130131 continue
131132 }
132133 out = append(out, c)
@@ -121,12 +121,13 @@ func (s *slashSuggester) allCatalog() []slashCommand {
121 // baseCatalog returns the built-in commands visible for the current121 // baseCatalog returns the built-in commands visible for the current
122 // interactive state.122 // interactive state.
123 func (s *slashSuggester) baseCatalog() []slashCommand {123 func (s *slashSuggester) baseCatalog() []slashCommand {
124+ hide := "/unjail"
124 if s.jailed {125 if s.jailed {
125- return slashCatalog126+ hide = "/jail"
126 }127 }
127 out := make([]slashCommand, 0, len(slashCatalog)-1)128 out := make([]slashCommand, 0, len(slashCatalog)-1)
128 for _, c := range slashCatalog {129 for _, c := range slashCatalog {
129- if c.Name == "/unjail" {130+ if c.Name == hide {
130 continue131 continue
131 }132 }
132 out = append(out, c)133 out = append(out, c)
M internal/agent/modes/slash_suggest_test.go +6 -0
@@ -8,11 +8,17 @@ func TestSlashSuggesterHidesUnjailUntilJailed(t *testing.T) {
88 if got := commandNames(s.matches("/unj")); contains(got, "/unjail") {
99 t.Fatalf("/unjail should be hidden while not jailed, got %v", got)
1010 }
11+ if got := commandNames(s.matches("/ja")); !contains(got, "/jail") {
12+ t.Fatalf("/jail should be visible while not jailed, got %v", got)
13+ }
1114
1215 s.SetJailed(true)
1316 if got := commandNames(s.matches("/unj")); !contains(got, "/unjail") {
1417 t.Fatalf("/unjail should be visible while jailed, got %v", got)
1518 }
19+ if got := commandNames(s.matches("/ja")); contains(got, "/jail") {
20+ t.Fatalf("/jail should be hidden while jailed, got %v", got)
21+ }
1622 }
1723
1824 func commandNames(cmds []slashCommand) []string {
@@ -8,11 +8,17 @@ func TestSlashSuggesterHidesUnjailUntilJailed(t *testing.T) {
8 if got := commandNames(s.matches("/unj")); contains(got, "/unjail") {8 if got := commandNames(s.matches("/unj")); contains(got, "/unjail") {
9 t.Fatalf("/unjail should be hidden while not jailed, got %v", got)9 t.Fatalf("/unjail should be hidden while not jailed, got %v", got)
10 }10 }
11+ if got := commandNames(s.matches("/ja")); !contains(got, "/jail") {
12+ t.Fatalf("/jail should be visible while not jailed, got %v", got)
13+ }
11 14
12 s.SetJailed(true)15 s.SetJailed(true)
13 if got := commandNames(s.matches("/unj")); !contains(got, "/unjail") {16 if got := commandNames(s.matches("/unj")); !contains(got, "/unjail") {
14 t.Fatalf("/unjail should be visible while jailed, got %v", got)17 t.Fatalf("/unjail should be visible while jailed, got %v", got)
15 }18 }
19+ if got := commandNames(s.matches("/ja")); contains(got, "/jail") {
20+ t.Fatalf("/jail should be hidden while jailed, got %v", got)
21+ }
16 }22 }
17 23
18 func commandNames(cmds []slashCommand) []string {24 func commandNames(cmds []slashCommand) []string {

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 476

↑↓ moveenter openesc close