@@ -34,24 +34,26 @@ import (
3434
3535// appModel represents the main application model that manages pages, dialogs, and UI state.
3636type appModel struct {
37− width, height int
38− keyMap KeyMap
37+ wWidth, wHeight int // Window dimensions
38+ width, height int
39+ keyMap KeyMap
3940
4041 currentPage page.PageID
4142 previousPage page.PageID
4243 pages map[page.PageID]util.Model
4344 loadedPages map[page.PageID]bool
4445
45− status status.StatusCmp
46+ // Status
47+ status status.StatusCmp
48+ showingFullHelp bool
4649
4750 app *app.App
4851
4952 dialog dialogs.DialogCmp
5053 completions completions.Completions
5154
52− // Session
55+ // Chat Page Specific
5356 selectedSessionID string // The ID of the currently selected session
54− fullHelp bool // Whether to show full help text
5557}
5658
5759// Init initializes the application model and returns initial commands.
@@ -99,7 +101,7 @@ func (a *appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
99101 )
100102 return a, nil
101103 case tea.WindowSizeMsg:
102− return a, a.handleWindowResize(msg)
104+ return a, a.handleWindowResize(msg.Width, msg.Height)
103105
104106 // Completions messages
105107 case completions.OpenCompletionsMsg, completions.FilterCompletionsMsg, completions.CloseCompletionsMsg:
@@ -244,23 +246,29 @@ func (a *appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
244246}
245247
246248// handleWindowResize processes window resize events and updates all components.
247−func (a *appModel) handleWindowResize(msg tea.WindowSizeMsg) tea.Cmd {
249+func (a *appModel) handleWindowResize(width, height int) tea.Cmd {
248250 var cmds []tea.Cmd
249− msg.Height -= 2 // Make space for the status bar
250− a.width, a.height = msg.Width, msg.Height
251−
251+ a.wWidth, a.wHeight = width, height
252+ if a.showingFullHelp {
253+ height -= 3
254+ } else {
255+ height -= 2
256+ }
257+ a.width, a.height = width, height
252258 // Update status bar
253− s, cmd := a.status.Update(msg)
259+ s, cmd := a.status.Update(tea.WindowSizeMsg{Width: width, Height: height})
254260 a.status = s.(status.StatusCmp)
255261 cmds = append(cmds, cmd)
256262
257263 // Update the current page
258− updated, cmd := a.pages[a.currentPage].Update(msg)
259− a.pages[a.currentPage] = updated.(util.Model)
260− cmds = append(cmds, cmd)
264+ for p, page := range a.pages {
265+ updated, pageCmd := page.Update(tea.WindowSizeMsg{Width: width, Height: height})
266+ a.pages[p] = updated.(util.Model)
267+ cmds = append(cmds, pageCmd)
268+ }
261269
262270 // Update the dialogs
263− dialog, cmd := a.dialog.Update(msg)
271+ dialog, cmd := a.dialog.Update(tea.WindowSizeMsg{Width: width, Height: height})
264272 a.dialog = dialog.(dialogs.DialogCmp)
265273 cmds = append(cmds, cmd)
266274
@@ -288,6 +296,11 @@ func (a *appModel) handleKeyPressMsg(msg tea.KeyPressMsg) tea.Cmd {
288296 u, cmd := a.completions.Update(msg)
289297 a.completions = u.(completions.Completions)
290298 return cmd
299+ // help
300+ case key.Matches(msg, a.keyMap.Help):
301+ a.status.ToggleFullHelp()
302+ a.showingFullHelp = !a.showingFullHelp
303+ return a.handleWindowResize(a.wWidth, a.wHeight)
291304 // dialogs
292305 case key.Matches(msg, a.keyMap.Quit):
293306 if a.dialog.ActiveDialogID() == quit.QuitDialogID {
@@ -345,7 +358,7 @@ func (a *appModel) handleKeyPressMsg(msg tea.KeyPressMsg) tea.Cmd {
345358// moveToPage handles navigation between different pages in the application.
346359func (a *appModel) moveToPage(pageID page.PageID) tea.Cmd {
347360 if a.app.CoderAgent.IsBusy() {
348− // For now we don't move to any page if the agent is busy
361+ // TODO: maybe remove this : For now we don't move to any page if the agent is busy
349362 return util.ReportWarn("Agent is busy, please wait...")
350363 }
351364
@@ -367,7 +380,12 @@ func (a *appModel) moveToPage(pageID page.PageID) tea.Cmd {
367380
368381// View renders the complete application interface including pages, dialogs, and overlays.
369382func (a *appModel) View() tea.View {
370− pageView := a.pages[a.currentPage].View()
383+ page := a.pages[a.currentPage]
384+ if withHelp, ok := page.(layout.Help); ok {
385+ a.keyMap.pageBindings = withHelp.Bindings()
386+ }
387+ a.status.SetKeyMap(a.keyMap)
388+ pageView := page.View()
371389 components := []string{
372390 pageView.String(),
373391 }
@@ -412,17 +430,20 @@ func (a *appModel) View() tea.View {
412430
413431// New creates and initializes a new TUI application model.
414432func New(app *app.App) tea.Model {
415− startPage := chat.ChatPage
433+ chatPage := chat.NewChatPage(app)
434+ keyMap := DefaultKeyMap()
435+ keyMap.pageBindings = chatPage.Bindings()
436+
416437 model := &appModel{
417− currentPage: startPage,
438+ currentPage: chat.ChatPageID,
418439 app: app,
419− status: status.NewStatusCmp(),
440+ status: status.NewStatusCmp(keyMap),
420441 loadedPages: make(map[page.PageID]bool),
421− keyMap: DefaultKeyMap(),
442+ keyMap: keyMap,
422443
423444 pages: map[page.PageID]util.Model{
424− chat.ChatPage: chat.NewChatPage(app),
425− logs.LogsPage: logs.NewLogsPage(),
445+ chat.ChatPageID: chatPage,
446+ logs.LogsPage: logs.NewLogsPage(),
426447 },
427448
428449 dialog: dialogs.NewDialogCmp(),