fix: highlight CSV without changing the default spreadsheet preview

This commit is contained in:
liukx0205 committed 2026-09-23 21:09:42 +08:00
1 parent 2a0531e9c3
commit caa4b8feca
18 files changed
+202 -30

No files matched your search

+93
View File
@@ -0,0 +1,93 @@
/** Recorded read metadata and the file preview share syntax highlighting while CSV defaults to Spreadsheet. */
import { mkdir, readFile, writeFile } from 'node:fs/promises'
import { join } from 'node:path'
import { fileURLToPath } from 'node:url'
import { chromium, type Browser } from 'playwright'
import { expect, it } from 'vitest'
import {
captureStableAria, compareOrRefreshGolden, fixtureUserPrompts, launchWebScaffold,
recordFixture, watchConsole, webSnapshotMode,
} from './scaffold.ts'
import { connectFreshWorkspace, expandTurnProcesses, newEnglishPage } from './support.ts'
const DIR = fileURLToPath(new URL('../../../snapshots/web/code-language', import.meta.url))
const FIXTURE = join(DIR, 'session.v4.jsonl')
const MODE = webSnapshotMode()
const FILES = [
{ name: 'sample.pyi', lang: 'py', previewLang: 'python', text: 'from typing import Protocol\n\nclass Greeter(Protocol):\n def greet(self, name: str) -> str: ...\n' },
{ name: 'deploy.ps1', lang: 'ps1', previewLang: 'powershell', text: 'param([string]$Name = "World")\nWrite-Host "Hello, $Name"\n' },
{ name: 'table.csv', lang: 'csv', previewLang: 'csv', text: 'name,count\napples,12\npears,7\n' },
] as const
it('replays highlighted Python stubs, PowerShell and CSV reads with their document previews', async () => {
const prompt = MODE === 'record'
? 'Use the read tool exactly once per file to read sample.pyi, deploy.ps1 and table.csv in the current directory. Use these relative paths. Do not run commands or change files. Then reply exactly: Read all three files.'
: fixtureUserPrompts(await readFile(FIXTURE, 'utf8'))[0]!
const scaffold = await launchWebScaffold({
...(MODE === 'record' ? {} : { replayFixture: FIXTURE }),
compareReplaySession: true,
})
let browser: Browser | undefined
try {
const cwd = join(scaffold.workspaceCwd, 'workspace')
await mkdir(cwd, { recursive: true })
await Promise.all(FILES.map(file => writeFile(join(cwd, file.name), file.text)))
browser = await chromium.launch()
const page = await newEnglishPage(browser)
const tripwire = watchConsole(page)
await page.goto(scaffold.authenticatedUrl, { waitUntil: 'load' })
await connectFreshWorkspace(page, scaffold.workspaceCwd)
const settled = scaffold.whenTurnSettled()
const input = page.locator('[data-composer-input]').first()
await input.fill(prompt)
await input.press('Enter')
const sessionId = await settled
const session = scaffold.ctx.agents.get(sessionId)?.session
if (session === undefined) throw new Error('read turn has no Session')
const reads = session.snapshotEvents().flatMap(event => event.type === 'tool/result' ? [event.data.meta] : [])
expect(reads).toHaveLength(FILES.length)
for (const file of FILES) {
expect(reads).toContainEqual(expect.objectContaining({ path: join(cwd, file.name), lang: file.lang }))
expect(await readFile(join(cwd, file.name), 'utf8')).toBe(file.text)
}
if (MODE === 'record') await recordFixture(scaffold, sessionId, FIXTURE)
await expandTurnProcesses(page)
await page.locator('[data-sidebar-right-expand]').click()
await page.locator('[data-sidebar-right-guide-entry="files"]').click()
const filesTab = page.locator('[data-dockkit-tab]').filter({ has: page.getByText('Files', { exact: true }) })
const preview = page.locator('[data-textpreview-url]')
const snapshots: string[] = []
for (const file of FILES) {
const readSelector = `[data-tool="read"]:has-text("${file.name}")`
const read = page.locator(readSelector)
await read.locator('[data-disclosure-row]').click()
await read.locator('[data-read]').scrollIntoViewIfNeeded()
await expect.poll(() => read.locator('[data-read] span[style*="color:"]').count()).toBeGreaterThan(0)
expect(await read.getByText(file.lang, { exact: true }).count()).toBe(1)
snapshots.push(`## Read ${file.name}\n\n${await captureStableAria(page, readSelector, scaffold.workspaceCwd)}`)
await filesTab.click()
await page.locator('[data-files-entry="file"]').getByRole('button', { name: file.name, exact: true }).click()
const viewer = preview.locator('[data-document-viewer-menu]')
if (file.name === 'table.csv') {
await expect.poll(() => viewer.innerText()).toBe('Spreadsheet')
await preview.locator('[data-excel-preview] canvas').first().waitFor()
await viewer.click()
await page.getByRole('menuitem', { name: 'Code', exact: true }).click()
}
await expect.poll(() => preview.locator('[data-code-preview] .shiki span[style*="color:"]').count()).toBeGreaterThan(0)
expect(await preview.getByText(file.previewLang, { exact: true }).count()).toBe(1)
snapshots.push(`## Preview ${file.name}\n\n${await captureStableAria(page, '[data-code-preview]', scaffold.workspaceCwd)}`)
await read.locator('[data-disclosure-row]').click()
}
if (MODE !== 'record') await compareOrRefreshGolden(join(DIR, 'ui.expected.md'), snapshots.join('\n\n'), MODE)
expect(tripwire.pageErrors).toEqual([])
expect(tripwire.warnings).toEqual([])
} finally {
try {
await browser?.close()
} finally {
await scaffold.close()
}
}
})
+1
View File
@@ -27,6 +27,7 @@
"tests/default-product-isolation.e2e.ts",
"tests/diff-context.e2e.ts",
"tests/code-card-layout.e2e.ts",
"tests/code-language.snapshot.ts",
"tests/scaffold.ts",
"tests/voice-input.e2e.ts",
"tests/voice-setup.e2e.ts",
@@ -2,5 +2,5 @@
# side as of the last confirmed-consistent state. Both languages carry equal authority;
# after editing either side, bring the other along and re-record with:
# pnpm run verify-translation-pairing --write packages/client/ui-sidebar-documentpreview/README.md
README.md: 03e25deb27591fb5b8864b48a5a0b44da854eb54
README.zh.md: d90d4932f210e9cff2275bdbadd5d35c1edea860
README.md: 9140a8402d6a3149e0383d6187d64286efdd5931
README.zh.md: e8e5c0b50cf83d5ee0e97b66aaff8c9b72db0677
@@ -70,7 +70,7 @@ Open `.xlsx`, `.xls`, `.csv`, and `.tsv` directly in the browser with worksheet
XLSX preview omits DrawingML parts from an in-memory copy before parsing and ignores worksheet drawing references. The original file and worksheet XML remain unchanged. A notice above the table lists detected charts, images, shapes, and conditional formatting that are not displayed, and recommends opening the workbook in a system application. Files without these detected features have no notice; formula warnings remain separate.
CSV and TSV default to the spreadsheet viewer and also offer Plain text. Commas and tabs delimit their fields respectively; quoted separators, escaped quotes, multiline fields, empty fields, and unequal row lengths are supported. The first row remains data. Values remain literal strings, including leading zeros, dates, booleans, and formula-looking text. Text files accept UTF-8 or BOM-marked UTF-16; invalid encoding receives conversion guidance. Malformed quoted fields fail the table preview rather than silently dropping data.
CSV and TSV default to the spreadsheet viewer and also offer Plain text; CSV additionally offers syntax-highlighted Code. Commas and tabs delimit their fields respectively; quoted separators, escaped quotes, multiline fields, empty fields, and unequal row lengths are supported. The first row remains data. Values remain literal strings, including leading zeros, dates, booleans, and formula-looking text. Text files accept UTF-8 or BOM-marked UTF-16; invalid encoding receives conversion guidance. Malformed quoted fields fail the table preview rather than silently dropping data.
Configure `excel` on the same `ui-sidebar-documentpreview` entry. These limits complement the Host's complete-file read limit; they do not cap browser process memory or decompression allocations.
@@ -70,7 +70,7 @@ PNG、JPEG、GIF、WebP、BMP、ICO 和 SVG 通过 Blob URL 在 `<img>` 静态
XLSX 预览在解析前从内存副本中移除 DrawingML 部件,并忽略工作表的绘图引用。原文件和工作表 XML 保持不变。表格上方的提示列出实际检测到但未展示的图表、图片、形状和条件格式,并建议使用系统应用打开工作簿。未检测到这些内容的文件不显示此提示;公式提示保持独立。
CSV 和 TSV 默认使用表格查看器,也可选择纯文本。两者分别以逗号和制表符分隔字段,支持引号内分隔符、转义引号、多行字段、空字段和不等长行。首行仍作为数据。值保持为字面字符串,包括前导零、日期、布尔值和类似公式的文本。文本文件支持 UTF-8 或带 BOM 的 UTF-16;无效编码会显示转换提示。引号字段格式错误会使表格预览失败,不会静默丢弃数据。
CSV 和 TSV 默认使用表格查看器,也可选择纯文本;CSV 还提供带语法高亮的 Code 预览。两者分别以逗号和制表符分隔字段,支持引号内分隔符、转义引号、多行字段、空字段和不等长行。首行仍作为数据。值保持为字面字符串,包括前导零、日期、布尔值和类似公式的文本。文本文件支持 UTF-8 或带 BOM 的 UTF-16;无效编码会显示转换提示。引号字段格式错误会使表格预览失败,不会静默丢弃数据。
在同一个 `ui-sidebar-documentpreview` 条目上配置 `excel`。这些限制补充 Host 的完整文件读取限制,但不限制浏览器进程内存或解压分配量。
@@ -124,7 +124,7 @@ export function apply(ctx: ClientContext): void {
registerHtml(ctx)
registerImage(ctx)
registerPdf(ctx)
registerCode(ctx)
registerOffice(ctx, config.office)
registerExcel(ctx, config.excel)
registerCode(ctx)
}
@@ -96,11 +96,11 @@ describe('ui-sidebar-documentpreview apply', () => {
['sidebar.right.tab.document', HTML_BODY_ID, 'documentHtml', HtmlBody],
['sidebar.right.tab.document', IMAGE_BODY_ID, 'sidebarImage', ImageBody],
['sidebar.right.tab.document', PDF_BODY_ID, 'sidebarPdf', LazyPdfBody],
['sidebar.right.tab.document', '@deepseek-ai/dsh-client-ui-sidebar-documentpreview/code', 'sidebarCodePreview', CodeBody],
['sidebar.right.tab.document.action', '@deepseek-ai/dsh-client-ui-sidebar-documentpreview/office', 'sidebarOffice', OfficeFontAction],
['sidebar.right.tab.document', '@deepseek-ai/dsh-client-ui-sidebar-documentpreview/office', 'sidebarOffice', OfficeBody],
['sidebar.right.tab.document.office.pdf', '@deepseek-ai/dsh-client-ui-sidebar-documentpreview/office', 'sidebarPdf', LazyPdfBody],
['sidebar.right.tab.document', '@deepseek-ai/dsh-client-ui-sidebar-documentpreview/excel', 'sidebarExcel', LazyExcelBody],
['sidebar.right.tab.document', '@deepseek-ai/dsh-client-ui-sidebar-documentpreview/code', 'sidebarCodePreview', CodeBody],
])
expect(registered[0]?.store).toBeDefined()
expect(typeof registered[0]?.inject).toBe('function')
@@ -114,15 +114,10 @@ describe('ui-sidebar-documentpreview apply', () => {
expect(dictionaries.size).toBe(0)
})
it('leaves every declared suffix with its owning preview and never lets the shared highlighter claim a later viewer\'s suffix', async () => {
it('keeps specialized previews first and offers Code for shared highlighting suffixes', async () => {
const { ctx } = await boot()
const previews = ctx.get('documentPreviews')
if (previews === undefined) throw new Error('documentPreviews was not provided')
// apply() registers in production order: text, markdown, html, image, pdf,
// code, office, excel. The shared Code body is the generic highlighter, so
// where it collides with an EARLIER dedicated body the earlier body keeps the
// suffix; any other collision means a later dedicated viewer lost a suffix it
// must render. Listing csv under Code makes Spreadsheet the loser.
const sharedHighlighter = '@deepseek-ai/dsh-client-ui-sidebar-documentpreview/code'
const owners = new Map<string, string>()
for (const definition of previews.getSnapshot()) {
@@ -138,9 +133,8 @@ describe('ui-sidebar-documentpreview apply', () => {
owners.set(extension, earlier ?? definition.id)
}
}
// Delimited spreadsheets stay with the Spreadsheet viewer, not the Code body.
const excel = '@deepseek-ai/dsh-client-ui-sidebar-documentpreview/excel'
expect(previews.candidates('table.csv')[0]?.id).toBe(excel)
expect(previews.candidates('table.csv').map(candidate => candidate.id)).toEqual([excel, sharedHighlighter])
expect(previews.candidates('table.tsv')[0]?.id).toBe(excel)
})
@@ -150,6 +150,7 @@ describe('langFromPath', () => {
// A suffix with no persisted value has none to preserve, so the projection
// applies the language's short name instead of the canonical grammar id.
expect(langFromPath('build.ps1')).toBe('ps1')
expect(langFromPath('table.csv')).toBe('csv')
expect(langFromPath('deploy.bat')).toBe('bat')
expect(langFromPath('.env')).toBe('env')
expect(langFromPath('server.log')).toBe('log')
+2 -2
View File
@@ -2,5 +2,5 @@
# side as of the last confirmed-consistent state. Both languages carry equal authority;
# after editing either side, bring the other along and re-record with:
# pnpm run verify-translation-pairing --write packages/util/code-language/README.md
README.md: 99930c192b946da09506593275e35dbd2601ddf4
README.zh.md: 5227ca85dadbd540c923ff94db375cdf80bffb52
README.md: e6b0c1404f8beaaade7bfafd44d2ba575d2c0db7
README.zh.md: 650c9c879ab8c419bd5363ee8fd752f770c264f1
+1 -1
View File
@@ -24,7 +24,7 @@ The repository's one file-extension to syntax-highlighting language table, share
The table lives in [`src/index.ts`](src/index.ts). Each key is a canonical language id — the grammar id the Client highlighter resolves — and each value is the lowercase extensions without the dot that select it. `languageForPath(path)` takes the text after the last dot of the final path segment, lowercases it, and looks it up in a `Map`; a `Map` keeps a filename such as `foo.constructor` from resolving an `Object.prototype` member. An unlisted dotfile (`.gitignore`), an absent extension, a trailing dot, and an unknown suffix all return `undefined`, which every consumer renders as plain text; a leading dot is still the separator, so `.env` resolves to `dotenv`. Both `/` and `\` separate path segments, so a Windows path resolves like a POSIX one.
The set is curated for common source, config, script, data, and markup extensions rather than mirroring a full language registry. Extensions with no matching grammar map to the nearest one (`properties` to `ini`, whose registration carries the `properties` alias); certificate and lock extensions (`pem`, `crt`, `key`, `cer`, `lock`) stay unlisted, and `csv` stays unlisted because the Spreadsheet preview declares the suffix and must keep it, so the earlier Code registration cannot claim it. `readLangHintForPath` is a projection over this table: a suffix whose value a recorded session already holds returns that persisted short id, any other suffix returns its language's short name (`powershell` to `ps1`), and an unrecognized suffix returns `undefined` — so the persisted field holds one style, a short name; for `kotlin`, `swift`, `yaml`, `json`, and similar that name is also the grammar id, and the suffixes whose own name is the better label (`tsx`, `tf`, `tfvars`, `gradle`) keep it. A consumer that needs the Client highlighter to actually tokenize a language still depends on that grammar being registered there — an id without a loaded grammar renders as plain text rather than failing.
The set is curated for common source, config, script, data, and markup extensions rather than mirroring a full language registry. Extensions with no matching grammar map to the nearest one (`properties` to `ini`, whose registration carries the `properties` alias); certificate and lock extensions (`pem`, `crt`, `key`, `cer`, `lock`) stay unlisted. CSV maps to `csv`; preview registries place specialized viewers before Code so Spreadsheet remains its default preview. `readLangHintForPath` is a projection over this table: a suffix whose value a recorded session already holds returns that persisted short id, any other suffix returns its language's short name (`powershell` to `ps1`), and an unrecognized suffix returns `undefined` — so the persisted field holds one style, a short name; for `kotlin`, `swift`, `yaml`, `json`, and similar that name is also the grammar id, and the suffixes whose own name is the better label (`tsx`, `tf`, `tfvars`, `gradle`) keep it. A consumer that needs the Client highlighter to actually tokenize a language still depends on that grammar being registered there — an id without a loaded grammar renders as plain text rather than failing.
-----
+1 -1
View File
@@ -24,7 +24,7 @@ kind: "package-library"
表位于 [`src/index.ts`](src/index.ts)。每个键是规范化语言 id——即 Client 高亮器解析的 grammar id;每个值是选中它的、不含点的小写扩展名。`languageForPath(path)` 取路径最后一段的最后一个点之后的文本、转小写后在 `Map` 中查找;使用 `Map` 可避免 `foo.constructor` 这类文件名解析到 `Object.prototype` 成员。未列入表的 dotfile(`.gitignore`)、无扩展名、结尾点、未知后缀都返回 `undefined`,各消费方一律按纯文本渲染;前导点仍算分隔符,因此 `.env` 解析为 `dotenv`。`/` 与 `\` 都算路径分隔符,因此 Windows 路径与 POSIX 路径解析一致。
该集合按常见源码、配置、脚本、数据与标记扩展名精选,并非完整语言登记表。没有对应 grammar 的扩展名映射到最接近的 grammar(`properties` 映射到 `ini`,该 grammar 自带 `properties` alias);证书与锁文件扩展名(`pem`、`crt`、`key`、`cer`、`lock`)保持不表,`csv` 同样保持不表:Spreadsheet 预览声明该后缀且必须保留,因此更早注册的 Code 不能抢占它。`readLangHintForPath` 在同一张表上做投影:已录制的会话已经持有该后缀的值时返回该持久化短 id,其余后缀返回该语言的短名(`powershell`→`ps1`),无法识别的后缀返回 `undefined`——持久化字段因此只有一种风格,即短名;对 `kotlin`、`swift`、`yaml`、`json` 等语言,短名与 grammar id 相同;而 `tsx`、`tf`、`tfvars`、`gradle` 这些后缀本身的名字更准确,保留其自身名字。消费方若希望 Client 高亮器真正分词,仍取决于该 grammar 已在其中注册——没有加载 grammar 的 id 会按纯文本渲染,而不是报错。
该集合按常见源码、配置、脚本、数据与标记扩展名精选,并非完整语言登记表。没有对应 grammar 的扩展名映射到最接近的 grammar(`properties` 映射到 `ini`,该 grammar 自带 `properties` alias);证书与锁文件扩展名(`pem`、`crt`、`key`、`cer`、`lock`)不列入表。CSV 映射为 `csv`;预览注册表将专用查看器排在 Code 之前,因此 Spreadsheet 仍是它的默认预览。`readLangHintForPath` 在同一张表上做投影:已录制的会话已经持有该后缀的值时返回该持久化短 id,其余后缀返回该语言的短名(`powershell`→`ps1`),无法识别的后缀返回 `undefined`——持久化字段因此只有一种风格,即短名;对 `kotlin`、`swift`、`yaml`、`json` 等语言,短名与 grammar id 相同;而 `tsx`、`tf`、`tfvars`、`gradle` 这些后缀本身的名字更准确,保留其自身名字。消费方若希望 Client 高亮器真正分词,仍取决于该 grammar 已在其中注册——没有加载 grammar 的 id 会按纯文本渲染,而不是报错。
-----
+5 -3
View File
@@ -22,9 +22,9 @@
* grammar does not exist map to the nearest available grammar
* (`properties` to `ini`, whose registration carries the `properties` alias) or
* stay unlisted. Certificate and lock extensions (`pem`, `crt`, `key`, `cer`,
* `lock`) stay unlisted, and `csv` is deliberately absent: the Spreadsheet
* preview declares it and must keep it, so listing it here would let the earlier
* Code registration take the suffix. `makefile` covers only the suffix
* `lock`) stay unlisted. Preview registries order specialized viewers before
* Code so CSV can default to Spreadsheet while retaining syntax highlighting.
* `makefile` covers only the suffix
* (`foo.makefile`); the extensionless `Makefile` name stays unlisted.
*/
const LANGUAGE_EXTENSIONS: Readonly<Record<string, readonly string[]>> = {
@@ -33,6 +33,7 @@ const LANGUAGE_EXTENSIONS: Readonly<Record<string, readonly string[]>> = {
shellscript: ['sh', 'bash', 'zsh'],
fish: ['fish'],
json: ['json', 'jsonc', 'jsonl', 'ndjson', 'ipynb'],
csv: ['csv'],
python: ['py', 'pyw', 'pyi'],
ruby: ['rb', 'rake', 'gemspec'],
go: ['go'],
@@ -133,6 +134,7 @@ const SHORT_BY_LANGUAGE: Readonly<Record<string, string>> = {
shellscript: 'sh',
fish: 'fish',
json: 'json',
csv: 'csv',
python: 'py',
ruby: 'rb',
go: 'go',
@@ -10,7 +10,7 @@ describe('languageForPath', () => {
['app.properties', 'ini'], ['app.conf', 'ini'], ['app.cfg', 'ini'],
['.env', 'dotenv'], ['server.log', 'log'],
['change.diff', 'diff'], ['fix.patch', 'diff'], ['api.http', 'http'],
['notebook.ipynb', 'json'],
['notebook.ipynb', 'json'], ['table.csv', 'csv'],
// Documentation and markup extensions.
['guide.rst', 'rst'], ['paper.tex', 'latex'], ['style.sty', 'latex'],
['doc.cls', 'latex'], ['refs.bib', 'bibtex'], ['Info.plist', 'xml'],
@@ -80,13 +80,8 @@ describe('languageForPath', () => {
}
})
it('leaves delimited-spreadsheet suffixes to the Spreadsheet preview', () => {
// The Code preview registers before the Spreadsheet preview, so listing csv
// here would make Code the earlier candidate and steal the suffix from the
// viewer that must render it.
for (const extension of ['csv', 'tsv']) {
expect(languageForPath(`table.${extension}`), extension).toBeUndefined()
}
it('leaves TSV unlisted because the highlighter has no TSV grammar', () => {
expect(languageForPath('table.tsv')).toBeUndefined()
})
})
@@ -112,6 +107,7 @@ describe('readLangHintForPath', () => {
it('uses the language short id for a suffix with no persisted value', () => {
expect(readLangHintForPath('build.ps1')).toBe('ps1')
expect(readLangHintForPath('table.csv')).toBe('csv')
expect(readLangHintForPath('.env')).toBe('env')
expect(readLangHintForPath('infra.tf')).toBe('tf')
expect(readLangHintForPath('paper.tex')).toBe('tex')
@@ -130,7 +126,7 @@ describe('readLangHintForPath', () => {
// imported so this test fails when a canonical grammar id is put back into the
// persisted value, which reading the implementation's own table would not catch.
const SHORT_BY_LANGUAGE: Readonly<Record<string, string>> = {
typescript: 'ts', javascript: 'js', shellscript: 'sh', fish: 'fish', json: 'json',
typescript: 'ts', javascript: 'js', shellscript: 'sh', fish: 'fish', json: 'json', csv: 'csv',
python: 'py', ruby: 'rb', go: 'go', rust: 'rs', java: 'java', c: 'c', cpp: 'cpp',
csharp: 'cs', kotlin: 'kotlin', swift: 'swift', php: 'php', yaml: 'yaml',
toml: 'toml', ini: 'ini', dotenv: 'env', log: 'log', diff: 'diff', http: 'http',
@@ -23,6 +23,7 @@ const repoRoot = resolve(import.meta.dirname, '..')
const corpusRoot = join(repoRoot, 'snapshots')
const profiles = ['acp', 'sdk', 'session', 'web'] as const
const snapshotAdapters = [
'apps/web/tests/code-language.snapshot.ts',
'apps/web/tests/message-feedback-protocol.snapshot.ts',
'apps/web/tests/minimal-preset.snapshot.ts',
'apps/web/tests/preset-migration.snapshot.ts',
@@ -0,0 +1,26 @@
{"type":"session","version":4,"id":"{{session:1}}","createdAt":1790168901572,"cwd":"{{cwd}}","isSeeded":false,"delegationDepth":0,"agentPreset":"standard"}
{"type":"permission/preset","data":{"preset":"workspace-write"}}
{"type":"sandbox/mode","data":{"mode":"workspace-write"}}
{"type":"approval/policy","data":{"policy":"ask"}}
{"type":"agent/inbox/spliced","data":{"target":"next-turn","start":0,"inserted":[{"content":[{"type":"text","text":"Use the read tool exactly once per file to read sample.pyi, deploy.ps1 and table.csv in the current directory. Use these relative paths. Do not run commands or change files. Then reply exactly: Read all three files."}],"source":{"kind":"user","rpcId":"{{rpc:1}}","clientTimeZone":"{{clientTimeZone}}"},"role":"user","id":"{{message:1}}"}]}}
{"type":"turn/start","data":{"turn":1}}
{"type":"agent/inbox/spliced","data":{"target":"next-turn","start":0,"removedCount":1,"inserted":[]}}
{"type":"step/start","data":{"turn":1,"step":1}}
{"type":"system/message","data":{"turn":1,"step":1,"message":{"role":"system","content":[{"type":"text","text":"{{system}}"}],"source":{"kind":"system-prompt"},"id":"{{message:2}}"}},"surfaceOp":"append"}
{"type":"user/message","data":{"content":[{"type":"text","text":"Use the read tool exactly once per file to read sample.pyi, deploy.ps1 and table.csv in the current directory. Use these relative paths. Do not run commands or change files. Then reply exactly: Read all three files."}],"source":{"kind":"user","rpcId":"{{rpc:1}}","clientTimeZone":"{{clientTimeZone}}"},"role":"user","id":"{{message:1}}"},"surfaceOp":"append"}
{"type":"user/message","data":{"content":[{"type":"text","text":"Current runtime context. This snapshot supersedes earlier runtime-context snapshots.\n\nCurrent DSH file policy: workspace-write. Any available operation enforced by the DSH file sandbox may modify files under the session workspace: \"{{cwd}}\". Some platform temporary areas may also be writable.\n\nApproval policy: ask. Operations that require approval may ask through the configured answerers; without an available answerer, the request fails closed."}],"source":{"kind":"runtime-context","form":"snapshot","sections":[{"name":"sandbox:policy","text":"Current DSH file policy: workspace-write. Any available operation enforced by the DSH file sandbox may modify files under the session workspace: \"{{cwd}}\". Some platform temporary areas may also be writable."},{"name":"approval:policy","text":"Approval policy: ask. Operations that require approval may ask through the configured answerers; without an available answerer, the request fails closed."}]},"role":"user","id":"{{message:3}}"},"surfaceOp":"append"}
{"type":"request/header","data":{"header":{"config":{"provider":"deepseek-official","model":"deepseek-v4-flash"},"tools":"{{tools}}"},"reason":"initial"}}
{"type":"request/context","data":{"provider":"deepseek-official","model":"deepseek-v4-flash","contextWindow":128000}}
{"type":"session/title","data":{"title":"Use the read tool exactly","messageSeqs":[8],"source":{"kind":"fallback"}}}
{"type":"assistant/message","data":{"turn":1,"step":1,"message":{"role":"assistant","content":[{"type":"reasoning","text":""},{"type":"text","text":"I'll read all three files using relative paths."},{"type":"tool-call","id":"call_00_ET_nKb413CLHY4ZbMBLeVJN2517","name":"read","arguments":"{\"file_path\": \"sample.pyi\"}"},{"type":"tool-call","id":"call_01_ET_HiRgELJvL5dI2PIxnu999728","name":"read","arguments":"{\"file_path\": \"deploy.ps1\"}"},{"type":"tool-call","id":"call_02_ET_k9GpNdJStUxsjDllNP754755","name":"read","arguments":"{\"file_path\": \"table.csv\"}"}],"source":{"kind":"model","provider":"deepseek-official","model":"deepseek-v4-flash","replayState":{"response":{"kind":"deepseek-messages","version":1,"model":"deepseek-flash"},"blocks":[{"type":"reasoning","signature":"6fbf31d2-a4c1-40ec-bbf2-c3efa855e735"},{"type":"text"},{"type":"tool-call"},{"type":"tool-call"},{"type":"tool-call"}]}},"id":"{{message:4}}"},"usage":{"inputTokens":7328,"outputTokens":110,"cacheReadTokens":1152,"cacheWriteTokens":0,"totalTokens":8590},"stream":[{"type":"chunk","time":1790168902529,"chunk":{"type":"block-start","index":0,"blockType":"reasoning"}},{"type":"chunk","time":1790168903114,"chunk":{"type":"block-end","index":0,"block":{"type":"reasoning","text":""}}},{"type":"chunk","time":1790168903114,"chunk":{"type":"block-start","index":1,"blockType":"text"}},{"type":"text-chunks","time0":1790168903114,"index":1,"dt":[15,1,0,9,1,0,0,13,14],"texts":["I","'ll"," read"," all"," three"," files"," using"," relative"," paths","."]},{"type":"chunk","time":1790168903180,"chunk":{"type":"block-end","index":1,"block":{"type":"text","text":"I'll read all three files using relative paths."}}},{"type":"chunk","time":1790168903180,"chunk":{"type":"block-start","index":2,"blockType":"tool-call"}},{"type":"tool-call-chunks","time0":1790168903180,"index":2,"dt":[],"id":"call_00_ET_nKb413CLHY4ZbMBLeVJN2517","name":"read","args":[""]},{"type":"tool-call-chunks","time0":1790168903194,"index":2,"dt":[5,0,1,27,3,1,0,0,0,0,3],"id":"call_00_ET_nKb413CLHY4ZbMBLeVJN2517","args":["{","\"","file","_path","\"",": ","\"","sample",".py","i","\"","}"]},{"type":"chunk","time":1790168903249,"chunk":{"type":"block-end","index":2,"block":{"type":"tool-call","id":"call_00_ET_nKb413CLHY4ZbMBLeVJN2517","name":"read","arguments":"{\"file_path\": \"sample.pyi\"}"}}},{"type":"chunk","time":1790168903249,"chunk":{"type":"block-start","index":3,"blockType":"tool-call"}},{"type":"tool-call-chunks","time0":1790168903249,"index":3,"dt":[],"id":"call_01_ET_HiRgELJvL5dI2PIxnu999728","name":"read","args":[""]},{"type":"tool-call-chunks","time0":1790168903263,"index":3,"dt":[0,0,0,13,1,0,0,11,1,0,1,0,13],"id":"call_01_ET_HiRgELJvL5dI2PIxnu999728","args":["{","\"","file","_path","\"",": ","\"","de","ploy",".","ps","1","\"","}"]},{"type":"chunk","time":1790168903330,"chunk":{"type":"block-end","index":3,"block":{"type":"tool-call","id":"call_01_ET_HiRgELJvL5dI2PIxnu999728","name":"read","arguments":"{\"file_path\": \"deploy.ps1\"}"}}},{"type":"chunk","time":1790168903331,"chunk":{"type":"block-start","index":4,"blockType":"tool-call"}},{"type":"tool-call-chunks","time0":1790168903331,"index":4,"dt":[],"id":"call_02_ET_k9GpNdJStUxsjDllNP754755","name":"read","args":[""]},{"type":"tool-call-chunks","time0":1790168903331,"index":4,"dt":[0,13,0,1,0,27,1,0,0,0],"id":"call_02_ET_k9GpNdJStUxsjDllNP754755","args":["{","\"","file","_path","\"",": ","\"","table",".csv","\"","}"]},{"type":"chunk","time":1790168903386,"chunk":{"type":"block-end","index":4,"block":{"type":"tool-call","id":"call_02_ET_k9GpNdJStUxsjDllNP754755","name":"read","arguments":"{\"file_path\": \"table.csv\"}"}}},{"type":"chunk","time":1790168903387,"chunk":{"type":"usage","usage":{"inputTokens":7328,"outputTokens":110,"cacheReadTokens":1152,"cacheWriteTokens":0,"totalTokens":8590}}},{"type":"chunk","time":1790168903387,"chunk":{"type":"finish","reason":{"kind":"tool-calls"},"replayState":{"response":{"kind":"deepseek-messages","version":1,"model":"deepseek-flash"},"blocks":[{"type":"reasoning","signature":"6fbf31d2-a4c1-40ec-bbf2-c3efa855e735"},{"type":"text"},{"type":"tool-call"},{"type":"tool-call"},{"type":"tool-call"}]}}}]},"surfaceOp":"append"}
{"type":"tool/call","data":{"turn":1,"step":1,"callId":"call_00_ET_nKb413CLHY4ZbMBLeVJN2517","name":"read","arguments":"{\"file_path\": \"sample.pyi\"}"}}
{"type":"tool/call","data":{"turn":1,"step":1,"callId":"call_01_ET_HiRgELJvL5dI2PIxnu999728","name":"read","arguments":"{\"file_path\": \"deploy.ps1\"}"}}
{"type":"tool/call","data":{"turn":1,"step":1,"callId":"call_02_ET_k9GpNdJStUxsjDllNP754755","name":"read","arguments":"{\"file_path\": \"table.csv\"}"}}
{"type":"tool/result","data":{"turn":1,"step":1,"message":{"role":"tool","source":{"kind":"tool","callId":"call_00_ET_nKb413CLHY4ZbMBLeVJN2517"},"toolCallId":"call_00_ET_nKb413CLHY4ZbMBLeVJN2517","content":[{"type":"text","text":"<path>{{cwd}}/sample.pyi</path>\n<type>file</type>\n<content>\n1: from typing import Protocol\n2: \n3: class Greeter(Protocol):\n4: def greet(self, name: str) -> str: ...\n\n(End of file - total 4 lines)\n</content>"}],"isError":false,"id":"{{message:5}}"},"meta":{"path":"{{cwd}}/sample.pyi","offset":1,"lines":[{"number":1,"text":"from typing import Protocol"},{"number":2,"text":""},{"number":3,"text":"class Greeter(Protocol):"},{"number":4,"text":" def greet(self, name: str) -> str: ..."}],"totalLines":4,"lang":"py"}},"sourceEventSeqs":[14],"surfaceOp":"append"}
{"type":"tool/result","data":{"turn":1,"step":1,"message":{"role":"tool","source":{"kind":"tool","callId":"call_01_ET_HiRgELJvL5dI2PIxnu999728"},"toolCallId":"call_01_ET_HiRgELJvL5dI2PIxnu999728","content":[{"type":"text","text":"<path>{{cwd}}/deploy.ps1</path>\n<type>file</type>\n<content>\n1: param([string]$Name = \"World\")\n2: Write-Host \"Hello, $Name\"\n\n(End of file - total 2 lines)\n</content>"}],"isError":false,"id":"{{message:6}}"},"meta":{"path":"{{cwd}}/deploy.ps1","offset":1,"lines":[{"number":1,"text":"param([string]$Name = \"World\")"},{"number":2,"text":"Write-Host \"Hello, $Name\""}],"totalLines":2,"lang":"ps1"}},"sourceEventSeqs":[15],"surfaceOp":"append"}
{"type":"tool/result","data":{"turn":1,"step":1,"message":{"role":"tool","source":{"kind":"tool","callId":"call_02_ET_k9GpNdJStUxsjDllNP754755"},"toolCallId":"call_02_ET_k9GpNdJStUxsjDllNP754755","content":[{"type":"text","text":"<path>{{cwd}}/table.csv</path>\n<type>file</type>\n<content>\n1: name,count\n2: apples,12\n3: pears,7\n\n(End of file - total 3 lines)\n</content>"}],"isError":false,"id":"{{message:7}}"},"meta":{"path":"{{cwd}}/table.csv","offset":1,"lines":[{"number":1,"text":"name,count"},{"number":2,"text":"apples,12"},{"number":3,"text":"pears,7"}],"totalLines":3,"lang":"csv"}},"sourceEventSeqs":[16],"surfaceOp":"append"}
{"type":"step/end","data":{"turn":1,"step":1}}
{"type":"step/start","data":{"turn":1,"step":2}}
{"type":"assistant/message","data":{"turn":1,"step":2,"message":{"role":"assistant","content":[{"type":"reasoning","text":""},{"type":"text","text":"Read all three files."}],"source":{"kind":"model","provider":"deepseek-official","model":"deepseek-v4-flash","replayState":{"response":{"kind":"deepseek-messages","version":1,"model":"deepseek-flash"},"blocks":[{"type":"reasoning","signature":"abe8baee-c8c9-484f-8e93-36fab36f10ea"},{"type":"text"}]}},"id":"{{message:8}}"},"usage":{"inputTokens":341,"outputTokens":6,"cacheReadTokens":8576,"cacheWriteTokens":0,"totalTokens":8923},"stream":[{"type":"chunk","time":1790168904202,"chunk":{"type":"block-start","index":0,"blockType":"reasoning"}},{"type":"chunk","time":1790168904774,"chunk":{"type":"block-end","index":0,"block":{"type":"reasoning","text":""}}},{"type":"chunk","time":1790168904774,"chunk":{"type":"block-start","index":1,"blockType":"text"}},{"type":"text-chunks","time0":1790168904774,"index":1,"dt":[13,1,0,0],"texts":["Read"," all"," three"," files","."]},{"type":"chunk","time":1790168904805,"chunk":{"type":"block-end","index":1,"block":{"type":"text","text":"Read all three files."}}},{"type":"chunk","time":1790168904806,"chunk":{"type":"usage","usage":{"inputTokens":341,"outputTokens":6,"cacheReadTokens":8576,"cacheWriteTokens":0,"totalTokens":8923}}},{"type":"chunk","time":1790168904806,"chunk":{"type":"finish","reason":{"kind":"stop"},"replayState":{"response":{"kind":"deepseek-messages","version":1,"model":"deepseek-flash"},"blocks":[{"type":"reasoning","signature":"abe8baee-c8c9-484f-8e93-36fab36f10ea"},{"type":"text"}]}}}]},"surfaceOp":"append"}
{"type":"step/end","data":{"turn":1,"step":2}}
{"type":"turn/end","data":{"turn":1,"reason":{"kind":"completed"}}}
+7
View File
@@ -0,0 +1,7 @@
version: 1
scenario: code-language
profile: web
composition: web-default
recording: live
header:
class: web-default
@@ -0,0 +1,50 @@
## Read sample.pyi
- button "Read sample.pyi" [expanded]:
- text: Read
- button "sample.pyi"
- text: py sample.pyi
- button "Wrap lines"
- button "Copy"
- text: "from typing import Protocol class Greeter(Protocol): def greet(self, name: str) -> str: ..."
- button "Inspect"
## Preview sample.pyi
- text: python
- button "Copy"
- code: "from typing import Protocol class Greeter(Protocol): def greet(self, name: str) -> str: ..."
## Read deploy.ps1
- button "Read deploy.ps1" [expanded]:
- text: Read
- button "deploy.ps1"
- text: ps1 deploy.ps1
- button "Wrap lines"
- button "Copy"
- text: param([string]$Name = "World") Write-Host "Hello, $Name"
- button "Inspect"
## Preview deploy.ps1
- text: powershell
- button "Copy"
- code: param([string]$Name = "World") Write-Host "Hello, $Name"
## Read table.csv
- button "Read table.csv" [expanded]:
- text: Read
- button "table.csv"
- text: csv table.csv
- button "Wrap lines"
- button "Copy"
- text: name,count apples,12 pears,7
- button "Inspect"
## Preview table.csv
- text: csv
- button "Copy"
- code: name,count apples,12 pears,7
+1
View File
@@ -15,6 +15,7 @@
"apps/web/tests/default-product-isolation.e2e.ts",
"apps/web/tests/diff-context.e2e.ts",
"apps/web/tests/code-card-layout.e2e.ts",
"apps/web/tests/code-language.snapshot.ts",
"apps/web/tests/scaffold.ts",
"apps/web/tests/voice-input.e2e.ts",
"apps/web/tests/voice-setup.e2e.ts",