fix: handle code agent not initialized

Kujtim Hoxha created

Change summary

internal/tui/page/chat/chat.go | 4 ++++
internal/tui/tui.go            | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)

Detailed changes

internal/tui/page/chat/chat.go 🔗

@@ -300,6 +300,10 @@ func (p *chatPage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 	case tea.KeyPressMsg:
 		switch {
 		case key.Matches(msg, p.keyMap.NewSession):
+			// if we have no agent do nothing
+			if p.app.CoderAgent == nil {
+				return p, nil
+			}
 			if p.app.CoderAgent.IsBusy() {
 				return p, util.ReportWarn("Agent is busy, please wait before starting a new session...")
 			}

internal/tui/tui.go 🔗

@@ -393,7 +393,7 @@ func (a *appModel) handleKeyPressMsg(msg tea.KeyPressMsg) tea.Cmd {
 		)
 		return tea.Sequence(cmds...)
 	case key.Matches(msg, a.keyMap.Suspend):
-		if a.app.CoderAgent.IsBusy() {
+		if a.app.CoderAgent != nil && a.app.CoderAgent.IsBusy() {
 			return util.ReportWarn("Agent is busy, please wait...")
 		}
 		return tea.Suspend