Skip to content

feat(slides): let the user edit, reorder and delete slides, and make the agent wait while the user edits an artifact - #259

Merged
GoDiao merged 1 commit into
mainfrom
feat/slides-editing
Nov 17, 2026
Merged

GoDiao merged 1 commit into
mainfrom
feat/slides-editing

Conversation

@GoDiao

@GoDiao GoDiao commented Nov 17, 2026

Copy link
Copy Markdown
Owner

What

Phase 3 of docs/features/slides/tech-design.md: the user can change a deck in the app. It also adds a lock that applies to every artifact kind, so the user and the agent do not write the same artifact at the same time.

Editing a deck

  • With Edit on in the slide toolbar, a click on a text block of the current slide edits it in place. Enter or leaving the block saves, Esc cancels, Shift+Enter starts a new line (saved as <br>). Blocks that preserve white space, such as code blocks, keep their text as typed.
  • In the overview, with Edit on, slides are reordered by dragging or with Cmd/Ctrl and the arrow keys. The dragged slide follows the pointer and the others glide to their new places; Esc cancels a drag; dragging near the top or bottom edge scrolls.
  • A slide is deleted with the toolbar button or the Delete key in the overview, after a confirmation.
  • The overview shows page numbers, text in it cannot be selected, and the current slide zooms between the overview and the single-slide view.
  • Three write-back endpoints: PUT /api/artifacts/slides/content (writes only if the file still equals what the edit was based on, otherwise 409), PATCH /api/artifacts/slides/order and DELETE /api/artifacts/slides.

The user-edit lock, for all artifact kinds

  • While the user edits a slide, or moves or resizes a board of a canvas, the sidecar holds a lock on that artifact folder (POST/DELETE /api/artifacts/edit-lock, renewed every 5 seconds, expiring after 20 seconds without renewal).
  • The agent's Write, Edit and ArtifactCopy ask the sidecar through a new control request, artifact_edit_wait, and wait until the lock is free. If the user changed files meanwhile, the tool call is refused with the list of changed files so the agent reads them first.
  • New session state artifactWait: the conversation shows that the agent is waiting for the user.
  • Every user edit adds one chip per artifact above the message box. With the next message it tells the agent which files the user changed and, after a reorder or delete in a deck, to check its section numbers.
  • Every user write returns { dir, files, latestMtimeMs }; the renderer builds the chip from it instead of composing paths itself.

Also in this PR

  • fileInsideFolder in src/utils/artifacts.ts is now the one check that a file is still inside its artifact folder; the entry file, board files and slide files use it.

Why

Until now only the agent could change a deck. Small corrections (a typo, the order of two slides, one slide too many) should not need a message to the agent. Once the user can write an artifact, the agent must not overwrite that work or build on a stale copy, which is what the lock and the chip are for.

How it was tested

  • bun test: 2766 pass, 0 fail.
  • cd desktop && bun run lint: pass.
  • cd desktop && bun run test -- --run: 3104 pass, 4 skipped. This run was before the last round of changes, which touched only the two design documents and src/server/__tests__/artifact-edit-locks.test.ts.
  • bun test --randomize --seed=1 on the lock and artifact test files: pass.
  • The lock-expiry test was checked to fail when a renewed hold does not replace the old timer and when the lock never expires.
  • The stage script was exercised in a browser with a fixture deck: dragging and landing, cancelling a drag with Esc, reordering with the keyboard, the Delete request, the hover outline, Shift+Enter saved as <br>, no layout jump when a block enters editing, page-number labels.
  • Checked in the dev app on macOS by the maintainer.

Known limits

  • Not checked on Windows.
  • No undo for the user's edits.
  • Agent writes through the shell do not go through the lock.
  • An edit made in the full-screen artifact viewer adds no chip, because the viewer belongs to no session.
  • A chip that has not been sent is lost on refresh.
  • Editing a code block was checked in unit tests only, not in a real browser.

…the agent wait while the user edits an artifact

Slides, with Edit on in the deck toolbar:
- Click a text block to change it in place. Enter saves, Shift+Enter starts
  a new line, Escape cancels. The block under the pointer that a click would
  edit is outlined. The block keeps its layout while it is edited, whatever
  line breaks and indentation its source has.
- Reorder slides in the overview by dragging or with Cmd/Ctrl and the arrow
  keys. The dragged slide follows the pointer, the others glide to their
  places, the overview scrolls at its edges, and Escape cancels the drag.
- Delete the current slide from the toolbar or with Delete in the overview,
  after a confirmation.
- The overview shows slide numbers, and the current slide zooms between the
  overview and the single-slide view.

Artifacts in general:
- While the user edits an artifact in the app (slide text, slide order, a
  canvas board), the sidecar holds a lock on that artifact folder. The
  agent's Write and Edit wait for it, the conversation says it is waiting,
  and the write is refused with the list of changed files if the user
  changed something meanwhile.
- After the user changes an artifact, a chip in that session's composer
  tells the agent with the next message which files changed, and for a deck
  whose slides were reordered or deleted, to check its section numbers.
@GoDiao
GoDiao merged commit 75d9b3b into main Nov 17, 2026
4 checks passed
@GoDiao
GoDiao deleted the feat/slides-editing branch November 17, 2026 01:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant