handlePRDUpdate handles PRD file change events.
(msg PRDUpdateMsg)
| 2295 | |
| 2296 | // handlePRDUpdate handles PRD file change events. |
| 2297 | func (a App) handlePRDUpdate(msg PRDUpdateMsg) (tea.Model, tea.Cmd) { |
| 2298 | if msg.Error != nil { |
| 2299 | // File error - could be temporary, keep watching |
| 2300 | a.lastActivity = "PRD file error: " + msg.Error.Error() |
| 2301 | } else if msg.PRD != nil { |
| 2302 | // Update the PRD |
| 2303 | a.prd = msg.PRD |
| 2304 | |
| 2305 | // Adjust selected index if it's now out of bounds |
| 2306 | if a.selectedIndex >= len(a.prd.UserStories) { |
| 2307 | a.selectedIndex = len(a.prd.UserStories) - 1 |
| 2308 | if a.selectedIndex < 0 { |
| 2309 | a.selectedIndex = 0 |
| 2310 | } |
| 2311 | } |
| 2312 | |
| 2313 | // Auto-select the in-progress story so the user sees its details |
| 2314 | a.selectInProgressStory() |
| 2315 | a.adjustStoriesScroll() |
| 2316 | } |
| 2317 | |
| 2318 | // Continue listening for changes |
| 2319 | return a, a.listenForPRDChanges() |
| 2320 | } |
| 2321 | |
| 2322 | // stopWatcher stops the file watchers. |
| 2323 | func (a *App) stopWatcher() { |
no test coverage detected