-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuilder_session.go.html
More file actions
737 lines (719 loc) · 36.4 KB
/
Copy pathbuilder_session.go.html
File metadata and controls
737 lines (719 loc) · 36.4 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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
{{/* Copyright (c) ClaceIO, LLC */}}
{{/* SPDX-License-Identifier: Apache-2.0 */}}
{{/* Builder session workspace (/builder/detail?id=...): chat pane + live
preview + publish. HTMX partial: block session_content. The chat pane
live-updates via <builder-chat> (builderchat.js) consuming the
/builder/events JSON-line stream; this page render is the durable
transcript from the activity log
*/}}
<!DOCTYPE html>
<html lang="en">
{{ template "head" . }}
<body class="min-h-screen bg-base-200">
<script src="{{ static "builderchat.js" }}"></script>
<script src="{{ static "vendor/highlight.min.js" }}"></script>
<script src="{{ static "builderfiles.js" }}"></script>
<div class="drawer lg:drawer-open">
{{ template "drawer_toggle" }}
<div class="drawer-content">
<main class="p-4 lg:p-6 space-y-4">
<!-- Header -->
<div
class="page-header flex items-center gap-2 flex-wrap mb-2 md:mb-6">
{{ template "hamburger" . }}
<div>
{{ template "page_title" "OpenRun Builder" }}
<div class="flex items-center gap-2">
<nav
aria-label="Breadcrumb"
class="breadcrumbs text-xs text-base-content/70 p-0">
<ul>
<li><a href="{{ .AppPath }}/builder">Builder</a></li>
<li>
{{ if .Data.Session }}
{{ .Data.Session.name }}
{{ else }}
session
{{ end }}
</li>
</ul>
</nav>
{{ template "help_link" .Data.HelpUrl }}
</div>
<h2 class="text-xl font-semibold">
{{ if .Data.Session }}
{{ .Data.Session.name }}
{{ else }}
Session
{{ end }}
</h2>
<p class="page-desc text-sm text-base-content/70">
Chat with the agent, see the app preview
</p>
</div>
</div>
{{ template "page_progress" }}
{{ template "error_alert" .Data.Error }}
{{ if .Data.Session }}
<div
id="session-content"
hx-get="{{ .AppPath }}/builder/detail?id={{ .Data.Id }}"
hx-trigger="builder-turn-done"
hx-target="#session-content"
hx-swap="innerHTML transition:true"
hx-indicator="#page-progress">
{{ block "session_content" . }}
{{ template "flash_alerts" .Data }}
{{ $s := .Data.Session }}
{{ $canWrite := index .Data.Perms "builder:create" }}
{{ $canPublish := index .Data.Perms "builder:publish" }}
<!-- Status + actions row -->
<div class="flex items-center gap-2 flex-wrap mb-4">
{{ template "builder_status_badge" $s.status }}
{{ if $s.edit_app }}
<a
href="{{ .AppPath }}/apps/detail?path={{ $s.edit_app }}"
class="badge badge-sm badge-info badge-soft font-mono tooltip tooltip-bottom"
data-tip="This session edits the app {{ $s.edit_app }}"
>editing {{ $s.edit_app }}</a
>
{{ end }}
<span class="text-xs text-base-content/70"
>{{ if $s.profile }}
profile: {{ $s.profile }} ·
{{ end }}agent:
{{ $s.agent }}{{ if $s.spec }}
· spec: {{ $s.spec }}
{{ end }}{{ if $s.services }}
· services:
{{ range $i, $svc := $s.services }}
{{ if $i }},{{ end }}{{ $svc }}
{{ end }}
{{ end }}</span
>
<div
class="page-actions ml-auto flex items-center gap-2 flex-wrap">
{{ if $s.preview_path }}
<button
class="btn btn-ghost btn-sm {{ if not (or (index .Data.Perms "app:approve") (index .Data.Perms "admin")) }}
tooltip tooltip-bottom
{{ end }}"
{{ if or (index .Data.Perms "app:approve") (index .Data.Perms "admin") }}
hx-post="{{ .AppPath }}/builder/detail/approve?id={{ $s.id }}"
hx-disabled-elt="this"
{{ else }}
disabled data-tip="requires the app:approve
permission"
{{ end }}>
Approve permissions
</button>
{{ end }}
{{/* Key off IsLive, not status: a published session keeps
its "published" status after the sandbox is reaped, so
status alone would hide Resume and offer a Stop with
nothing to stop
*/}}
{{ if not .Data.IsLive }}
<button
class="btn btn-ghost btn-sm"
{{ if $canWrite }}
hx-post="{{ .AppPath }}/builder/detail/resume?id={{ $s.id }}"
hx-disabled-elt="this"
{{ else }}
disabled data-tip="requires builder:create"
{{ end }}>
Resume
</button>
{{ else }}
<button
class="btn btn-ghost btn-sm"
{{ if $canWrite }}
hx-post="{{ .AppPath }}/builder/detail/stop?id={{ $s.id }}"
hx-disabled-elt="this"
{{ else }}
disabled data-tip="requires builder:create"
{{ end }}>
Stop sandbox
</button>
{{ end }}
<button
class="btn btn-ghost btn-sm text-error"
{{ if $canWrite }}
hx-post="{{ .AppPath }}/builder/detail/delete?id={{ $s.id }}"
hx-confirm="Delete draft {{ $s.name }}? The workspace
and preview app are
removed.{{ if $s.publish_path }}
The published app at {{ $s.publish_path }} stays live
until unpublished.
{{ end }}"
hx-disabled-elt="this"
{{ else }}
disabled data-tip="requires builder:create"
{{ end }}>
Delete draft
</button>
<details class="dropdown dropdown-end">
<summary
class="btn btn-primary btn-sm {{ if or (not $canPublish) (not $s.preview_path) }}
btn-disabled tooltip tooltip-bottom
{{ end }}"
{{ if not $canPublish }}
data-tip="requires builder:publish"
{{ else if not $s.preview_path }}
data-tip="the app must load in preview before
publishing"
{{ end }}>
{{ if and $s.edit_app $s.publish_path }}
Publish update
{{ else if $s.publish_path }}
Republish
{{ else }}
Publish
{{ end }}
</summary>
<div
class="dropdown-content z-10 card bg-base-100 border border-base-300 w-[26rem] max-w-[90vw] max-h-[calc(100vh-8rem)] overflow-y-auto shadow-lg">
{{ template "publish_form" . }}
</div>
</details>
</div>
</div>
{{ if .Data.PublishResult }}
<div
class="alert alert-success alert-soft py-2 text-sm mb-4 min-w-0"
role="status"
aria-live="polite">
<div class="min-w-0 break-words">
<div>
Published
<span class="font-mono break-all"
>{{ .Data.PublishResult.publish_path }}</span
>
({{ .Data.PublishResult.mode }} mode)
{{ if .Data.PublishResult.commit_sha }}
- commit
<span class="font-mono"
>{{ .Data.PublishResult.commit_sha | trunc 12 }}</span
>
{{ end }}
</div>
{{ if eq .Data.PublishResult.mode "git" }}
<div class="text-xs">
Apps go live when the prod sync runs
</div>
{{ end }}
</div>
</div>
{{ end }}
{{ if .Data.AskPromotePath }}
<!-- The publish landed on staging, ask about promotion -->
<div class="mb-4">
{{ template "promote_prompt" (dict
"Message" "The changes were applied to the staging app. Promote to make them live on prod?"
"Path" .Data.AskPromotePath
"PostUrl" (print .AppPath "/builder/detail/promote?id=" .Data.Id)
"Target" "#session-content"
"KeepHref" (print .AppPath "/apps/detail?path=" .Data.AskPromotePath)
"Perms" .Data.Perms)
}}
</div>
{{ end }}
{{ if $s.publish_path }}
<div class="text-xs text-base-content/70 mb-4">
Published at
<span class="font-mono">{{ $s.publish_path }}</span
><a
href="{{ .AppPath }}/apps/detail?path={{ $s.publish_path }}"
data-tip="View app details"
aria-label="View app details for {{ $s.publish_path }}"
class="inline-block text-primary ml-1 tooltip tooltip-top"
>app detail <span aria-hidden="true">↗</span></a
>
{{ if not $s.edit_app }}
<button
class="btn btn-ghost btn-xs text-error ml-2"
{{ if $canPublish }}
hx-post="{{ .AppPath }}/builder/detail/unpublish?id={{ $s.id }}"
hx-confirm="Unpublish {{ $s.publish_path }}?
{{ if eq .Data.PublishMode "git" }}
The removal is committed to the repo; the prod sync
decides whether the app is deleted.
{{ else }}
The app is deleted from this server.
{{ end }}"
hx-disabled-elt="this"
{{ else }}
disabled data-tip="requires builder:publish"
{{ end }}>
Unpublish
</button>
{{ end }}
</div>
{{ end }}
<!-- Workspace split: chat left, preview right, equal height -->
<div class="builder-split grid grid-cols-1 gap-4">
<!-- Chat pane -->
<div
class="bs-chat card bg-base-100 border border-base-300 shadow-sm overflow-hidden"
style="height: calc(100vh - 250px); min-height: 480px">
<div class="card-body p-0 h-full flex flex-col gap-0">
<div
class="flex items-center gap-2 px-4 py-2.5 border-b border-base-300 bg-base-200/50">
<svg
aria-hidden="true"
focusable="false"
class="w-4 h-4 text-primary"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round">
<path d="M12 8V4H8" />
<rect width="16" height="12" x="4" y="8" rx="2" />
<path d="M2 14h2" />
<path d="M20 14h2" />
<path d="M15 13v2" />
<path d="M9 13v2" />
</svg>
<h3 class="font-semibold text-sm">Agent</h3>
{{ if .Data.SandboxContainerId }}
<a
href="{{ .AppPath }}/containers/detail?id={{ .Data.SandboxContainerId }}"
data-tip="Agent container detail and logs (raw ACP traffic)"
aria-label="Agent container detail for this session"
class="inline-block text-primary text-xs"
>agent <span aria-hidden="true">↗</span></a
>
{{ end }}
<span
class="bc-status text-xs text-base-content/70 truncate"
role="status"></span>
<button
type="button"
class="btn btn-ghost btn-xs text-error ml-auto {{ if not .Data.TurnActive }}
hidden
{{ end }}"
data-builder-cancel
{{ if $canWrite }}
hx-post="{{ .AppPath }}/builder/detail/cancel?id={{ $s.id }}"
hx-swap="none"
{{ else }}
disabled data-tip="requires builder:create"
{{ end }}>
<span
class="loading loading-spinner loading-xs"
aria-hidden="true"></span>
Stop
</button>
</div>
<builder-chat
class="flex-1 min-h-0 flex flex-col"
stream="{{ .AppPath }}/builder/events?id={{ $s.id }}"
session="{{ $s.id }}"
{{ if .Data.IsLive }}live{{ end }}
{{ if .Data.TurnActive }}turn-active{{ end }}>
<div
class="bc-transcript flex-1 min-h-0 space-y-1.5 overflow-y-auto px-3 py-2"
aria-label="Conversation with the agent"
aria-live="polite">
{{ range .Data.Messages }}
{{ if eq .kind "prompt" }}
<div class="chat chat-end">
<div
class="chat-bubble chat-bubble-primary whitespace-pre-wrap text-sm shadow-sm">
{{ .content | trim }}
</div>
</div>
{{ else if eq .kind "agent_message" }}
<div class="chat chat-start">
<div
class="chat-bubble bc-md bg-base-200 text-base-content whitespace-pre-wrap text-sm shadow-sm">
{{ .content | trim }}
</div>
</div>
{{ else if eq .kind "tool_call" }}
<div
class="pl-1 flex items-center flex-wrap gap-x-2 gap-y-0.5 text-xs text-base-content/70">
<svg
aria-hidden="true"
focusable="false"
class="w-3 h-3 shrink-0"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round">
<path
d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z" />
</svg>
{{ range .parts }}
<span
class="inline-flex items-center gap-1 font-mono">
<span
class="bc-tool-title"
title="{{ .text | trim }}"
>{{- .text | trim -}}</span
>
{{- if gt .count 1 }}
<span
class="badge badge-soft badge-primary badge-xs font-mono tooltip tooltip-top"
data-tip="{{ .count }} tool calls"
>×{{ .count }}</span
>
{{ end -}}
</span>
{{ end }}
</div>
{{ else if eq .kind "error" }}
<div
class="pl-1 text-error text-xs whitespace-pre-wrap break-words">
{{ .content | trim }}
</div>
{{ else if eq .kind "lifecycle" }}
<div class="pl-1 text-base-content/50 text-xs">
{{- range $i, $part := .parts }}
{{ if $i }}
·
{{ end }}{{ $part.text }}{{ if gt $part.count 1 }}
×{{ $part.count }}
{{ end }}
{{ end -}}
</div>
{{ else }}
<div class="pl-1 text-base-content/50 text-xs">
{{ .content | trim }}
</div>
{{ end }}
{{ end }}
{{ if .Data.Partial }}
<div class="chat chat-start" data-bc-streaming>
<div
class="chat-bubble bc-md bg-base-200 text-base-content whitespace-pre-wrap text-sm shadow-sm">
{{ .Data.Partial | trim }}
</div>
</div>
{{ end }}
</div>
{{/* Failed sends land here via HX-Retarget: the
composer posts with hx-swap=none (the chat
renders from SSE events), so without this slot a
rejected message (agent busy, session still
starting) would be invisible
*/}}
<div id="bc-send-error" class="px-3">
{{ template "bc_send_error" . }}
</div>
<form
class="flex items-end gap-2 px-2.5 py-2 border-t border-base-300 bg-base-200/30"
hx-post="{{ .AppPath }}/builder/detail/message?id={{ $s.id }}"
hx-swap="none"
data-builder-composer>
<textarea
name="message"
rows="2"
class="textarea textarea-bordered flex-1 text-sm resize-y min-h-16 max-h-48 focus:textarea-primary"
placeholder="{{ if .Data.IsLive }}
Ask for a change…
{{ else }}
Sandbox is stopped - resume to continue
{{ end }}"
aria-label="Message to the agent"
{{ if not .Data.IsLive }}
disabled
{{ end }}></textarea>
<button
type="submit"
class="btn btn-primary btn-sm btn-circle transition-transform duration-150 active:scale-95 {{ if not (and $canWrite .Data.IsLive) }}
tooltip tooltip-top
{{ end }}"
aria-label="Send message"
{{ if not (and $canWrite .Data.IsLive) }}
disabled
data-tip="{{ if not $canWrite }}
requires builder:create
{{ else }}
sandbox is stopped
{{ end }}"
{{ end }}>
<svg
aria-hidden="true"
focusable="false"
class="w-4 h-4"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round">
<path d="m5 12 14-9-4 18-4.5-7z" />
<path d="M19 3 10.5 14" />
</svg>
</button>
</form>
</builder-chat>
</div>
</div>
<!-- Drag handle between the panes (xl+ only); arrow keys
resize when focused -->
<div
class="bs-divider hidden xl:flex"
data-bc-splitter
role="separator"
aria-orientation="vertical"
aria-label="Resize agent and preview panes"
tabindex="0"></div>
<!-- Preview / Files pane -->
<div
class="bs-preview card bg-base-100 border border-base-300 shadow-sm overflow-hidden"
style="height: calc(100vh - 250px); min-height: 480px"
data-bf-tabs>
<div class="card-body p-0 h-full flex flex-col gap-0">
<!-- Browser-style header bar -->
<div
class="flex items-center gap-2 px-4 py-2.5 border-b border-base-300 bg-base-200/50">
<span class="flex gap-1.5" aria-hidden="true">
<span
class="w-2.5 h-2.5 rounded-full bg-base-300"></span>
<span
class="w-2.5 h-2.5 rounded-full bg-base-300"></span>
<span
class="w-2.5 h-2.5 rounded-full bg-base-300"></span>
</span>
<div
class="tabs tabs-box tabs-xs p-0.5"
role="tablist"
aria-label="Preview or workspace files">
<button
type="button"
role="tab"
class="tab tab-active"
aria-selected="true"
data-bf-tab="preview">
Preview
</button>
<button
type="button"
role="tab"
class="tab"
aria-selected="false"
data-bf-tab="files">
Files{{ if .Data.Files }}
({{ len .Data.Files }})
{{ end }}
</button>
</div>
{{ if .Data.Files }}
<a
href="{{ $.AppPath }}/builder/download?id={{ .Data.Id }}"
download
class="btn btn-ghost btn-xs btn-circle tooltip tooltip-left"
data-tip="Download the source files as a zip"
aria-label="Download the source files as a zip">
<svg
aria-hidden="true"
focusable="false"
class="w-3.5 h-3.5"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round">
<path
d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" />
<polyline points="7 10 12 15 17 10" />
<line x1="12" y1="3" x2="12" y2="15" />
</svg>
</a>
{{ end }}
{{ if $s.preview_path }}
<span
class="flex-1 min-w-0 bg-base-100 border border-base-300 rounded-full px-3 py-1 font-mono text-xs text-base-content/70 truncate"
>{{ $s.preview_path }}</span
>
<button
type="button"
class="btn btn-ghost btn-xs btn-circle"
data-builder-refresh
aria-label="Refresh preview">
<svg
aria-hidden="true"
focusable="false"
class="w-3.5 h-3.5"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round">
<path
d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8" />
<path d="M21 3v5h-5" />
<path
d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16" />
<path d="M8 16H3v5" />
</svg>
</button>
<a
href="{{ $s.preview_path }}"
target="_blank"
rel="noopener"
class="btn btn-ghost btn-xs btn-circle"
aria-label="Open preview app in a new tab">
{{ template "globe_icon" }}
</a>
{{ else }}
<span
class="flex-1 min-w-0 bg-base-100 border border-base-300 rounded-full px-3 py-1 font-mono text-xs text-base-content/40 truncate"
>waiting for a loadable app…</span
>
{{ end }}
</div>
<div
class="flex-1 min-h-0 flex flex-col p-2"
data-bf-panel="preview">
{{ if $s.preview_path }}
<iframe
id="builder-preview"
src="{{ $s.preview_path }}"
title="Preview of {{ $s.name }}"
class="flex-1 w-full bg-base-200 rounded-lg border border-base-300"></iframe>
{{ else }}
<div
class="flex-1 flex flex-col items-center justify-center gap-4 text-sm text-base-content/70 p-6 text-center">
{{ if .Data.PreviewError }}
<div
class="alert alert-error text-left text-xs max-w-lg"
role="alert">
<span class="whitespace-pre-wrap break-all"
>{{ .Data.PreviewError }}</span
>
</div>
<p class="max-w-md">
The app failed to load. Ask the agent to fix the
error above - the preview is retried after every
agent reply.
</p>
{{ else }}
<svg
aria-hidden="true"
focusable="false"
class="w-12 h-12 text-base-content/20"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round">
<path
d="M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z" />
<path d="M20 3v4" />
<path d="M22 5h-4" />
<path d="M4 17v2" />
<path d="M5 18H3" />
</svg>
{{ if and .Data.Files (not .Data.HasAppStar) }}
<p class="max-w-md">
The workspace has no
<span class="font-mono">app.star</span>
yet, which OpenRun needs to serve the app. Ask
the agent to "add the app.star OpenRun app
definition" - the preview is retried after
every agent reply.
</p>
{{ else }}
<p class="max-w-md font-medium">
Your app will appear here
</p>
<p
class="max-w-md text-xs text-base-content/50">
The live preview loads automatically once the
agent's first pass produces a loadable app
</p>
{{ end }}
{{ end }}
</div>
{{ end }}
</div>
<!-- Files panel: explorer tree + read-only viewer -->
<builder-files
class="flex-1 min-h-0"
endpoint="{{ .AppPath }}/builder/file?id={{ $s.id }}"
data-bf-panel="files"
hidden>
<nav
class="bf-tree shrink-0 overflow-y-auto bg-base-200/30 py-2 text-xs"
aria-label="Workspace files">
{{ if .Data.FileTree }}
{{ range .Data.FileTree }}
{{ if .is_dir }}
<div
class="flex items-center gap-1.5 px-3 py-1 text-base-content/70 font-medium"
style="padding-left: calc(0.75rem + {{ .depth }} * 0.75rem)">
<svg
aria-hidden="true"
class="w-3.5 h-3.5 shrink-0"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round">
<path
d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z" />
</svg>
<span class="truncate">{{ .name }}</span>
</div>
{{ else }}
<button
type="button"
data-bf-file="{{ .path }}"
class="flex items-center gap-1.5 w-full text-left px-3 py-1 font-mono hover:bg-base-200 rounded-none"
style="padding-left: calc(0.75rem + {{ .depth }} * 0.75rem)">
<svg
aria-hidden="true"
class="w-3.5 h-3.5 shrink-0 text-base-content/50"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round">
<path
d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z" />
<path d="M14 2v4a2 2 0 0 0 2 2h4" />
</svg>
<span class="truncate">{{ .name }}</span>
</button>
{{ end }}
{{ end }}
{{ else }}
<p class="px-3 py-2 text-base-content/60">
No files yet
</p>
{{ end }}
</nav>
<div class="bf-viewer flex-1 min-w-0 flex flex-col">
<div
class="bf-name px-4 py-1.5 border-b border-base-300 font-mono text-xs text-base-content/70 truncate"></div>
<div class="bf-body flex-1 min-h-0">
<div class="bf-gutter" aria-hidden="true"></div>
<pre class="bf-code"><code></code></pre>
</div>
</div>
</builder-files>
</div>
</div>
</div>
{{ end }}
<!-- End of "session_content" block -->
</div>
{{ end }}
</main>
</div>
{{ template "sidebar" . }}
</div>
</body>
</html>