detached 4b56f28

test(tabs): tighten rename tab persistence coverage

commit
4b56f28eb5eeda59fdb919e6d1d445250a6addb9
author
brice · · 2026-07-04 02:10 UTC
parent
2112549
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
2 files · +10 -1
M internal/usecase/daemon/session.go +3 -0
@@ -222,6 +222,9 @@ func (d *Daemon) createTab(sess *session, sz domain.Size) error {
222222 if err := d.persist.Save(record); err != nil {
223223 sess.tabs = sess.tabs[:len(sess.tabs)-1]
224224 sess.active = oldActive
225+ if tb.cancel != nil {
226+ tb.cancel()
227+ }
225228 sess.mu.Unlock()
226229 d.mu.Unlock()
227230 _ = pty.Close()
@@ -222,6 +222,9 @@ func (d *Daemon) createTab(sess *session, sz domain.Size) error {
222 if err := d.persist.Save(record); err != nil {222 if err := d.persist.Save(record); err != nil {
223 sess.tabs = sess.tabs[:len(sess.tabs)-1]223 sess.tabs = sess.tabs[:len(sess.tabs)-1]
224 sess.active = oldActive224 sess.active = oldActive
225+ if tb.cancel != nil {
226+ tb.cancel()
227+ }
225 sess.mu.Unlock()228 sess.mu.Unlock()
226 d.mu.Unlock()229 d.mu.Unlock()
227 _ = pty.Close()230 _ = pty.Close()
M internal/usecase/daemon/session_test.go +7 -1
@@ -693,7 +693,12 @@ func TestRenameTabPersistsForNamedSession(t *testing.T) {
693693
694694 records, err := d.persist.LoadAll()
695695 require.NoError(t, err)
696- require.Equal(t, []persist.Record{{Name: "work", Cwd: "/tmp/work", CreatedAt: sess.createdAt, UpdatedAt: records[0].UpdatedAt, TabNames: []string{"shell"}}}, records)
696+ require.Len(t, records, 1)
697+ require.Equal(t, "work", records[0].Name)
698+ require.Equal(t, "/tmp/work", records[0].Cwd)
699+ require.Equal(t, sess.createdAt, records[0].CreatedAt)
700+ require.GreaterOrEqual(t, records[0].UpdatedAt, records[0].CreatedAt)
701+ require.Equal(t, []string{"shell"}, records[0].TabNames)
697702 }
698703
699704 func TestRenameTabDoesNotPersistForEphemeralSession(t *testing.T) {
@@ -707,6 +712,7 @@ func TestRenameTabDoesNotPersistForEphemeralSession(t *testing.T) {
707712 sess, err := d.createSessionLocked("0", true, "/tmp/work", sz, nil)
708713 require.NoError(t, err)
709714 require.NoError(t, d.renameTab(sess, sess.tabs[0], "shell"))
715+ require.Equal(t, "shell", sess.tabs[0].name)
710716
711717 require.False(t, state.has("0"))
712718 records, err := d.persist.LoadAll()
@@ -693,7 +693,12 @@ func TestRenameTabPersistsForNamedSession(t *testing.T) {
693 693
694 records, err := d.persist.LoadAll()694 records, err := d.persist.LoadAll()
695 require.NoError(t, err)695 require.NoError(t, err)
696- require.Equal(t, []persist.Record{{Name: "work", Cwd: "/tmp/work", CreatedAt: sess.createdAt, UpdatedAt: records[0].UpdatedAt, TabNames: []string{"shell"}}}, records)696+ require.Len(t, records, 1)
697+ require.Equal(t, "work", records[0].Name)
698+ require.Equal(t, "/tmp/work", records[0].Cwd)
699+ require.Equal(t, sess.createdAt, records[0].CreatedAt)
700+ require.GreaterOrEqual(t, records[0].UpdatedAt, records[0].CreatedAt)
701+ require.Equal(t, []string{"shell"}, records[0].TabNames)
697 }702 }
698 703
699 func TestRenameTabDoesNotPersistForEphemeralSession(t *testing.T) {704 func TestRenameTabDoesNotPersistForEphemeralSession(t *testing.T) {
@@ -707,6 +712,7 @@ func TestRenameTabDoesNotPersistForEphemeralSession(t *testing.T) {
707 sess, err := d.createSessionLocked("0", true, "/tmp/work", sz, nil)712 sess, err := d.createSessionLocked("0", true, "/tmp/work", sz, nil)
708 require.NoError(t, err)713 require.NoError(t, err)
709 require.NoError(t, d.renameTab(sess, sess.tabs[0], "shell"))714 require.NoError(t, d.renameTab(sess, sess.tabs[0], "shell"))
715+ require.Equal(t, "shell", sess.tabs[0].name)
710 716
711 require.False(t, state.has("0"))717 require.False(t, state.has("0"))
712 records, err := d.persist.LoadAll()718 records, err := d.persist.LoadAll()

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 12

Tags 11

↑↓ moveenter openesc close