summaryrefslogtreecommitdiff
path: root/makima/frontend/src/components/directives/DirectiveList.tsx
blob: 5afa36e88d0560453270e0f569d237ef5a1307d1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
import { useState } from "react";
import type { DirectiveSummary, DirectiveStatus } from "../../lib/api";

interface DirectiveListProps {
  directives: DirectiveSummary[];
  loading: boolean;
  onSelect: (id: string) => void;
  onCreate: () => void;
  onDelete?: (directive: DirectiveSummary) => void;
  selectedId?: string;
}

const statusColors: Record<DirectiveStatus, string> = {
  draft: "text-[#888]",
  planning: "text-yellow-400",
  active: "text-green-400",
  paused: "text-orange-400",
  completed: "text-blue-400",
  archived: "text-[#555]",
  failed: "text-red-400",
};

export function DirectiveList({
  directives,
  loading,
  onSelect,
  onCreate,
  selectedId,
}: DirectiveListProps) {
  const [filter, setFilter] = useState<DirectiveStatus | "all">("all");

  const filteredDirectives =
    filter === "all"
      ? directives
      : directives.filter((d) => d.status === filter);

  if (loading) {
    return (
      <div className="panel h-full flex items-center justify-center">
        <div className="font-mono text-[#9bc3ff] text-sm">Loading...</div>
      </div>
    );
  }

  return (
    <div className="panel h-full flex flex-col">
      {/* Header */}
      <div className="p-4 border-b border-dashed border-[rgba(117,170,252,0.35)]">
        <div className="flex items-center justify-between mb-3">
          <h2 className="font-mono text-sm text-[#75aafc] uppercase tracking-wider">
            Directives
          </h2>
          <button
            onClick={onCreate}
            className="px-3 py-1.5 font-mono text-xs text-[#dbe7ff] bg-[#0f3c78] border border-[#3f6fb3] hover:bg-[#153667] transition-colors uppercase"
          >
            + New
          </button>
        </div>

        {/* Filter tabs */}
        <div className="flex gap-1 flex-wrap">
          {(["all", "draft", "planning", "active", "paused", "completed", "failed"] as const).map(
            (status) => (
              <button
                key={status}
                onClick={() => setFilter(status)}
                className={`
                  px-2 py-1 font-mono text-[10px] uppercase tracking-wider transition-colors
                  ${
                    filter === status
                      ? "bg-[rgba(117,170,252,0.1)] text-[#9bc3ff] border border-[rgba(117,170,252,0.3)]"
                      : "text-[#555] hover:text-[#75aafc]"
                  }
                `}
              >
                {status}
              </button>
            )
          )}
        </div>
      </div>

      {/* List */}
      <div className="flex-1 overflow-y-auto">
        {filteredDirectives.length === 0 ? (
          <div className="p-4 text-center">
            <p className="font-mono text-sm text-[#555]">
              {filter === "all"
                ? "No directives yet"
                : `No ${filter} directives`}
            </p>
          </div>
        ) : (
          <div className="divide-y divide-[rgba(117,170,252,0.15)]">
            {filteredDirectives.map((directive) => (
              <button
                key={directive.id}
                onClick={() => onSelect(directive.id)}
                className={`
                  w-full text-left p-4 transition-colors
                  ${
                    selectedId === directive.id
                      ? "bg-[rgba(117,170,252,0.1)]"
                      : "hover:bg-[rgba(117,170,252,0.05)]"
                  }
                `}
              >
                <div className="flex items-start justify-between gap-2 mb-2">
                  <h3 className="font-mono text-sm text-[#dbe7ff] truncate">
                    {directive.title}
                  </h3>
                  <span
                    className={`text-[10px] font-mono uppercase shrink-0 ${
                      statusColors[directive.status] || "text-[#888]"
                    }`}
                  >
                    {directive.status}
                  </span>
                </div>

                {directive.goal && (
                  <p className="font-mono text-xs text-[#555] mb-2 line-clamp-2">
                    {directive.goal}
                  </p>
                )}

                <div className="flex items-center gap-3 text-[10px] font-mono text-[#555]">
                  {directive.chainCount > 0 && (
                    <span>{directive.chainCount} chains</span>
                  )}
                  {directive.stepCount > 0 && (
                    <span>{directive.stepCount} steps</span>
                  )}
                </div>
              </button>
            ))}
          </div>
        )}
      </div>
    </div>
  );
}