Context and filesystem
Components for two things long-running agents need: a view of how full the context window is, and files that live in the browser.
Context window
The context budget chip and usage panel, as a long run fills the window and compacts. Background in Context usage.
Loading the live demo…
ContextChip props
| Prop | Type | Notes |
|---|---|---|
ratio | number | Required. 0 to 1, how full the window is. |
showLabel | boolean | Show the percentage next to the ring. |
isCompacting | boolean | Animate while a compaction is running. |
size | number | Diameter in px. |
onClick | () => void | Typically opens the usage panel. |
title, className | string |
ContextUsagePanel props
| Prop | Type | Notes |
|---|---|---|
budget | ContextBudget | Token counts by category, from the chat store. |
compactions | CompactionLogItem[] | History of compactions in this thread. |
isCompacting | boolean | |
onCompact | () => void | Called when the user asks to compact now. |
className | string |
File workspace
A Monaco-backed file tree the agent reads and writes, stored in IndexedDB.
From @distri/fs. See Using IndexedDB.
Loading the live demo…
FileWorkspace props
| Prop | Type | Notes |
|---|---|---|
projectId | string | Required. Namespaces the files in IndexedDB. |
initialEntries | InitialEntry[] | Files and folders to seed an empty project with. |
defaultFilePath | string | The file to open first. |
onSaveFile | FileSaveHandler | Called when the user saves a file. |
filesystem | ProjectFilesystem | Your own storage backend instead of IndexedDB. |
previewRenderer | PreviewRenderer | Custom preview for a file type. |
panels, activityBarItems | Extra side panels and activity-bar entries. | |
fileActionItems, fileActionRenderers | Per-file actions in the tree. | |
className | string |
Script testing panel
A payload editor and a run button for a script tool. See Browser scripting.
Loading the live demo…
ScriptTestingPanel props
| Prop | Type | Notes |
|---|---|---|
onRun | (payload: string) => string | void | Promise<string | void> | Run the script; the returned string is shown as the result. |
onGenerate | (currentPayload: string) => string | void | Promise<string | void> | Fill the editor with a generated payload. |
defaultPayload | string | Initial editor contents. |
title, description | string | |
resultPlaceholder | string | Shown before the first run. |
language | string | Editor language for the payload. |