| 839 | } |
| 840 | |
| 841 | func (a *App) NewSession() { |
| 842 | if a.cancel != nil { |
| 843 | a.cancel() |
| 844 | a.cancel = nil |
| 845 | } |
| 846 | // Preserve user-controlled session flags |
| 847 | // so they don't reset to default on /new |
| 848 | var opts []session.Opt |
| 849 | if a.session != nil { |
| 850 | opts = append(opts, |
| 851 | session.WithToolsApproved(a.session.ToolsApproved), |
| 852 | session.WithHideToolResults(a.session.HideToolResults), |
| 853 | session.WithWorkingDir(a.session.WorkingDir), |
| 854 | ) |
| 855 | } |
| 856 | a.session = session.New(opts...) |
| 857 | // Clear first message so it won't be re-sent on re-init |
| 858 | a.firstMessage = nil |
| 859 | a.firstMessageAttach = "" |
| 860 | |
| 861 | // Re-emit startup info so the sidebar shows agent/tools info in the new session |
| 862 | a.reEmitStartupInfo(a.ctx()) |
| 863 | } |
| 864 | |
| 865 | // reEmitStartupInfo resets and re-emits startup info (agent, team, tools) |
| 866 | // through the events channel so the sidebar updates. |