feat: show screen thumbnails in pod streams

This commit is contained in:
Yahya Alhinai
2026-06-28 05:33:00 +00:00
parent 1080bfd85f
commit c771e1594c
6 changed files with 39 additions and 8 deletions
+1
View File
@@ -47,6 +47,7 @@ function observationEvent(doc: EngineerContext): PodActivityEvent {
actor: doc.engineerId,
actors: [doc.engineerId],
file,
imageUrl: doc.screenshotDataUrl,
title: file ? `Working in ${file}` : 'Screen context updated',
detail: [
symbol ? `symbol ${symbol}` : undefined,
+18 -7
View File
@@ -20,6 +20,7 @@ import { initMemory } from './memory/db.js';
const POD_ROOM = process.env.POD_ROOM ?? 'demo-pod';
const HERMES_IDENTITY = 'podman-hermes';
const SAMPLE_INTERVAL_MS = 1000; // ~1 fps to the vision model
const SCREEN_THUMBNAIL_WIDTH = 360;
const SHUTDOWN_GRACE_MS = 5000;
async function agentToken(room: string): Promise<string> {
@@ -91,13 +92,23 @@ async function main() {
try {
const rgba = event.frame.convert(VideoBufferType.RGBA);
const jpeg = await sharp(Buffer.from(rgba.data), {
raw: { width: rgba.width, height: rgba.height, channels: 4 },
})
.resize({ width: 1280, withoutEnlargement: true })
.jpeg({ quality: 70 })
.toBuffer();
await podman.onScreenFrame(engineerId, jpeg);
const pixels = Buffer.from(rgba.data);
const raw = { width: rgba.width, height: rgba.height, channels: 4 } as const;
const [jpeg, thumbnail] = await Promise.all([
sharp(pixels, { raw })
.resize({ width: 1280, withoutEnlargement: true })
.jpeg({ quality: 70 })
.toBuffer(),
sharp(pixels, { raw })
.resize({ width: SCREEN_THUMBNAIL_WIDTH, withoutEnlargement: true })
.jpeg({ quality: 42 })
.toBuffer(),
]);
await podman.onScreenFrame(
engineerId,
jpeg,
`data:image/jpeg;base64,${thumbnail.toString('base64')}`,
);
} finally {
inFlight.delete(engineerId);
}
+2 -1
View File
@@ -46,8 +46,9 @@ export class PodMan {
});
}
async onScreenFrame(engineerId: string, jpeg: Buffer): Promise<void> {
async onScreenFrame(engineerId: string, jpeg: Buffer, screenshotDataUrl?: string): Promise<void> {
const ctx = await analyzeFrame(engineerId, this.podId, jpeg);
if (screenshotDataUrl) ctx.screenshotDataUrl = screenshotDataUrl;
this.contexts.set(engineerId, ctx);
await recordObservation(ctx);