diff --git a/internal/tui/components/dialogs/commands/commands.go b/internal/tui/components/dialogs/commands/commands.go index 6c292ce7fd16eb671abc02bf577c6fc420dbd283..139ec1ea5ac0461b0c4fa8de65c61c7293b8ac50 100644 --- a/internal/tui/components/dialogs/commands/commands.go +++ b/internal/tui/components/dialogs/commands/commands.go @@ -119,7 +119,10 @@ func (c *commandDialogCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case tea.WindowSizeMsg: c.wWidth = msg.Width c.wHeight = msg.Height - return c, c.commandList.SetSize(c.listWidth(), c.listHeight()) + return c, tea.Batch( + c.SetCommandType(c.commandType), + c.commandList.SetSize(c.listWidth(), c.listHeight()), + ) case tea.KeyPressMsg: switch { case key.Matches(msg, c.keyMap.Select): @@ -318,7 +321,6 @@ func (c *commandDialogCmp) defaultCommands() []Command { }) } } - // Only show toggle compact mode command if window width is larger than compact breakpoint (90) if c.wWidth > 120 && c.sessionID != "" { commands = append(commands, Command{ diff --git a/internal/tui/components/files/files.go b/internal/tui/components/files/files.go index 9ddced4c908ecae59452ecc999facfcaf52443b3..234a75fd4e06431018eab1fbf37e90e562da4083 100644 --- a/internal/tui/components/files/files.go +++ b/internal/tui/components/files/files.go @@ -59,6 +59,9 @@ func RenderFileList(fileSlice []SessionFile, opts RenderOptions) []string { // Sort files by the latest version's created time sort.Slice(fileSlice, func(i, j int) bool { + if fileSlice[i].History.LatestVersion.CreatedAt == fileSlice[j].History.LatestVersion.CreatedAt { + return strings.Compare(fileSlice[i].FilePath, fileSlice[j].FilePath) < 0 + } return fileSlice[i].History.LatestVersion.CreatedAt > fileSlice[j].History.LatestVersion.CreatedAt }) diff --git a/internal/tui/exp/list/list.go b/internal/tui/exp/list/list.go index 44a849fcf6027813feb49be5a68c401f4253eeb6..4bf8b2dbbc4ffde261465c8ebd655a26f2344852 100644 --- a/internal/tui/exp/list/list.go +++ b/internal/tui/exp/list/list.go @@ -3,6 +3,7 @@ package list import ( "slices" "strings" + "sync" "github.com/charmbracelet/bubbles/v2/key" tea "github.com/charmbracelet/bubbletea/v2" @@ -90,6 +91,7 @@ type list[T Item] struct { renderedItems *csync.Map[string, renderedItem] + renderMu sync.Mutex rendered string movingByItem bool @@ -328,7 +330,9 @@ func (l *list[T]) render() tea.Cmd { // we are not rendering the first time if l.rendered != "" { // rerender everything will mostly hit cache + l.renderMu.Lock() l.rendered, _ = l.renderIterator(0, false, "") + l.renderMu.Unlock() if l.direction == DirectionBackward { l.recalculateItemPositions() } @@ -338,9 +342,10 @@ func (l *list[T]) render() tea.Cmd { } return focusChangeCmd } + l.renderMu.Lock() rendered, finishIndex := l.renderIterator(0, true, "") l.rendered = rendered - + l.renderMu.Unlock() // recalculate for the initial items if l.direction == DirectionBackward { l.recalculateItemPositions() @@ -348,7 +353,10 @@ func (l *list[T]) render() tea.Cmd { renderCmd := func() tea.Msg { l.offset = 0 // render the rest + + l.renderMu.Lock() l.rendered, _ = l.renderIterator(finishIndex, false, l.rendered) + l.renderMu.Unlock() // needed for backwards if l.direction == DirectionBackward { l.recalculateItemPositions() @@ -357,7 +365,6 @@ func (l *list[T]) render() tea.Cmd { if l.focused { l.scrollToSelection() } - return nil } return tea.Batch(focusChangeCmd, renderCmd)