From c9550bf357079588a7dcd1f897a2cb621c4934d5 Mon Sep 17 00:00:00 2001 From: Toshii <94262432+0xToshii@users.noreply.github.com> Date: Wed, 8 Oct 2025 15:09:43 -0700 Subject: [PATCH] now showing historical messages for cline task view (#6711) --- cli/pkg/cli/task/manager.go | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/cli/pkg/cli/task/manager.go b/cli/pkg/cli/task/manager.go index 70c5c394f5..119c3ecc42 100644 --- a/cli/pkg/cli/task/manager.go +++ b/cli/pkg/cli/task/manager.go @@ -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