chore: add new session

Kujtim Hoxha created

Change summary

internal/llm/prompt/coder.md                         |  2 
internal/tui/components/chat/splash/splash.go        | 20 ++++++++++++++
internal/tui/components/dialogs/commands/commands.go | 10 +++++++
internal/tui/page/chat/chat.go                       |  5 +++
4 files changed, 36 insertions(+), 1 deletion(-)

Detailed changes

internal/llm/prompt/coder.md 🔗

@@ -228,7 +228,7 @@ NEVER commit changes unless the user explicitly asks you to. It is VERY IMPORTAN
 
 **When to verify with `pwd`:**
 
-- After a command fails with "file not found" or similar path-related errors
+- After a command fails with "file not found" or similar path-related or `exit status 1` errors
 - When resuming work or continuing from a previous step if uncertain
 - When you realize you may have lost track of your current location
 

internal/tui/components/chat/splash/splash.go 🔗

@@ -562,6 +562,8 @@ func (s *splashCmp) infoSection() string {
 			lipgloss.Left,
 			s.cwd(),
 			"",
+			s.currentModelBlock(),
+			"",
 			lipgloss.JoinHorizontal(lipgloss.Left, s.lspBlock(), s.mcpBlock()),
 			"",
 		),
@@ -740,6 +742,24 @@ func (s *splashCmp) mcpBlock() string {
 	)
 }
 
+func (s *splashCmp) currentModelBlock() string {
+	cfg := config.Get()
+	agentCfg := cfg.Agents["coder"]
+	model := config.Get().GetModelByType(agentCfg.Model)
+	t := styles.CurrentTheme()
+	modelIcon := t.S().Base.Foreground(t.FgSubtle).Render(styles.ModelIcon)
+	modelName := t.S().Text.Render(model.Name)
+	modelInfo := fmt.Sprintf("%s %s", modelIcon, modelName)
+	parts := []string{
+		modelInfo,
+	}
+
+	return lipgloss.JoinVertical(
+		lipgloss.Left,
+		parts...,
+	)
+}
+
 func (s *splashCmp) IsShowingAPIKey() bool {
 	return s.needsAPIKey
 }

internal/tui/components/dialogs/commands/commands.go 🔗

@@ -59,6 +59,7 @@ type commandDialogCmp struct {
 
 type (
 	SwitchSessionsMsg    struct{}
+	NewSessionsMsg       struct{}
 	SwitchModelMsg       struct{}
 	QuitMsg              struct{}
 	OpenFilePickerMsg    struct{}
@@ -250,6 +251,15 @@ func (c *commandDialogCmp) Position() (int, int) {
 
 func (c *commandDialogCmp) defaultCommands() []Command {
 	commands := []Command{
+		{
+			ID:          "new_session",
+			Title:       "New Session",
+			Description: "start a new session",
+			Shortcut:    "ctrl+n",
+			Handler: func(cmd Command) tea.Cmd {
+				return util.CmdHandler(NewSessionsMsg{})
+			},
+		},
 		{
 			ID:          "switch_session",
 			Title:       "Switch Session",

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

@@ -287,6 +287,11 @@ func (p *chatPage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 		p.isProjectInit = false
 		p.focusedPane = PanelTypeEditor
 		return p, p.SetSize(p.width, p.height)
+	case commands.NewSessionsMsg:
+		if p.app.CoderAgent.IsBusy() {
+			return p, util.ReportWarn("Agent is busy, please wait before starting a new session...")
+		}
+		return p, p.newSession()
 	case tea.KeyPressMsg:
 		switch {
 		case key.Matches(msg, p.keyMap.NewSession):