Skip to content

Commit 20cb7a7

Browse files
authored
feat(tui): highlight current session in sessions modal (#1093)
1 parent a493aec commit 20cb7a7

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

packages/tui/internal/components/dialog/session.go

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ type SessionDialog interface {
2828
type sessionItem struct {
2929
title string
3030
isDeleteConfirming bool
31+
isCurrentSession bool
3132
}
3233

3334
func (s sessionItem) Render(
@@ -42,7 +43,11 @@ func (s sessionItem) Render(
4243
if s.isDeleteConfirming {
4344
text = "Press again to confirm delete"
4445
} else {
45-
text = s.title
46+
if s.isCurrentSession {
47+
text = "● " + s.title
48+
} else {
49+
text = s.title
50+
}
4651
}
4752

4853
truncatedStr := truncate.StringWithTail(text, uint(width-1), "...")
@@ -56,6 +61,14 @@ func (s sessionItem) Render(
5661
Foreground(t.BackgroundElement()).
5762
Width(width).
5863
PaddingLeft(1)
64+
} else if s.isCurrentSession {
65+
// Different style for current session when selected
66+
itemStyle = baseStyle.
67+
Background(t.Primary()).
68+
Foreground(t.BackgroundElement()).
69+
Width(width).
70+
PaddingLeft(1).
71+
Bold(true)
5972
} else {
6073
// Normal selection
6174
itemStyle = baseStyle.
@@ -70,6 +83,12 @@ func (s sessionItem) Render(
7083
itemStyle = baseStyle.
7184
Foreground(t.Error()).
7285
PaddingLeft(1)
86+
} else if s.isCurrentSession {
87+
// Highlight current session when not selected
88+
itemStyle = baseStyle.
89+
Foreground(t.Primary()).
90+
PaddingLeft(1).
91+
Bold(true)
7392
} else {
7493
itemStyle = baseStyle.
7594
PaddingLeft(1)
@@ -194,6 +213,7 @@ func (s *sessionDialog) updateListItems() {
194213
item := sessionItem{
195214
title: sess.Title,
196215
isDeleteConfirming: s.deleteConfirmation == i,
216+
isCurrentSession: s.app.Session != nil && s.app.Session.ID == sess.ID,
197217
}
198218
items = append(items, item)
199219
}
@@ -229,6 +249,7 @@ func NewSessionDialog(app *app.App) SessionDialog {
229249
items = append(items, sessionItem{
230250
title: sess.Title,
231251
isDeleteConfirming: false,
252+
isCurrentSession: app.Session != nil && app.Session.ID == sess.ID,
232253
})
233254
}
234255

0 commit comments

Comments
 (0)