The open source AI video agent: turns any coding agent into a video agent, with an editor to change anything it makes.
Chat: a read step names the file it read (#201)
WEBGRS046155fc6209
diff --git a/.changeset/read-step-file-name.md b/.changeset/read-step-file-name.mdnew file mode 100644index 0000000..6c0ff8b--- /dev/null+++ b/.changeset/read-step-file-name.md@@ -0,0 +1,5 @@+---+"@openfilm/desktop": patch+---++A read step in the chat names the file it read, whichever agent read it. Claude Code's ended as "File", OpenCode's and Copilot's as a long path cut short (OpenCode's without its drive) and Cursor's sometimes as the whole path; each now shows the file's name, as Codex's does.diff --git a/apps/desktop/chat/src/lib/local-agent-run.ts b/apps/desktop/chat/src/lib/local-agent-run.tsindex 4deee3e..e6146e3 100644--- a/apps/desktop/chat/src/lib/local-agent-run.ts+++ b/apps/desktop/chat/src/lib/local-agent-run.ts@@ -29,6 +29,7 @@ import type { Balance } from '@/lib/balance';import { chatTurns, putChatTurn, type SavedTurn } from '@/lib/chat-store';import { app } from '../app-bridge';import { isEmptyBackgroundTurn, opensUnprompted } from '@/lib/unprompted';+import { baseName, titleFile } from '@/lib/step-file';import { reduceTranscript, type TranscriptItem, type TranscriptPlanEntry } from '@/lib/agent-transcript';import {desktopBridge,@@ -73,10 +74,6 @@ function clipDetail(text: string): string {return one.length > DETAIL_MAX ? `${one.slice(0, DETAIL_MAX - 1)}…` : one;}-function baseName(path: string): string {- return path.replace(/[\\/]+$/, '').split(/[\\/]/).pop() ?? path;-}-/** The files this call touches: ACP's locations, and the path in diff content such as an edit's. */function touchedFiles(extra: LocalToolExtra | undefined, rawInput: Record<string, unknown>): string[] {const out: string[] = [];@@ -168,9 +165,11 @@ export function localToolActivity(const files = touchedFiles(extra, input);const detail = (value: string | undefined) => (value ? { detail: value } : {});switch (kind) {- case 'read':- /* Codex viewing an image (View Image …) is a read too */- return { act: 'files.read', ...detail(filesDetail(files) ?? (name ? clipDetail(name.replace(/^(?:Read|View Image)\s+/i, '')) : undefined)) };+ case 'read': {+ /* Codex viewing an image (View Image …) is a read too. No path given, its title may be one */+ const titled = titleFile(name);+ return { act: 'files.read', ...detail(filesDetail(files) ?? (titled ? clipDetail(titled) : undefined)) };+ }case 'search':if (/^web search/i.test(name)) return { act: 'research.search', ...(searchedFor(name, input) ? { query: searchedFor(name, input)! } : {}) };return { act: 'files.search', ...detail(searchedFor(name, input)) };diff --git a/apps/desktop/chat/src/lib/step-file.ts b/apps/desktop/chat/src/lib/step-file.tsnew file mode 100644index 0000000..31e7058--- /dev/null+++ b/apps/desktop/chat/src/lib/step-file.ts@@ -0,0 +1,23 @@+/**+ * The file a step of the user's own agent names in its row (lib/local-agent-run localToolActivity): the base name of+ * its path, with either separator.+ *+ * The path is where ACP puts it, in the call's locations or its input (`file_path`, `path`, `filePath`), and else+ * in its title. A read's last update often carries only its title, or nothing but what was read, and each agent+ * titles a read its own way: Claude Code "Read .film\cache\look\0-5s.png (1 - 40)", OpenCode the path without its+ * drive ("Users\me\…\0-5s.png"), Copilot "Viewing …\look\0-5s.png", Cursor "Read C:\…\SKILL.md". A title that is+ * no path (Claude Code's "Read File" before it knows which, OpenCode's "read") names no file, so the row keeps the+ * one it has.+ *+ * Pure: no React, no bridge, so `node --test` runs it (src/step-file.test.mjs).+ */++export function baseName(path: string): string {+ return path.replace(/[\\/]+$/, '').split(/[\\/]/).pop() ?? path;+}++/** The file a title names when it is a path, after its verb and line range; undefined when it is none. */+export function titleFile(title: string): string | undefined {+ const path = title.trim().replace(/^(?:Read|View Image|Viewing)\s+/i, '').replace(/\s+\((?:from line \d+|\d+ - \d+)\)$/, '');+ return /[\\/]|\.\w+$/.test(path) ? baseName(path) : undefined;+}diff --git a/apps/desktop/src/step-file.test.mjs b/apps/desktop/src/step-file.test.mjsnew file mode 100644index 0000000..a0230d4--- /dev/null+++ b/apps/desktop/src/step-file.test.mjs@@ -0,0 +1,33 @@+import { test } from 'node:test';+import assert from 'node:assert/strict';+import { baseName, titleFile } from '../chat/src/lib/step-file.ts';++test('a path names its file, with either separator', () => {+ assert.equal(baseName('C:\\Users\\me\\Videos\\OpenFilm\\Projects\\a film\\.film\\cache\\look\\0-5s.png'), '0-5s.png');+ assert.equal(baseName('/Users/me/Movies/OpenFilm/Projects/a film/film.html'), 'film.html');+ assert.equal(baseName('C:\\Users\\me\\Videos\\OpenFilm\\Projects\\a film\\'), 'a film');+ assert.equal(baseName('film.html'), 'film.html');+});++test('a read titled by its path names the file, as each agent titles it', () => {+ /* the titles of reads as the agents sent them on Windows, then two as on macOS */+ const titles = [+ ['Claude Code', 'Read .film\\cache\\look\\0-5s.png', '0-5s.png'],+ ['Claude Code', 'Read scenes\\title.html (76 - 81)', 'title.html'],+ ['Claude Code', 'Read scenes\\title.html (from line 76)', 'title.html'],+ ['OpenCode', 'Users\\me\\Videos\\OpenFilm\\Projects\\a film\\.film\\cache\\look\\0-5s.png', '0-5s.png'],+ ['Copilot', 'Viewing ...ts\\a film\\.film\\cache\\look\\0-5s.png', '0-5s.png'],+ ['Copilot', 'Viewing ...eos\\OpenFilm\\Projects\\a film', 'a film'],+ ['Cursor', 'Read C:\\Users\\me\\.claude\\skills\\openfilm\\SKILL.md', 'SKILL.md'],+ ['Cursor', 'Read film.html', 'film.html'],+ ['Codex', 'View Image C:\\Users\\me\\Videos\\OpenFilm\\Projects\\a film\\.film\\cache\\look\\0-5s.png', '0-5s.png'],+ ['Claude Code', 'Read .film/cache/look/0-5s.png (1 - 40)', '0-5s.png'],+ ['OpenCode', 'Users/me/Movies/OpenFilm/Projects/a film/film.html', 'film.html'],+ ];+ for (const [agent, title, file] of titles) assert.equal(titleFile(title), file, `${agent}: ${title}`);+});++test('a title that is no path names no file, so the row keeps the one it has', () => {+ /* Claude Code's before it knows which file, kept for the call's later updates; OpenCode's at first */+ for (const title of ['Read File', 'read', '']) assert.equal(titleFile(title), undefined, title);+});