fix(cmd/t): show only tasks without goal header

Amolith and Crush created

Implements: 87aeb06
Co-authored-by: Crush <crush@charm.land>

Change summary

cmd/t/t.go           | 14 +-------------
internal/cli/plan.go | 20 ++++++++++++++++----
2 files changed, 17 insertions(+), 17 deletions(-)

Detailed changes

cmd/t/t.go 🔗

@@ -57,18 +57,6 @@ func runListTasks(cmd *cobra.Command, _ []string) error {
 		return err
 	}
 
-	goalDoc, ok, err := env.LoadGoal(cmd.Context(), sessionDoc.SID)
-	if err != nil {
-		return err
-	}
-
-	state := cli.PlanState{
-		Tasks: tasks,
-	}
-	if ok {
-		state.Goal = &goalDoc
-	}
-
-	_, _ = fmt.Fprint(cmd.OutOrStdout(), cli.RenderPlan(state))
+	_, _ = fmt.Fprint(cmd.OutOrStdout(), cli.RenderTasksOnly(tasks))
 	return nil
 }

internal/cli/plan.go 🔗

@@ -84,20 +84,32 @@ func RenderPlan(state PlanState) string {
 		b.WriteString("No goal set yet\n\n")
 	}
 
-	legend := buildLegend(state.Tasks)
+	b.WriteString(renderTaskList(state.Tasks))
+	return b.String()
+}
+
+// RenderTasksOnly renders just the tasks without the goal header.
+func RenderTasksOnly(tasks []task.Task) string {
+	return renderTaskList(tasks)
+}
+
+func renderTaskList(tasks []task.Task) string {
+	var b strings.Builder
+
+	legend := buildLegend(tasks)
 	if legend != "" {
 		b.WriteString("Legend: ")
 		b.WriteString(legend)
 		b.WriteString("\n")
 	}
 
-	if len(state.Tasks) == 0 {
+	if len(tasks) == 0 {
 		b.WriteString("No tasks yet.\n")
 		return b.String()
 	}
 
-	sorted := make([]task.Task, len(state.Tasks))
-	copy(sorted, state.Tasks)
+	sorted := make([]task.Task, len(tasks))
+	copy(sorted, tasks)
 	sort.Slice(sorted, func(i, j int) bool {
 		if sorted[i].CreatedSeq != sorted[j].CreatedSeq {
 			return sorted[i].CreatedSeq < sorted[j].CreatedSeq