on main help sign in
fix: correct replaceAll not-found error, harden session type assertions

- edit tool replaceContent: when replace_all=true and old_string is not found, return 'old_string not found' error instead of the misleading 'new content is the same as old content'. Matches the existing behavior in deleteContent. - sessions dialog: replace unchecked type assertions (item.(*SessionItem)) with safe comma-ok assertions in the Select handler and selectedSessionItem() to prevent potential panics if the list ever contains a non-SessionItem type

commitc61252b1e3df66e222b176fba0e8258a9d2acef5 authoriko <mail@iko.soy> dateWed 8 Jul 2026, 21:27 (3 months ago) parent8add8b4
2 files changed+9−3
internal/agent/tools/edit.go+3 internal/ui/dialog/sessions.go+6−3
internal/agent/tools/edit.go+3
@@ -381,6 +381,9 @@ func replaceContent(edit editContext, filePath, oldString, newString string, rep
381381
382382 if replaceAll {
383383 newContent = strings.ReplaceAll(oldContent, oldString, newString)
384+ if newContent == oldContent {
385+ return oldStringNotFoundErr, nil
386+ }
384387 } else {
385388 index := strings.Index(oldContent, oldString)
386389 if index == -1 {
internal/ui/dialog/sessions.go+6−3
@@ -206,8 +206,9 @@ func (s *Session) HandleMsg(msg tea.Msg) Action {
206206 s.list.ScrollToSelected()
207207 case key.Matches(msg, s.keyMap.Select):
208208 if item := s.list.SelectedItem(); item != nil {
209− sessionItem := item.(*SessionItem)
210− return ActionSelectSession{sessionItem.Session}
209+ if sessionItem, ok := item.(*SessionItem); ok {
210+ return ActionSelectSession{sessionItem.Session}
211+ }
211212 }
212213 default:
213214 var cmd tea.Cmd
@@ -329,7 +330,9 @@ func (s *Session) Draw(scr uv.Screen, area uv.Rectangle) *tea.Cursor {
329330
330331func (s *Session) selectedSessionItem() *SessionItem {
331332 if item := s.list.SelectedItem(); item != nil {
332− return item.(*SessionItem)
333+ if sessionItem, ok := item.(*SessionItem); ok {
334+ return sessionItem
335+ }
333336 }
334337 return nil
335338}