zidane-ui/ files
import { … } from 'zidane-ui/files'ui/src/files/index.ts
Components#
DiffsTabComponent#
The Diffs tab: the session's edits and the working tree against HEAD, a file tree beside virtualised diffs with
review comments, find in diffs and search in changes, over the FilesProvider's host. Loads on first render.
function DiffsTab(props: DiffsTabProps): ElementParameters
| Name | Type | Description |
|---|---|---|
| props | DiffsTabProps | The scope, the app's hooks, chat target and requests. |
Returns
ElementProps
| Name | Type | Description |
|---|---|---|
| chat? | FilesChatTarget | null | The chat review comments go to ( |
| className? | string | Classes on the root. |
| createParseWorker? | () => Worker | Makes the worker that parses working-tree patches (it answers |
| onWorkingTreeTaken? | () => void | The tab took |
| scope | FilesScope | The folder the tab works from; bound to a session, it shows that session's edits too. |
| style? | CSSProperties | Styles on the root. |
| useEdits? | SessionEditsHook | The bound session's edit events (a hook). Without it, the Session source is empty. |
| useKeyScope? | FilesKeyScopeHook | Registers the tab's next / previous / close / find keys (a hook). |
| workingTreeRequest? | number | A count the app bumps to open the working tree (the git bar's changes); 0: none asked. |
EditorEnvironmentRootComponent#
Provides the editor surfaces' environment from the app's appearance and Editor settings.
function EditorEnvironmentRoot(props: EditorEnvironmentRootProps): ElementParameters
| Name | Type | Description |
|---|---|---|
| props | EditorEnvironmentRootProps | The |
Returns
ElementProps
| Name | Type | Description |
|---|---|---|
| children | ReactNode | The editor surfaces. |
FilesProviderComponent#
Provides a FilesHost and optional label overrides to the Files and Diffs tabs below it.
function FilesProvider(props: FilesProviderProps): ElementParameters
| Name | Type | Description |
|---|---|---|
| props | FilesProviderProps | Provider props: the |
Returns
ElementProps
| Name | Type | Description |
|---|---|---|
| children | ReactNode | The components that read from |
| host | FilesHost | The host the Files and Diffs tabs below read files, git state and editor preferences from. |
| labels? | Partial<{ filesAddToChat: string; filesAddToPrompt: string; filesAddWhatToChat: (what: string) => string; filesAfter: string; filesAllFiles: string; filesBefore: string; filesBinary: string; filesBlankLines: string; filesCancel: string; filesChangedOnly: string; filesCheckedBy: (ran: readonly string[], failed: readonly string[]) => string; filesCheckFailed: (tools: readonly string[]) => string; filesChecking: string; filesClearSearch: string; filesCloseSearch: string; filesCloseSearchHint: string; filesCommentOn: (what: string) => string; filesCommentPlaceholder: string; filesCopy: string; filesCopyPath: string; filesCopyRelativePath: string; filesCopyWhat: (what: string) => string; filesCut: string; filesDelete: string; filesDeleteConfirm: string; filesDeletePermanent: string; filesDeleteTitle: (name: string, count: number) => string; filesDeleteToTrash: string; filesDiffSource: string; filesDiffsToolbar: string; filesDismiss: string; filesDropHere: string; filesDuplicate: string; filesEmptyFolder: string; filesEntryDenied: string; filesEntryExists: string; filesEntryInvalid: string; filesEntryMissing: string; filesEntryTooLarge: string; filesFileNames: string; filesFindInDiff: string; filesFindInDiffs: string; filesGoToDefinition: string; filesHideFileList: string; filesHideIgnored: string; filesHideTree: string; filesImageSize: (name: string, width: number, height: number) => string; filesLanguageServer: string; filesLineHits: (count: number, more: boolean, files: number) => string; filesMatchCase: string; filesMatchingLines: string; filesMatchLine: (path: string, line: number, text: string) => string; filesMediaFailed: (name: string) => string; filesMoreLines: (count: number) => string; filesMoveToTrash: string; filesNameHits: (count: number, more: boolean) => string; filesNewFile: string; filesNewFolder: string; filesNoChanged: string; filesNoChangesHint: string; filesNoChangesYet: string; filesNoChat: string; filesNoFolder: string; filesNoResults: string; filesNotFound: string; filesNoTool: string; filesNoWorkingTree: string; filesOpenEditor: string; filesOpenFiles: string; filesOpenFolderInEditor: string; filesOpenInEditor: string; filesPaste: string; filesPickFile: string; filesPlainView: string; filesRefresh: string; filesRename: string; filesRevealFinder: string; filesRevealInFinder: string; filesSearchFiles: string; filesSearchInChanges: string; filesSearchInFiles: string; filesSearching: string; filesSearchNamesOnly: string; filesSelectedLines: string; filesSelection: string; filesSessionNoFolder: string; filesShowChanges: string; filesShowChangesLarge: string; filesShowFileList: string; filesShowIgnored: string; filesShowTree: string; filesSourceSession: string; filesSourceWorking: string; filesSplit: string; filesToAdd: string; filesTooLarge: (kb: number) => string; filesTruncated: (shown: number, total: number, atLeast: boolean) => string; filesWorkingTreeClean: string; filesWrap: string }> | Overrides for the built-in strings. Keys you leave out keep the default English label. |
FilesTabComponent#
The Files tab: the workspace tree beside the open files (viewer, editor, working-tree diff), search in files,
find, diagnostics and language-server findings, over the FilesProvider's host. Loads on first render.
function FilesTab(props: FilesTabProps): ElementParameters
| Name | Type | Description |
|---|---|---|
| props | FilesTabProps | The scope, the app's layout store, chat target, hooks and hand-overs. |
Returns
ElementProps
| Name | Type | Description |
|---|---|---|
| chat? | FilesChatTarget | null | The chat "Add to chat" and review comments go to ( |
| className? | string | Classes on the root. |
| fileActions? | boolean | The tree's file actions (new file and folder, rename, move, copy, delete, drops), when the host has them. Default: true. |
| layout? | FilesLayoutStore | Where the scope's layout lives (open tabs, the active file, the tree toggles and width). Default: in memory, per mount. |
| onOpenExternal? | (absolutePath: string) => Promise<boolean> | ⌘/Ctrl-click on a tree row: open the absolute path outside the panel. Resolves false to open it here instead. |
| onRevealTaken? | () => void | The tab took |
| readOnly? | boolean | Nothing changes: no saves, no file actions. Default: false. |
| renderTabGlyph? | (path: string) => ReactNode | A file tab's glyph (a stable function). Default: the file's icon. |
| revealRequest? | string | null | An absolute path handed over from elsewhere (a folder ends with |
| scope | FilesScope | The folder the tab works from, optionally bound to a session (its edits mark changed files). |
| style? | CSSProperties | Styles on the root. |
| takeRevealPosition? | (absolutePath: string) => FilesRevealPosition | null | The position to reveal in a handed-over file, taken once. |
| useEdits? | SessionEditsHook | The bound session's edit events (a hook). Without it, changed files come from git status alone. |
| useKeyScope? | FilesKeyScopeHook | Registers the tab's next / previous / close / find keys (a hook). |
Functions#
attachmentNameFunction#
snippet-index.ts-L2toL8.md: what the composer chip shows.
function attachmentName(prefix: string, filePath: string, label: string | null): stringParameters
| Name | Type | Description |
|---|---|---|
| prefix | string |
|
| filePath | string | The file the excerpt is from. |
| label | string | null | Its line range ( |
Returns
stringcodeAttachmentLabelFunction#
The icon and name a non-image attachment shows: a code attachment (comment-<file>-L1toL9.md,
snippet-<file>.md, a terminal's lines) shows its source's icon and name with the range, a PDF the PDF
icon, anything else fallbackIcon. An app's attachmentLabel renderer slot.
function codeAttachmentLabel(name: string, fallbackIcon?: string): AttachmentLabelPartsParameters
| Name | Type | Default | Description |
|---|---|---|---|
| name | string | The attachment's file name. | |
| fallbackIcon? | string | 'i-ph-file' | The icon of any other file. |
Returns
fenceForFunction#
Fence long enough to wrap content that itself contains backticks.
function fenceFor(text: string): stringParameters
| Name | Type | Description |
|---|---|---|
| text | string | The content to fence. |
Returns
stringparseCodeAttachmentNameFunction#
Inverse of attachmentName; null for any other attachment.
function parseCodeAttachmentName(name: string): CodeAttachmentInfo | nullParameters
| Name | Type | Description |
|---|---|---|
| name | string | An attachment's name. |
Returns
CodeAttachmentInfo | nullserializeTerminalExcerptFunction#
A terminal selection as a composer attachment, named and fenced like code excerpts so its chip reads
Terminal 1, then lines 12–18.
function serializeTerminalExcerpt(e: TerminalExcerpt): { body: string; name: string }Parameters
| Name | Type | Description |
|---|---|---|
| e | TerminalExcerpt | The selection. |
Returns
{ body: string; name: string }terminalRangeDetailFunction#
L12 to L18 → lines 12–18, L3 → line 3: the chip's wording.
function terminalRangeDetail(rangeLabel: string | null): string | undefinedParameters
| Name | Type | Description |
|---|---|---|
| rangeLabel | string | null | A |
Returns
string | undefinedterminalRangeLabelFunction#
A terminal selection's range label: L12 to L18, L3 for one line (either order).
function terminalRangeLabel(startLine: number, endLine: number): stringParameters
| Name | Type | Description |
|---|---|---|
| startLine | number | One end of the selection (1-based). |
| endLine | number | The other end. |
Returns
stringuseEditorPrefsFunction#
The editor preferences of the nearest FilesProvider's host (the defaults without a provider or without
editorPrefs). Re-renders when they change.
function useEditorPrefs(): EditorStateReturns
useFilesHostFunction#
Returns the FilesHost from the nearest FilesProvider. Throws when called outside one.
useFilesLabelsFunction#
Returns the Files and Diffs tabs' strings: the defaults merged with any overrides given to FilesProvider or LabelsProvider.
function useFilesLabels(): { filesAddToChat: string; filesAddToPrompt: string; filesAddWhatToChat: (what: string) => string; filesAfter: string; filesAllFiles: string; filesBefore: string; filesBinary: string; filesBlankLines: string; filesCancel: string; filesChangedOnly: string; filesCheckedBy: (ran: readonly string[], failed: readonly string[]) => string; filesCheckFailed: (tools: readonly string[]) => string; filesChecking: string; filesClearSearch: string; filesCloseSearch: string; filesCloseSearchHint: string; filesCommentOn: (what: string) => string; filesCommentPlaceholder: string; filesCopy: string; filesCopyPath: string; filesCopyRelativePath: string; filesCopyWhat: (what: string) => string; filesCut: string; filesDelete: string; filesDeleteConfirm: string; filesDeletePermanent: string; filesDeleteTitle: (name: string, count: number) => string; filesDeleteToTrash: string; filesDiffSource: string; filesDiffsToolbar: string; filesDismiss: string; filesDropHere: string; filesDuplicate: string; filesEmptyFolder: string; filesEntryDenied: string; filesEntryExists: string; filesEntryInvalid: string; filesEntryMissing: string; filesEntryTooLarge: string; filesFileNames: string; filesFindInDiff: string; filesFindInDiffs: string; filesGoToDefinition: string; filesHideFileList: string; filesHideIgnored: string; filesHideTree: string; filesImageSize: (name: string, width: number, height: number) => string; filesLanguageServer: string; filesLineHits: (count: number, more: boolean, files: number) => string; filesMatchCase: string; filesMatchingLines: string; filesMatchLine: (path: string, line: number, text: string) => string; filesMediaFailed: (name: string) => string; filesMoreLines: (count: number) => string; filesMoveToTrash: string; filesNameHits: (count: number, more: boolean) => string; filesNewFile: string; filesNewFolder: string; filesNoChanged: string; filesNoChangesHint: string; filesNoChangesYet: string; filesNoChat: string; filesNoFolder: string; filesNoResults: string; filesNotFound: string; filesNoTool: string; filesNoWorkingTree: string; filesOpenEditor: string; filesOpenFiles: string; filesOpenFolderInEditor: string; filesOpenInEditor: string; filesPaste: string; filesPickFile: string; filesPlainView: string; filesRefresh: string; filesRename: string; filesRevealFinder: string; filesRevealInFinder: string; filesSearchFiles: string; filesSearchInChanges: string; filesSearchInFiles: string; filesSearching: string; filesSearchNamesOnly: string; filesSelectedLines: string; filesSelection: string; filesSessionNoFolder: string; filesShowChanges: string; filesShowChangesLarge: string; filesShowFileList: string; filesShowIgnored: string; filesShowTree: string; filesSourceSession: string; filesSourceWorking: string; filesSplit: string; filesToAdd: string; filesTooLarge: (kb: number) => string; filesTruncated: (shown: number, total: number, atLeast: boolean) => string; filesWorkingTreeClean: string; filesWrap: string }Returns
{ filesAddToChat: string; filesAddToPrompt: string; filesAddWhatToChat: (what: string) => string; filesAfter: string; filesAllFiles: string; filesBefore: string; filesBinary: string; filesBlankLines: string; filesCancel: string; filesChangedOnly: string; filesCheckedBy: (ran: readonly string[], failed: readonly string[]) => string; filesCheckFailed: (tools: readonly string[]) => string; filesChecking: string; filesClearSearch: string; filesCloseSearch: string; filesCloseSearchHint: string; filesCommentOn: (what: string) => string; filesCommentPlaceholder: string; filesCopy: string; filesCopyPath: string; filesCopyRelativePath: string; filesCopyWhat: (what: string) => string; filesCut: string; filesDelete: string; filesDeleteConfirm: string; filesDeletePermanent: string; filesDeleteTitle: (name: string, count: number) => string; filesDeleteToTrash: string; filesDiffSource: string; filesDiffsToolbar: string; filesDismiss: string; filesDropHere: string; filesDuplicate: string; filesEmptyFolder: string; filesEntryDenied: string; filesEntryExists: string; filesEntryInvalid: string; filesEntryMissing: string; filesEntryTooLarge: string; filesFileNames: string; filesFindInDiff: string; filesFindInDiffs: string; filesGoToDefinition: string; filesHideFileList: string; filesHideIgnored: string; filesHideTree: string; filesImageSize: (name: string, width: number, height: number) => string; filesLanguageServer: string; filesLineHits: (count: number, more: boolean, files: number) => string; filesMatchCase: string; filesMatchingLines: string; filesMatchLine: (path: string, line: number, text: string) => string; filesMediaFailed: (name: string) => string; filesMoreLines: (count: number) => string; filesMoveToTrash: string; filesNameHits: (count: number, more: boolean) => string; filesNewFile: string; filesNewFolder: string; filesNoChanged: string; filesNoChangesHint: string; filesNoChangesYet: string; filesNoChat: string; filesNoFolder: string; filesNoResults: string; filesNotFound: string; filesNoTool: string; filesNoWorkingTree: string; filesOpenEditor: string; filesOpenFiles: string; filesOpenFolderInEditor: string; filesOpenInEditor: string; filesPaste: string; filesPickFile: string; filesPlainView: string; filesRefresh: string; filesRename: string; filesRevealFinder: string; filesRevealInFinder: string; filesSearchFiles: string; filesSearchInChanges: string; filesSearchInFiles: string; filesSearching: string; filesSearchNamesOnly: string; filesSelectedLines: string; filesSelection: string; filesSessionNoFolder: string; filesShowChanges: string; filesShowChangesLarge: string; filesShowFileList: string; filesShowIgnored: string; filesShowTree: string; filesSourceSession: string; filesSourceWorking: string; filesSplit: string; filesToAdd: string; filesTooLarge: (kb: number) => string; filesTruncated: (shown: number, total: number, atLeast: boolean) => string; filesWorkingTreeClean: string; filesWrap: string }Interfaces#
CodeAttachmentInfoInterface#
What a code attachment's name says: its kind, file and line range.
interface CodeAttachmentInfoProperties
| Name | Type | Description |
|---|---|---|
| file | string | Basename of the file the excerpt came from. |
| kind | 'terminal' | 'comment' | 'snippet' | 'diagnostic' |
|
| rangeLabel | string | null |
|
DiffsTabPropsInterface#
Props for DiffsTab.
interface DiffsTabPropsProperties
| Name | Type | Description |
|---|---|---|
| chat? | FilesChatTarget | null | The chat review comments go to ( |
| className? | string | Classes on the root. |
| createParseWorker? | () => Worker | Makes the worker that parses working-tree patches (it answers |
| onWorkingTreeTaken? | () => void | The tab took |
| scope | FilesScope | The folder the tab works from; bound to a session, it shows that session's edits too. |
| style? | CSSProperties | Styles on the root. |
| useEdits? | SessionEditsHook | The bound session's edit events (a hook). Without it, the Session source is empty. |
| useKeyScope? | FilesKeyScopeHook | Registers the tab's next / previous / close / find keys (a hook). |
| workingTreeRequest? | number | A count the app bumps to open the working tree (the git bar's changes); 0: none asked. |
EditorEnvironmentRootPropsInterface#
Props for EditorEnvironmentRoot.
interface EditorEnvironmentRootPropsProperties
| Name | Type | Description |
|---|---|---|
| children | ReactNode | The editor surfaces. |
FilesProviderPropsInterface#
Props for FilesProvider.
interface FilesProviderPropsProperties
| Name | Type | Description |
|---|---|---|
| children | ReactNode | The components that read from |
| host | FilesHost | The host the Files and Diffs tabs below read files, git state and editor preferences from. |
| labels? | Partial<{ filesAddToChat: string; filesAddToPrompt: string; filesAddWhatToChat: (what: string) => string; filesAfter: string; filesAllFiles: string; filesBefore: string; filesBinary: string; filesBlankLines: string; filesCancel: string; filesChangedOnly: string; filesCheckedBy: (ran: readonly string[], failed: readonly string[]) => string; filesCheckFailed: (tools: readonly string[]) => string; filesChecking: string; filesClearSearch: string; filesCloseSearch: string; filesCloseSearchHint: string; filesCommentOn: (what: string) => string; filesCommentPlaceholder: string; filesCopy: string; filesCopyPath: string; filesCopyRelativePath: string; filesCopyWhat: (what: string) => string; filesCut: string; filesDelete: string; filesDeleteConfirm: string; filesDeletePermanent: string; filesDeleteTitle: (name: string, count: number) => string; filesDeleteToTrash: string; filesDiffSource: string; filesDiffsToolbar: string; filesDismiss: string; filesDropHere: string; filesDuplicate: string; filesEmptyFolder: string; filesEntryDenied: string; filesEntryExists: string; filesEntryInvalid: string; filesEntryMissing: string; filesEntryTooLarge: string; filesFileNames: string; filesFindInDiff: string; filesFindInDiffs: string; filesGoToDefinition: string; filesHideFileList: string; filesHideIgnored: string; filesHideTree: string; filesImageSize: (name: string, width: number, height: number) => string; filesLanguageServer: string; filesLineHits: (count: number, more: boolean, files: number) => string; filesMatchCase: string; filesMatchingLines: string; filesMatchLine: (path: string, line: number, text: string) => string; filesMediaFailed: (name: string) => string; filesMoreLines: (count: number) => string; filesMoveToTrash: string; filesNameHits: (count: number, more: boolean) => string; filesNewFile: string; filesNewFolder: string; filesNoChanged: string; filesNoChangesHint: string; filesNoChangesYet: string; filesNoChat: string; filesNoFolder: string; filesNoResults: string; filesNotFound: string; filesNoTool: string; filesNoWorkingTree: string; filesOpenEditor: string; filesOpenFiles: string; filesOpenFolderInEditor: string; filesOpenInEditor: string; filesPaste: string; filesPickFile: string; filesPlainView: string; filesRefresh: string; filesRename: string; filesRevealFinder: string; filesRevealInFinder: string; filesSearchFiles: string; filesSearchInChanges: string; filesSearchInFiles: string; filesSearching: string; filesSearchNamesOnly: string; filesSelectedLines: string; filesSelection: string; filesSessionNoFolder: string; filesShowChanges: string; filesShowChangesLarge: string; filesShowFileList: string; filesShowIgnored: string; filesShowTree: string; filesSourceSession: string; filesSourceWorking: string; filesSplit: string; filesToAdd: string; filesTooLarge: (kb: number) => string; filesTruncated: (shown: number, total: number, atLeast: boolean) => string; filesWorkingTreeClean: string; filesWrap: string }> | Overrides for the built-in strings. Keys you leave out keep the default English label. |
FilesRevealPositionInterface#
A position to reveal once a handed-over file opens (a terminal link's src/app.ts:12:5), 1-based.
interface FilesRevealPositionProperties
| Name | Type | Description |
|---|---|---|
| column | number | 1-based column. |
| line | number | 1-based line. |
FilesTabPropsInterface#
Props for FilesTab.
interface FilesTabPropsProperties
| Name | Type | Description |
|---|---|---|
| chat? | FilesChatTarget | null | The chat "Add to chat" and review comments go to ( |
| className? | string | Classes on the root. |
| fileActions? | boolean | The tree's file actions (new file and folder, rename, move, copy, delete, drops), when the host has them. Default: true. |
| layout? | FilesLayoutStore | Where the scope's layout lives (open tabs, the active file, the tree toggles and width). Default: in memory, per mount. |
| onOpenExternal? | (absolutePath: string) => Promise<boolean> | ⌘/Ctrl-click on a tree row: open the absolute path outside the panel. Resolves false to open it here instead. |
| onRevealTaken? | () => void | The tab took |
| readOnly? | boolean | Nothing changes: no saves, no file actions. Default: false. |
| renderTabGlyph? | (path: string) => ReactNode | A file tab's glyph (a stable function). Default: the file's icon. |
| revealRequest? | string | null | An absolute path handed over from elsewhere (a folder ends with |
| scope | FilesScope | The folder the tab works from, optionally bound to a session (its edits mark changed files). |
| style? | CSSProperties | Styles on the root. |
| takeRevealPosition? | (absolutePath: string) => FilesRevealPosition | null | The position to reveal in a handed-over file, taken once. |
| useEdits? | SessionEditsHook | The bound session's edit events (a hook). Without it, changed files come from git status alone. |
| useKeyScope? | FilesKeyScopeHook | Registers the tab's next / previous / close / find keys (a hook). |
TerminalExcerptInterface#
Lines selected in a terminal, to attach to the composer.
interface TerminalExcerptProperties
| Name | Type | Description |
|---|---|---|
| endLine | number | Its last buffer line (1-based, inclusive). |
| label | string | The terminal's label ("Terminal 1", or the agent's command). |
| startLine | number | The selection's first buffer line (1-based, inclusive). |
| text | string | The selected text. |
Types#
FilesKeyScopeHookType#
Registers a tab's key scope on its root element (next / previous / close / find), routed by the app's focus handling. A hook: the same function on every render.
type FilesKeyScopeHook = (root: RefObject<HTMLElement | null>, scope: FilesKeyScope) => voidSessionEditsHookType#
A session's edit events (tool events carrying an edit), as a stable array that changes only when an edit
lands (null: no session, no edits). A hook: the same function on every render.
type SessionEditsHook = (sessionId: string | null) => readonly SessionEditEvent[]