Skip to content

Commit bd7d704

Browse files
committed
feat: add compact mode for right-side layout
- Auto-enable compact mode when display_mode is "right" - Hide hints bar in compact mode for cleaner side panel - Hide welcome message in compact mode - Reduce message spacing (1 line instead of 2 between messages) - Add is_compact() helper function
1 parent 692f9cc commit bd7d704

1 file changed

Lines changed: 18 additions & 9 deletions

File tree

lua/chatgpt/flows/chat/base.lua

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,14 @@ function Chat:welcome()
104104
end
105105
end
106106

107-
if #self.session.conversation == 0 or (#self.session.conversation == 1 and self.system_message ~= nil) then
108-
local lines = Utils.split_string_by_line(Config.options.chat.welcome_message)
109-
self:set_lines(0, 0, false, lines)
110-
for line_num = 0, #lines do
111-
self:add_highlight("ChatGPTWelcome", line_num, 0, -1)
107+
-- Show welcome message only in non-compact mode
108+
if not self:is_compact() then
109+
if #self.session.conversation == 0 or (#self.session.conversation == 1 and self.system_message ~= nil) then
110+
local lines = Utils.split_string_by_line(Config.options.chat.welcome_message)
111+
self:set_lines(0, 0, false, lines)
112+
for line_num = 0, #lines do
113+
self:add_highlight("ChatGPTWelcome", line_num, 0, -1)
114+
end
112115
end
113116
end
114117
self:render_role()
@@ -186,6 +189,10 @@ function Chat:isBusy()
186189
return self.spinner:is_running() or self.is_streaming_response
187190
end
188191

192+
function Chat:is_compact()
193+
return self.display_mode == "right"
194+
end
195+
189196
function Chat:add(type, text, usage)
190197
local idx = self.session:add_item({
191198
type = type,
@@ -204,7 +211,8 @@ function Chat:_add(type, text, usage, idx)
204211
local start_line = 0
205212
if self.selectedIndex > 0 then
206213
local prev = self.messages[self.selectedIndex]
207-
start_line = prev.end_line + (prev.type == ANSWER and 2 or 1)
214+
local spacing = self:is_compact() and 1 or (prev.type == ANSWER and 2 or 1)
215+
start_line = prev.end_line + spacing
208216
end
209217

210218
local lines = {}
@@ -266,7 +274,8 @@ function Chat:addAnswerPartial(text, state)
266274
local start_line = 0
267275
if self.selectedIndex > 0 then
268276
local prev = self.messages[self.selectedIndex]
269-
start_line = prev.end_line + (prev.type == ANSWER and 2 or 1)
277+
local spacing = self:is_compact() and 1 or (prev.type == ANSWER and 2 or 1)
278+
start_line = prev.end_line + spacing
270279
end
271280

272281
if state == "END" then
@@ -1203,9 +1212,9 @@ function Chat:get_layout_params()
12031212
}, { dir = "col", grow = 1 })
12041213
end
12051214

1206-
-- Build final layout with hints at full width bottom
1215+
-- Build final layout with hints at full width bottom (hidden in compact mode)
12071216
local box
1208-
if self.hints_panel then
1217+
if self.hints_panel and not self:is_compact() then
12091218
box = Layout.Box({
12101219
main_content,
12111220
Layout.Box(self.hints_panel, { size = 1 }),

0 commit comments

Comments
 (0)