Skip to content

Commit ad3a99c

Browse files
authored
feat: show message count in session selection (#37)
1 parent e1cf7a5 commit ad3a99c

File tree

5 files changed

+26
-8
lines changed

5 files changed

+26
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ require('goose').setup({
8181
window = {
8282
submit = '<cr>', -- Submit prompt
8383
close = '<esc>', -- Close UI windows
84-
stop = '<C-c>', -- Stop a running job
84+
stop = '<C-c>', -- Stop goose while it is running
8585
next_message = ']]', -- Navigate to next message in the conversation
8686
prev_message = '[[', -- Navigate to previous message in the conversation
8787
mention_file = '@', -- Pick a file and add to context. See File Mentions section

lua/goose/session.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ function M.get_all_sessions()
1414
return {
1515
workspace = session.metadata.working_dir,
1616
description = session.metadata.description,
17+
message_count = session.metadata.message_count,
18+
tokens = session.metadata.total_tokens,
1719
modified = session.modified,
1820
name = session.id,
1921
path = session.path
2022
}
2123
end, sessions)
2224
end
2325

24-
-- Helper function to get all sessions as JSON
2526
function M.get_all_workspace_sessions()
2627
local sessions = M.get_all_sessions()
2728
if not sessions then return nil end

lua/goose/ui/output_renderer.lua

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,13 @@ end
261261

262262
function M.render_session_bar()
263263
local function update_winbar(desc)
264-
-- content
264+
--[[ ** TODO: use this right side win bar text with something useful
265+
local winwidth = vim.api.nvim_win_get_width(state.windows.output_win)
266+
local txt = "txt content here"
267+
local padding = string.rep(" ", winwidth - #desc - #txt - 1)
268+
local right_side_txt = padding .. txt
269+
]]
270+
265271
vim.wo[state.windows.output_win].winbar = " " .. desc
266272

267273
-- Add our winbar highlights while preserving existing highlights

lua/goose/ui/session_formatter.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,13 @@ function M._format_message(message)
6262

6363
for _, part in ipairs(message.content) do
6464
if part.type == 'text' and part.text and part.text ~= "" then
65+
local text = vim.trim(part.text)
6566
has_content = true
6667

6768
if message.role == 'user' then
68-
M._format_user_message(lines, part.text)
69+
M._format_user_message(lines, text)
6970
elseif message.role == 'assistant' then
70-
for _, line in ipairs(vim.split(part.text, "\n")) do
71+
for _, line in ipairs(vim.split(text, "\n")) do
7172
table.insert(lines, line)
7273
end
7374
end

lua/goose/ui/ui.lua

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,22 @@ function M.select_session(sessions, cb)
170170
vim.ui.select(sessions, {
171171
prompt = "",
172172
format_item = function(session)
173-
if not session.modified then
174-
return session.description
173+
local parts = {}
174+
175+
if session.description then
176+
table.insert(parts, session.description)
177+
end
178+
179+
if session.message_count then
180+
table.insert(parts, session.message_count .. " messages")
175181
end
176182

177183
local modified = util.time_ago(session.modified)
178-
return session.description .. " ~ " .. modified
184+
if modified then
185+
table.insert(parts, modified)
186+
end
187+
188+
return table.concat(parts, " ~ ")
179189
end
180190
}, function(session_choice)
181191
cb(session_choice)

0 commit comments

Comments
 (0)