Official

files

Built-in files UI (JavaScript UI plugin).

The app opens the listing; nothing installs until an agent in your Plugins workspace has read the files and you enable the plugin. In a terminal: dvg install divergence/files@0.2.6

Permissions in 0.2.6

  • Read files fs.readMediumReads files in the listed places.List the files of the workspacePlaces: the open workspace
  • Read chats chats.readMediumReads your transcripts and chat lists.Refresh the file list when an agent finishes a turn
  • Show panels ui.slotsAlways grantedShows views in the listed parts of the window.Show the files button and panelSlots: railright

Files

views.tsx5.1 KB
// Files rail and panel trees. Rendering only reads state; handlers run effects.
// HTM whitespace is significant; keep these templates out of Prettier's HTML formatter.
import type { EffectViewContext } from "divergence/effect";
import type { Files } from "./controller.ts";
import { isOpen, isPending, selectedPath, treeItems } from "./panel.ts";

// Layout for the templates below: a flex column, a row that centres its
// children across (the old `ui.row`), and a child that takes the free
// space and may shrink below its content.
const column = { display: "flex", flexDirection: "column" } as const;
const row = { display: "flex", flexDirection: "row", alignItems: "center" } as const;
const fill = { flexGrow: 1, flexShrink: 1, flexBasis: "0%", minWidth: 0, minHeight: 0 } as const;
const full = { width: "100%", height: "100%" } as const;

export function renderRail(ctx: EffectViewContext<object>, actions: Files["Service"]) {
  // Drawn a little larger than the button's usual icon (about 13.3px): the glyph is narrower than the
  // reload button's round one above it, and at 15.1px it is as wide.
  return <button id="rail-files" icon="files" iconSize={15.1} variant="ghost" active={ctx.app.shared?.rightPanel === "files"} tooltip="Files" onClick={() => ctx.run(actions.toggle(ctx.app))} />;
}

export function renderPanel(ctx: EffectViewContext<object>, actions: Files["Service"]) {
  const { state } = actions;
  if (!isOpen(ctx.app)) return null;
  const workspaceId = ctx.app.workspaceId;
  if (!workspaceId) {
    return <div {...column} gap="small" padding="medium"><text style="muted">Select a workspace to browse files.</text></div>;
  }
  // Matches show in their own tree with every folder open; the browsing
  // tree stays mounted behind it, so clearing the query gives it back with
  // the folders that were open.
  const searching = Boolean(state.query.trim());
  const open = state.open[workspaceId] ?? new Set<string>();
  const source = state.all ? { files: state.all.map((path) => ({ path })) } : { items: treeItems(state.listing, open, state.failed) };
  // An answer with nothing in it says so; one still on its way shows the last matches.
  const nothing = searching && !state.results.length && state.resultsFor === state.query.trim();
  // A kernel before `expanded` reports a click on a folder, which turns it.
  const onSelect = (e: { id: string; folder: boolean; expanded?: boolean }) => {
    if (e.folder) ctx.run(actions.setOpen(workspaceId, e.id, e.expanded ?? !open.has(e.id)));
    else if (!isPending(e.id)) ctx.run(actions.openFile(workspaceId, e.id));
  };
  // One 0.5rem inset and one gap: the title, the field's mark and the
  // tree's icons start on the same line, and the close button ends where
  // the field does. The header is a rail button's height at the panel's
  // top, so its buttons sit on the line of the rail's first icon.
  return (
    <div {...column} {...fill} {...full} padding="medium" paddingTop={0} gap="small">
      <div {...row} gap="small" height="2rem">
          <div {...row} {...fill} paddingX={9}><text style="body" size={13.125} weight={600} truncate>Files</text></div>
          <button id="files-refresh" icon="rotate-cw" variant="ghost" small tooltip="Refresh" onClick={() => ctx.run(actions.refresh(workspaceId))} />
          <button id="files-close" icon="x" variant="ghost" small tooltip="Close" onClick={() => ctx.run(actions.close)} />
        </div>
      <input id="files-search" value={state.query} placeholder="Search files..." icon="search" onChange={(e: { value: string }) => {
                  state.query = e.value;
                  ctx.update();
                  ctx.run(actions.search(workspaceId, e.value));
                }} />
      {nothing ? <div {...column} padding="small" paddingX={9}><text style="muted">No matches</text></div> : null}
      {searching && !nothing
                ? (
                  <div {...column} {...fill}>
                    <tree id={`files-search-${workspaceId}`} rowDrag={fileDrag(workspaceId)} openFolders files={state.results.map((path) => ({ path }))} selected={selectedPath(state.activePath)} onSelect={(e: { id: string; folder: boolean }) => {
                                      if (e.folder) return;
                                      // The search has found what it was for: the tree comes
                                      // back, with the opened file selected in it.
                                      state.query = "";
                                      state.results = [];
                                      ctx.update();
                                      ctx.run(actions.openFile(workspaceId, e.id));
                                    }} />
                  </div>
                )
                : null}
      <div {...column} {...fill} display={searching ? "none" : "flex"}>
          <tree id={`files-${workspaceId}`} rowDrag={fileDrag(workspaceId)} {...source} selected={selectedPath(state.activePath)} onSelect={onSelect} />
        </div>
    </div>
  );
}

/** A file row drags as the tabs plugin's file tab, which a pane opens where it lands. */
const fileDrag = (workspaceId: string) => ({ type: "divergence/item", itemKind: "tabs.file", keyPrefix: `file:${workspaceId}:` });

Versions

VersionPublishedPlugin APISizePermissionsStatus
0.2.6latestNov 21, 2026>=5 <613.7 KB3 permissionsListed
0.2.5Nov 11, 2026>=5 <613.3 KB3 permissionsListed
0.2.4Nov 9, 2026>=5 <612.3 KB3 permissionsListed
0.2.3Oct 27, 2026>=2 <48 KB3 permissionsListed

Reviews and comments

0 threads · 0 reviews

No comments yet.