Desktop app that records your on-screen work session and uses the GitHub Copilot SDK to reconstruct it as an intent + ordered steps, then builds a reusable Skill or Automation for Microsoft Autopilots like Scout, Microsoft Copilot Cowork, or Copilot Studio.
TypeScript agent-skillsai-agentsautomationcopilotcopilot-clicopilot-coworkcopilot-studioelectronmicrosoft-scoutscreen-recording
Show session disk usage
Giorgio Ughini0cb1ba36a68b
diff --git a/common/ipc.ts b/common/ipc.tsindex 7765e11..42ce81e 100644--- a/common/ipc.ts+++ b/common/ipc.ts@@ -16,6 +16,8 @@ export interface SessionSummary {startedAt: number | null;stoppedAt: number | null;durationMs: number | null;+ /** Total bytes occupied by all files under this session's directory. */+ sizeBytes: number | null;/** True once post-processing produced a bundle. */processed: boolean;hasVideo: boolean;diff --git a/electron/sessions.test.ts b/electron/sessions.test.tsnew file mode 100644index 0000000..b53df25--- /dev/null+++ b/electron/sessions.test.ts@@ -0,0 +1,43 @@+import assert from "node:assert/strict";+import { access, mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";+import { tmpdir } from "node:os";+import path from "node:path";+import test from "node:test";++import { deleteSession, listSessions } from "./sessions";++test("session size includes every artifact and deletion removes the whole directory", async () => {+ const root = await mkdtemp(path.join(tmpdir(), "skill-recorder-sessions-"));+ const previousRoot = process.env.SKILL_RECORDER_SESSIONS_DIR;+ process.env.SKILL_RECORDER_SESSIONS_DIR = root;++ try {+ const id = "storage-test";+ const dir = path.join(root, id);+ await mkdir(path.join(dir, "video-frames"), { recursive: true });+ await mkdir(path.join(dir, "frames"), { recursive: true });++ const artifacts: [string, string | Uint8Array][] = [+ ["session.json", JSON.stringify({ id, startedAt: 1_000, stoppedAt: 2_000 })],+ ["video.webm", Buffer.alloc(17, 1)],+ ["audio.webm", Buffer.alloc(19, 2)],+ [path.join("video-frames", "frame_000001.jpg"), Buffer.alloc(23, 3)],+ [path.join("frames", "event_1000.jpg"), Buffer.alloc(29, 4)],+ ];+ for (const [file, data] of artifacts) await writeFile(path.join(dir, file), data);++ const [summary] = await listSessions();+ const expectedBytes = artifacts.reduce(+ (sum, [, data]) => sum + (typeof data === "string" ? Buffer.byteLength(data) : data.byteLength),+ 0,+ );+ assert.equal(summary?.sizeBytes, expectedBytes);++ await deleteSession(id);+ await assert.rejects(access(dir), { code: "ENOENT" });+ } finally {+ if (previousRoot === undefined) delete process.env.SKILL_RECORDER_SESSIONS_DIR;+ else process.env.SKILL_RECORDER_SESSIONS_DIR = previousRoot;+ await rm(root, { recursive: true, force: true });+ }+});diff --git a/electron/sessions.ts b/electron/sessions.tsindex 2ae901b..007ac21 100644--- a/electron/sessions.ts+++ b/electron/sessions.ts@@ -1,12 +1,16 @@-import { access, readdir, readFile, rm, stat } from "node:fs/promises";+import { access, lstat, readdir, readFile, rm, stat } from "node:fs/promises";import path from "node:path";import { AnalysisSchema, type Analysis } from "../common/analysis";import type { SessionSummary } from "../common/ipc";import { NARRATION_FILE, type NarrationTranscript } from "../common/narration";import type { SessionMeta } from "../common/types";+import { createLogger } from "./logger";import { isValidSessionId, sessionDir, sessionsRoot } from "./recorder/session-store";+const log = createLogger("Sessions");+const SIZE_STAT_BATCH = 64;+/** True when `file` exists (non-throwing `fs.access`). */async function exists(file: string): Promise<boolean> {try {@@ -42,6 +46,57 @@ async function loadNarration(}}+function isMissing(error: unknown): boolean {+ return (+ typeof error === "object" &&+ error !== null &&+ "code" in error &&+ error.code === "ENOENT"+ );+}++/** Sum file and link sizes without following links outside the session directory. */+export async function sessionDirectorySize(root: string): Promise<number> {+ const pending = [root];+ let total = 0;++ while (pending.length > 0) {+ const dir = pending.pop();+ if (!dir) break;++ let entries;+ try {+ entries = await readdir(dir, { withFileTypes: true });+ } catch (error) {+ if (isMissing(error)) continue;+ throw error;+ }++ const files: string[] = [];+ for (const entry of entries) {+ const file = path.join(dir, entry.name);+ if (entry.isDirectory()) pending.push(file);+ else files.push(file);+ }++ for (let start = 0; start < files.length; start += SIZE_STAT_BATCH) {+ const stats = await Promise.all(+ files.slice(start, start + SIZE_STAT_BATCH).map(async (file) => {+ try {+ return await lstat(file);+ } catch (error) {+ if (isMissing(error)) return null;+ throw error;+ }+ }),+ );+ for (const info of stats) total += info?.size ?? 0;+ }+ }++ return total;+}+/** Build the library summary for a single session dir, or null if it isn't one. */async function summarize(root: string, name: string): Promise<SessionSummary | null> {const dir = path.join(root, name);@@ -59,21 +114,30 @@ async function summarize(root: string, name: string): Promise<SessionSummary | n}if (!meta?.id) return null;- const [analysis, processed, hasVideo, hasAudio, narration, hasSkill, hasAutomation] = await Promise.all([- loadAnalysis(dir),- exists(path.join(dir, "bundle.json")),- exists(path.join(dir, "video.json")),- exists(path.join(dir, "audio.json")),- loadNarration(dir),- exists(path.join(dir, "skill.json")),- exists(path.join(dir, "built-automation.json")),- ]);+ const [analysis, processed, hasVideo, hasAudio, narration, hasSkill, hasAutomation, sizeBytes] =+ await Promise.all([+ loadAnalysis(dir),+ exists(path.join(dir, "bundle.json")),+ exists(path.join(dir, "video.json")),+ exists(path.join(dir, "audio.json")),+ loadNarration(dir),+ exists(path.join(dir, "skill.json")),+ exists(path.join(dir, "built-automation.json")),+ sessionDirectorySize(dir).catch((error) => {+ log.warn(+ `could not measure session ${name}:`,+ error instanceof Error ? error.message : String(error),+ );+ return null;+ }),+ ]);return {id: meta.id,startedAt: meta.startedAt ?? null,stoppedAt: meta.stoppedAt ?? null,durationMs: meta.startedAt && meta.stoppedAt ? meta.stoppedAt - meta.startedAt : null,+ sizeBytes,processed,hasVideo,hasAudio,diff --git a/package.json b/package.jsonindex e422b37..ac97339 100644--- a/package.json+++ b/package.json@@ -14,7 +14,7 @@"build": "tsc --noEmit && vite build","typecheck": "tsc --noEmit","typecheck:evals": "tsc --noEmit -p evals/tsconfig.json",- "test": "node --experimental-transform-types --no-warnings --import ./evals/register.mjs --test electron/frames/extractor.test.ts electron/narration/audio-analysis.test.ts",+ "test": "node --experimental-transform-types --no-warnings --import ./evals/register.mjs --test electron/frames/extractor.test.ts electron/narration/audio-analysis.test.ts electron/sessions.test.ts","eval": "node --experimental-transform-types --no-warnings --import ./evals/register.mjs evals/run.ts","eval:builder": "node --experimental-transform-types --no-warnings --import ./evals/register.mjs evals/builder/run.ts","eval:skill": "node --experimental-transform-types --no-warnings --import ./evals/register.mjs evals/skillbuilder/run.ts",diff --git a/src/App.css b/src/App.cssindex ab655dd..748dac8 100644--- a/src/App.css+++ b/src/App.css@@ -1008,6 +1008,11 @@ button:focus-visible,color: var(--faint);}+.sess-size {+ font-size: 9px;+ color: var(--faint);+}+/* Per-row delete: a quiet trash affordance revealed on hover/focus, plus aninline confirm that swaps in so deletion always takes a deliberate second tap. */.sess-row {diff --git a/src/Library.tsx b/src/Library.tsxindex e77a049..5198974 100644--- a/src/Library.tsx+++ b/src/Library.tsx@@ -24,7 +24,7 @@ import {ScheduleEditor,SkillStepTiles,} from "./plan-edit";-import { formatDur, formatWhen, shortLabel } from "./format";+import { formatBytes, formatDur, formatWhen, shortLabel } from "./format";export function Library() {const [sessions, setSessions] = useState<SessionSummary[]>([]);@@ -145,7 +145,10 @@ function SessionsList({<div className="sess-confirm" role="alertdialog" aria-label="Confirm delete"><div className="sess-confirm-text"><span className="sess-confirm-title">Delete this recording?</span>- <span className="sess-confirm-sub">This cannot be undone.</span>+ <span className="sess-confirm-sub">+ This cannot be undone.+ {s.sizeBytes != null && ` Frees ${formatBytes(s.sizeBytes)} from this device.`}+ </span></div><div className="sess-confirm-actions"><button className="linky" onClick={() => setConfirmId(null)}>@@ -193,6 +196,14 @@ function SessionsList({</div><div className="sess-sub">{s.durationMs != null && <span>{formatDur(s.durationMs)}</span>}+ {s.sizeBytes != null && (+ <span+ className="sess-size"+ title={`${s.sizeBytes.toLocaleString()} bytes used by this recording`}+ >+ {formatBytes(s.sizeBytes)}+ </span>+ )}{s.analysis && <span>{s.analysis.stepCount} steps</span>}{s.hasVideo && <span>video</span>}{s.hasAudio && !s.hasNarration && <span>voice pending</span>}diff --git a/src/format.ts b/src/format.tsindex 6f4606d..b7be0f1 100644--- a/src/format.ts+++ b/src/format.ts@@ -13,6 +13,21 @@ export function formatDur(ms: number): string {return `${Math.floor(s / 60)}m ${s % 60}s`;}+/** Compact binary file size, e.g. "824 KB" or "12.4 MB". */+export function formatBytes(bytes: number): string {+ if (!Number.isFinite(bytes) || bytes <= 0) return "0 B";+ if (bytes < 1024) return `${Math.round(bytes)} B`;++ const units = ["KB", "MB", "GB", "TB"];+ let value = bytes / 1024;+ let unit = 0;+ while (value >= 1024 && unit < units.length - 1) {+ value /= 1024;+ unit++;+ }+ return `${Number(value.toFixed(1))} ${units[unit]}`;+}+/*** Compact one-line label derived from a full intent sentence. Used as the* sessions-list name when an analysis has no short `title` (older analyses saved