now showing historical messages for cline task view (#6711)

This commit is contained in:
Toshii
2025-10-08 15:09:43 -07:00
committed by GitHub
parent 0c63eaac20
commit c9550bf357
+6 -19
View File
@@ -655,7 +655,7 @@ func (m *Manager) FollowConversation(ctx context.Context, instanceAddress string
// FollowConversationUntilCompletion streams conversation updates until task completion
func (m *Manager) FollowConversationUntilCompletion(ctx context.Context) error {
fmt.Println("Streaming conversation until completion... (Press Ctrl+C to exit)")
fmt.Println("Following task conversation until completion... (Press Ctrl+C to exit)")
ctx, cancel := context.WithCancel(ctx)
defer cancel()
@@ -663,14 +663,16 @@ func (m *Manager) FollowConversationUntilCompletion(ctx context.Context) error {
// Create stream coordinator
coordinator := NewStreamCoordinator()
// Get current message count without displaying history
totalMessageCount, err := m.getCurrentMessageCount(ctx)
// Load history first
totalMessageCount, err := m.loadAndDisplayRecentHistory(ctx)
if err != nil {
m.renderer.RenderDebug("Warning: Failed to get current message count: %v", err)
m.renderer.RenderDebug("Warning: Failed to load conversation history: %v", err)
totalMessageCount = 0
}
coordinator.SetConversationTurnStartIndex(totalMessageCount)
fmt.Println("\n--- Live updates ---")
// Start both streams concurrently
errChan := make(chan error, 2)
completionChan := make(chan bool, 1)
@@ -977,21 +979,6 @@ func (m *Manager) outputMessageAsJSON(msg *types.ClineMessage) error {
return nil
}
// getCurrentMessageCount gets the current message count without displaying messages
func (m *Manager) getCurrentMessageCount(ctx context.Context) (int, error) {
state, err := m.client.State.GetLatestState(ctx, &cline.EmptyRequest{})
if err != nil {
return 0, fmt.Errorf("failed to get state: %w", err)
}
messages, err := m.extractMessagesFromState(state.StateJson)
if err != nil {
return 0, fmt.Errorf("failed to extract messages: %w", err)
}
return len(messages), nil
}
// loadAndDisplayRecentHistory loads and displays recent conversation history and returns the total number of existing messages
func (m *Manager) loadAndDisplayRecentHistory(ctx context.Context) (int, error) {
// Get the latest state which contains messages