MCPcopy Create free account
hub / github.com/MiniCodeMonkey/chief / handleLoopEvent

Method handleLoopEvent

internal/tui/app.go:914–1023  ·  view source on GitHub ↗

handleLoopEvent handles events from the manager.

(prdName string, event loop.Event)

Source from the content-addressed store, hash-verified

912
913// handleLoopEvent handles events from the manager.
914func (a App) handleLoopEvent(prdName string, event loop.Event) (tea.Model, tea.Cmd) {
915 // Only update iteration and log if this is the currently viewed PRD
916 isCurrentPRD := prdName == a.prdName
917
918 if isCurrentPRD {
919 a.iteration = event.Iteration
920 // Add event to log viewer
921 a.logViewer.AddEvent(event)
922 }
923
924 var autoActionCmd tea.Cmd
925
926 switch event.Type {
927 case loop.EventIterationStart:
928 if isCurrentPRD {
929 a.lastActivity = "Starting iteration..."
930 // Start tracking story timing if this is a new story
931 if event.StoryID != "" && event.StoryID != a.currentStoryID {
932 a.finalizeStoryTiming()
933 a.currentStoryID = event.StoryID
934 a.currentStoryStart = time.Now()
935 }
936 }
937 case loop.EventAssistantText:
938 if isCurrentPRD {
939 // Truncate long text for activity display
940 text := event.Text
941 if len(text) > 100 {
942 text = text[:97] + "..."
943 }
944 a.lastActivity = text
945 }
946 case loop.EventToolStart:
947 if isCurrentPRD {
948 a.lastActivity = "Running tool: " + event.Tool
949 }
950 case loop.EventToolResult:
951 if isCurrentPRD {
952 a.lastActivity = "Tool completed"
953 }
954 case loop.EventStoryDone:
955 if isCurrentPRD {
956 a.lastActivity = "Story done"
957 // Finalize story timing
958 a.finalizeStoryTiming()
959 }
960 case loop.EventComplete:
961 if isCurrentPRD {
962 a.state = StateComplete
963 a.lastActivity = "All stories complete!"
964 // Finalize the last story's timing
965 a.finalizeStoryTiming()
966 autoActionCmd = a.showCompletionScreen(prdName)
967 } else {
968 // For background PRDs, trigger auto-push/PR without showing completion screen
969 autoActionCmd = a.runBackgroundAutoActions(prdName)
970 }
971 // Trigger completion callback for any PRD

Callers 1

UpdateMethod · 0.95

Calls 8

finalizeStoryTimingMethod · 0.95
showCompletionScreenMethod · 0.95
clearInProgressMethod · 0.95
LoadPRDFunction · 0.92
AddEventMethod · 0.80
RefreshMethod · 0.45

Tested by

no test coverage detected