feat: add static previews to the room pane
The preview tool could only name a port, so a static build needed a server the terminal had to keep alive. `preview` now accepts a path: the app reads the file or folder over the room's ssh sandbox and serves it from a signed host, with `..` and dotfiles refused and a 16 MiB cap. The target is stored with the room and replayed as a durable event. The pane shows a static path with a reload control and keeps the port field as a local fallback.
This commit is contained in:
1 parent
5be17cf4ef
commit
36de0aace7
20 files changed
+1046
-145
No files matched your search
@@ -8,6 +8,7 @@ import type {
|
||||
MessagePage,
|
||||
NoticeData,
|
||||
PresencePeer,
|
||||
PreviewTarget,
|
||||
Room,
|
||||
RoomDetailResponse,
|
||||
StepStartData,
|
||||
@@ -36,6 +37,7 @@ const detail = ref<RoomDetailResponse | null>(null)
|
||||
const detailLoading = ref(true)
|
||||
const detailError = ref('')
|
||||
|
||||
const previewTarget = ref<PreviewTarget | null>(null)
|
||||
const messages = ref<Message[]>([])
|
||||
const notices = ref<Array<{ seq: number; level: string; text: string }>>([])
|
||||
const activities = ref<TurnActivity[]>([])
|
||||
@@ -96,7 +98,7 @@ let presenceSocket: WebSocket | null = null
|
||||
let presenceTimer: number | null = null
|
||||
let presenceRetry = 0
|
||||
|
||||
const DURABLE_KINDS = new Set(['message', 'notice', 'turn_start', 'turn_end', 'tool_result'])
|
||||
const DURABLE_KINDS = new Set(['message', 'notice', 'turn_start', 'turn_end', 'tool_result', 'preview'])
|
||||
const BACKOFF = [1000, 2000, 5000, 10000]
|
||||
|
||||
useHead({
|
||||
@@ -235,6 +237,11 @@ function handleEnvelope(envelope: Envelope) {
|
||||
case 'message':
|
||||
addMessage(eventData<Message>(envelope))
|
||||
break
|
||||
case 'preview': {
|
||||
const data = eventData<PreviewTarget>(envelope)
|
||||
if (data && (data.kind === 'port' || data.kind === 'static')) previewTarget.value = data
|
||||
break
|
||||
}
|
||||
case 'notice': {
|
||||
const data = eventData<NoticeData>(envelope)
|
||||
addNotice(envelope.seq, data.level, data.text)
|
||||
@@ -638,6 +645,7 @@ async function loadDetail() {
|
||||
try {
|
||||
const response = await api.get<RoomDetailResponse>(`/rooms/${roomId.value}`)
|
||||
detail.value = response
|
||||
previewTarget.value = response.preview ?? null
|
||||
if (onlineIds.value.length === 0) {
|
||||
onlineIds.value = response.members.filter((member) => member.online).map((member) => member.id)
|
||||
}
|
||||
@@ -863,6 +871,7 @@ onBeforeUnmount(() => {
|
||||
v-if="paneOpen"
|
||||
:room-id="detail.room.id"
|
||||
:room-name="detail.room.name"
|
||||
:preview="previewTarget"
|
||||
@close="paneOpen = false"
|
||||
/>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user