File tree Expand file tree Collapse file tree 4 files changed +16
-6
lines changed
Expand file tree Collapse file tree 4 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -274,7 +274,7 @@ function M.submit_input_prompt()
274274 -- we're displaying /help or something similar, need to clear that and refresh
275275 -- the session data before sending the command
276276 state .display_route = nil
277- ui .render_output ()
277+ ui .render_output (true )
278278 end
279279
280280 input_window .handle_submit ()
Original file line number Diff line number Diff line change @@ -77,7 +77,7 @@ function M.open(opts)
7777 -- and the windows were closed so we need to do a full refresh. This mostly happens
7878 -- when opening the window after having closed it since we're not currently clearing
7979 -- the session on api.close()
80- ui .render_output (false )
80+ ui .render_output ()
8181 end
8282 end
8383 end
Original file line number Diff line number Diff line change @@ -114,12 +114,14 @@ local function fetch_session()
114114 return require (' opencode.session' ).get_messages (session )
115115end
116116
117+ --- Request all of the session data from the opencode server and render it
118+ --- @return Promise<OpencodeMessage[]>
117119function M .render_full_session ()
118120 if not output_window .mounted () or not state .api_client then
119- return
121+ return Promise . new (): resolve ( nil )
120122 end
121123
122- fetch_session ():and_then (M ._render_full_session_data )
124+ return fetch_session ():and_then (M ._render_full_session_data )
123125end
124126
125127function M ._render_full_session_data (session_data )
Original file line number Diff line number Diff line change @@ -174,8 +174,16 @@ function M.clear_output()
174174 -- state.restore_points = {}
175175end
176176
177- function M .render_output (_ )
178- renderer .render_full_session ()
177+ --- Force a full rerender of the output buffer. Should be done synchronously if
178+ --- called before submitting input or doing something that might generate events
179+ --- from opencode
180+ --- @param synchronous ? boolean If true , waits until session is fully rendered
181+ function M .render_output (synchronous )
182+ local ret = renderer .render_full_session ()
183+
184+ if ret and synchronous then
185+ ret :wait ()
186+ end
179187end
180188
181189function M .render_lines (lines )
You can’t perform that action at this time.
0 commit comments