@@ -78,14 +78,14 @@ func DefaultKeyMap() KeyMap {
7878// New creates and initializes a new TUI application model
7979func New (a * app.App ) tea.Model {
8080 t := & appModel {
81- chatPage : chatpage .New (a ),
8281 keyMap : DefaultKeyMap (),
8382 dialog : dialog .New (),
8483 notification : notification .New (),
8584 application : a ,
8685 }
8786
8887 t .statusBar = statusbar .New (t )
88+ t .chatPage = chatpage .New (a , t .builtInSessionCommands ())
8989
9090 return t
9191}
@@ -316,55 +316,63 @@ func toFullscreenView(content string) tea.View {
316316 return view
317317}
318318
319+ func (a * appModel ) builtInSessionCommands () []dialog.Command {
320+ return []dialog.Command {
321+ {
322+ ID : "session.new" ,
323+ Label : "New" ,
324+ SlashCommand : "/new" ,
325+ Description : "Start a new conversation" ,
326+ Category : "Session" ,
327+ Execute : func () tea.Cmd {
328+ a .application .NewSession ()
329+ a .chatPage = chatpage .New (a .application , a .builtInSessionCommands ())
330+ a .dialog = dialog .New ()
331+ a .statusBar = statusbar .New (a .chatPage )
332+
333+ return tea .Batch (a .Init (), a .handleWindowResize (a .wWidth , a .wHeight ))
334+ },
335+ },
336+ {
337+ ID : "session.compact" ,
338+ Label : "Compact" ,
339+ SlashCommand : "/compact" ,
340+ Description : "Summarize the current conversation" ,
341+ Category : "Session" ,
342+ Execute : func () tea.Cmd {
343+ return a .chatPage .CompactSession ()
344+ },
345+ },
346+ {
347+ ID : "session.clipboard" ,
348+ Label : "Copy" ,
349+ SlashCommand : "/copy" ,
350+ Description : "Copy the current conversation to the clipboard" ,
351+ Category : "Session" ,
352+ Execute : func () tea.Cmd {
353+ return a .chatPage .CopySessionToClipboard ()
354+ },
355+ },
356+ {
357+ ID : "session.eval" ,
358+ Label : "Eval" ,
359+ SlashCommand : "/eval" ,
360+ Description : "Create an evaluation report for the current conversation" ,
361+ Category : "Session" ,
362+ Execute : func () tea.Cmd {
363+ evalFile , _ := evaluation .Save (a .application .Session ())
364+ return core .CmdHandler (notification.ShowMsg {Text : fmt .Sprintf ("Eval saved to file %s" , evalFile )})
365+ },
366+ },
367+ }
368+ }
369+
319370// buildCommandCategories builds the list of command categories for the command palette
320371func (a * appModel ) buildCommandCategories (ctx context.Context ) []dialog.CommandCategory {
321372 categories := []dialog.CommandCategory {
322373 {
323- Name : "Session" ,
324- Commands : []dialog.Command {
325- {
326- ID : "session.new" ,
327- Label : "New " ,
328- Description : "Start a new conversation" ,
329- Category : "Session" ,
330- Execute : func () tea.Cmd {
331- a .application .NewSession ()
332- a .chatPage = chatpage .New (a .application )
333- a .dialog = dialog .New ()
334- a .statusBar = statusbar .New (a .chatPage )
335-
336- return tea .Batch (a .Init (), a .handleWindowResize (a .wWidth , a .wHeight ))
337- },
338- },
339- {
340- ID : "session.compact" ,
341- Label : "Compact" ,
342- Description : "Summarize the current conversation" ,
343- Category : "Session" ,
344- Execute : func () tea.Cmd {
345- return a .chatPage .CompactSession ()
346- },
347- },
348- {
349- ID : "session.clipboard" ,
350- Label : "Copy" ,
351- Description : "Copy the current conversation to the clipboard" ,
352- Category : "Session" ,
353- Execute : func () tea.Cmd {
354- return a .chatPage .CopySessionToClipboard ()
355- },
356- },
357- {
358- ID : "session.eval" ,
359- Label : "Eval" ,
360- Description : "Create an evaluation report for the current conversation" ,
361- Category : "Session" ,
362- Execute : func () tea.Cmd {
363- evalFile , _ := evaluation .Save (a .application .Session ())
364- return core .CmdHandler (notification.ShowMsg {Text : fmt .Sprintf ("Eval saved to file %s" , evalFile )})
365- },
366- },
367- },
374+ Name : "Session" ,
375+ Commands : a .builtInSessionCommands (),
368376 },
369377 }
370378
0 commit comments