Repository navigation
Expand file tree
/
Copy pathbuilder.go.html
More file actions
224 lines (220 loc) · 11.3 KB
/
Copy pathbuilder.go.html
File metadata and controls
224 lines (220 loc) · 11.3 KB
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
{{/* Copyright (c) ClaceIO, LLC */}}
{{/* SPDX-License-Identifier: Apache-2.0 */}}
{{/* Builder sessions list (/builder): draft apps built with the AI agent.
HTMX partial: block builder_rows
*/}}
{{ template "page_open" (dict "Ctx" . "Main" "space-y-4 max-w-6xl") }}
<!-- Header -->
<div
class="page-header flex items-center gap-2 flex-wrap mb-2 md:mb-6">
{{ template "hamburger" . }}
<div>
{{ template "page_title" "Builder" }}
<p class="page-desc text-sm text-base-content/70">
Describe an app, iterate with the AI agent
</p>
</div>
<div class="page-actions ml-auto flex items-center gap-2">
{{ template "page_search" (dict "Query" .Data.Query "Label" "Filter builder sessions" "Placeholder" "Filter sessions…" "Url" (print .AppPath "/builder") "Target" "#builder-rows") }}
<a
class="btn btn-sm btn-primary transition-transform duration-150 active:scale-95 {{ if not (index .Data.Perms "builder:create") }}
btn-disabled tooltip tooltip-bottom
{{ end }}"
{{ if index .Data.Perms "builder:create" }}
href="{{ .AppPath }}/builder/create"
{{ else }}
data-tip="requires builder:create" aria-disabled="true"
tabindex="-1"
{{ end }}>
+ New app
</a>
</div>
</div>
{{ template "page_progress" }}
<div id="builder-rows" class="space-y-4">
{{ block "builder_rows" . }}
{{ template "flash_alerts" .Data }}
{{ if not .Data.Enabled }}
<div class="alert" role="status">
<span>
The app builder is not enabled on this server. Set
<code class="font-mono">app_builder.enabled</code> and an
agent profile in the server config.
</span>
</div>
{{ else if .Data.Sessions }}
<div class="card bg-base-100 border border-base-300">
<div class="overflow-x-auto">
<table class="table table-sm">
<thead>
<tr>
<th scope="col" class="w-8">
<span class="sr-only">Details</span>
</th>
<th scope="col">Name</th>
<th scope="col">Status</th>
<th scope="col" class="hidden md:table-cell">
Preview
</th>
<th scope="col" class="hidden md:table-cell">
Published
</th>
<th scope="col" class="hidden lg:table-cell">
Agent
</th>
<th scope="col" class="hidden lg:table-cell">By</th>
<th scope="col" class="text-right">Actions</th>
</tr>
</thead>
<tbody>
{{ range .Data.Sessions }}
<tr class="group hover:bg-base-200/50">
<td>
<a
href="{{ $.AppPath }}/builder/detail?id={{ .id }}"
class="btn btn-xs btn-ghost btn-square tooltip tooltip-right"
data-tip="Expand: {{ .name }} session details"
aria-label="Details for {{ .name }}">
{{ template "drilldown_icon" }}
</a>
</td>
<td
class="font-medium break-words whitespace-normal sm:min-w-44 max-w-72">
{{ .name }}
{{ if .edit_app }}
<span
class="block font-mono text-xs text-base-content/70 font-normal"
>edits {{ .edit_app }}</span
>
{{ end }}
</td>
<td>
{{ template "builder_status_badge" .status }}
</td>
<td class="hidden md:table-cell">
{{ if .preview_path }}
<span
class="inline-flex items-center gap-1 max-w-52">
<span
class="font-mono text-xs truncate tooltip tooltip-right"
data-tip="{{ .preview_path }}"
>{{ .preview_path }}</span
>
<a
href="{{ .preview_path }}"
target="_blank"
rel="noopener"
class="opacity-0 group-hover:opacity-100 focus:opacity-100 transition-all duration-200"
aria-label="Open preview app {{ .name }} in a new tab">
{{ template "globe_icon" }}
</a>
</span>
{{ else }}
<span class="text-base-content/70 text-xs"
>not created yet</span
>
{{ end }}
</td>
<td class="hidden md:table-cell font-mono text-xs">
{{ .publish_path }}
</td>
<td class="hidden lg:table-cell text-xs">
{{ .agent }}
</td>
<td class="hidden lg:table-cell text-xs">
{{ .user_id }}
</td>
<td class="text-right">
<div class="inline-flex flex-col items-end sm:flex-row sm:items-center gap-1">
{{ $canWrite := index $.Data.Perms "builder:create" }}
{{ if or (eq .status "detached") (eq .status "error") }}
<button
class="btn btn-ghost btn-xs {{ if not $canWrite }}
tooltip tooltip-left
{{ end }}"
{{ if $canWrite }}
hx-post="{{ $.AppPath }}/builder/resume?id={{ .id }}"
hx-target="#builder-rows"
hx-disable="this"
hx-indicator="#page-progress"
{{ else }}
disabled data-tip="requires builder:create"
{{ end }}
aria-label="Resume session {{ .name }}">
Resume
</button>
{{ else if ne .status "published" }}
<button
class="btn btn-ghost btn-xs {{ if not $canWrite }}
tooltip tooltip-left
{{ end }}"
{{ if $canWrite }}
hx-post="{{ $.AppPath }}/builder/stop?id={{ .id }}"
hx-target="#builder-rows"
hx-disable="this"
hx-indicator="#page-progress"
{{ else }}
disabled data-tip="requires builder:create"
{{ end }}
aria-label="Stop session {{ .name }}">
Stop
</button>
{{ end }}
<button
class="btn btn-ghost btn-xs text-error {{ if not $canWrite }}
tooltip tooltip-left
{{ end }}"
{{ if $canWrite }}
hx-post="{{ $.AppPath }}/builder/delete?id={{ .id }}"
hx-confirm="Delete draft {{ .name }}? The
workspace and preview app are removed. A
published app stays live until unpublished."
hx-target="#builder-rows"
hx-disable="this"
hx-indicator="#page-progress"
{{ else }}
disabled data-tip="requires builder:create"
{{ end }}
aria-label="Delete session {{ .name }}">
Delete
</button>
</div>
</td>
</tr>
{{ end }}
</tbody>
</table>
</div>
</div>
{{ else }}
<div class="card bg-base-100 border border-base-300">
<div class="card-body items-center text-center py-10 gap-2">
{{ if .Data.Query }}
<h3 class="font-semibold">
No sessions match "{{ .Data.Query }}"
</h3>
{{ else }}
<h3 class="font-semibold">No builder sessions yet</h3>
<p class="text-sm text-base-content/70">
Describe the app you want and the AI agent builds it
with a live preview
</p>
<a
class="btn btn-xs btn-primary transition-transform duration-150 active:scale-95 {{ if not (index .Data.Perms "builder:create") }}
btn-disabled tooltip tooltip-top
{{ end }}"
{{ if index .Data.Perms "builder:create" }}
href="{{ .AppPath }}/builder/create"
{{ else }}
data-tip="requires builder:create"
{{ end }}
>+ New app</a
>
{{ end }}
</div>
</div>
{{ end }}
{{ end }}
<!-- End of "builder_rows" block -->
</div>
{{ template "page_close" . }}