From bcd944c2cd082d5cfae1064a7d0c3895fe25be71 Mon Sep 17 00:00:00 2001 From: Kujtim Hoxha Date: Tue, 29 Jul 2025 12:34:43 +0200 Subject: [PATCH] chore: add new session --- internal/llm/prompt/coder.md | 2 +- internal/tui/components/chat/splash/splash.go | 20 +++++++++++++++++++ .../components/dialogs/commands/commands.go | 10 ++++++++++ internal/tui/page/chat/chat.go | 5 +++++ 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/internal/llm/prompt/coder.md b/internal/llm/prompt/coder.md index 9c958a1c1858c6722ee08dcaa62bf2811a20febd..1477ad915a17247b13ff00588674d2acbc25a125 100644 --- a/internal/llm/prompt/coder.md +++ b/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 diff --git a/internal/tui/components/chat/splash/splash.go b/internal/tui/components/chat/splash/splash.go index 5254c31365384a5805c811880dcf0a4dfbf1edd6..c4e8a407c38564bf5b152207cc4f68223459bc1d 100644 --- a/internal/tui/components/chat/splash/splash.go +++ b/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 } diff --git a/internal/tui/components/dialogs/commands/commands.go b/internal/tui/components/dialogs/commands/commands.go index 713c8628e7d962a6bce06b43c7e6ebd07b5bedaf..3319d0134888ad1e65656fb64cf4352ecd178229 100644 --- a/internal/tui/components/dialogs/commands/commands.go +++ b/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", diff --git a/internal/tui/page/chat/chat.go b/internal/tui/page/chat/chat.go index 9f79da4bcf42f0eef5f73155a65d5ac7ca70b22c..66060d047e07dc96d3ce7542ffdc63ab8fa80686 100644 --- a/internal/tui/page/chat/chat.go +++ b/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):