Skip to content

Commit 671c7d6

Browse files
authored
style(chat-agent): apply prettier to plan 016 (#134)
1 parent d4e05e9 commit 671c7d6

1 file changed

Lines changed: 13 additions & 11 deletions

File tree

chat-agent/plans/016-draft-write-mode.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ readiness: draft
99

1010
There's a usability gap between the two "write-capable" modes today:
1111

12-
- **`ask`** — the agent can call write tools, but every write pauses on a confirmation dialog (`needsApproval: true`, see `tools.ts:594-606`). Good for high-trust operations, but the round-trip is painful when a user is iterating on content and wants the agent to just _do the work_ — especially on long tasks that involve many small edits (e.g. *"rewrite the intro of all 20 blog posts in the 'news' category"*).
12+
- **`ask`** — the agent can call write tools, but every write pauses on a confirmation dialog (`needsApproval: true`, see `tools.ts:594-606`). Good for high-trust operations, but the round-trip is painful when a user is iterating on content and wants the agent to just _do the work_ — especially on long tasks that involve many small edits (e.g. _"rewrite the intro of all 20 blog posts in the 'news' category"_).
1313
- **`read-write`** — writes execute instantly, but they hit production data directly. Fine for superuser-style maintenance; too sharp for content iteration where the user wants a safety net.
1414

1515
What users actually want for iterative content work: **instant writes with a safety net**. The agent writes freely, no confirmation dialogs, but the result lands as a draft version — nothing is published until the user reviews and publishes it in the admin panel.
@@ -25,11 +25,13 @@ Understanding Payload's draft model is essential for this plan. There are **two
2525
2. **The `_status` field** (document field) — holds the actual status of the document: `'draft'` or `'published'`. This is a regular field on the document, not a query flag.
2626

2727
What `draft: true` does on a write:
28+
2829
- Writes to the **versions table**, not the main table — so the published version is untouched.
2930
- Relaxes required-field validation, allowing the agent to save work-in-progress content.
3031
- Sets `_status: 'draft'` on the new version.
3132

3233
What this means for `draft-write` mode:
34+
3335
- Forcing `draft: true` on every create/update ensures the agent's changes land in the versions table and never overwrite the published document.
3436
- The user reviews the draft in the admin panel's version history and publishes when ready.
3537
- Collections/globals without `versions.drafts` don't have a versions table, so `draft: true` is a no-op — this is why we must refuse writes to non-drafts-enabled targets (see below).
@@ -40,13 +42,13 @@ What this means for `draft-write` mode:
4042

4143
Add a fourth mode between `ask` and `read-write`:
4244

43-
| Mode | Writes execute? | Confirmation | Persists as |
44-
| -------------- | --------------- | ------------ | ----------------------- |
45-
| `read` | no || |
46-
| `ask` | yes | per-call | published |
47-
| **`draft-write`** | yes | none | **draft version** |
48-
| `read-write` | yes | none | published |
49-
| `superuser` | yes | none | published (bypass ACL) |
45+
| Mode | Writes execute? | Confirmation | Persists as |
46+
| ----------------- | --------------- | ------------ | ---------------------- |
47+
| `read` | no |||
48+
| `ask` | yes | per-call | published |
49+
| **`draft-write`** | yes | none | **draft version** |
50+
| `read-write` | yes | none | published |
51+
| `superuser` | yes | none | published (bypass ACL) |
5052

5153
In `draft-write`:
5254

@@ -93,7 +95,7 @@ Add a mode-specific block to `buildSystemPrompt` mirroring the existing per-mode
9395
> - Some collections/globals may not have drafts enabled; writes to those will fail with a clear error. Relay the error and suggest switching modes.
9496
> - You do not need to set `draft: true` yourself — it is forced on every write. Required-field validation is relaxed, so partial saves are fine.
9597
96-
Also skip the line *"Always confirm with the user before creating, updating, or deleting documents"* in this mode, since the whole point is that the user has _already_ opted in to instant writes.
98+
Also skip the line _"Always confirm with the user before creating, updating, or deleting documents"_ in this mode, since the whole point is that the user has _already_ opted in to instant writes.
9799

98100
## Implementation
99101

@@ -114,7 +116,7 @@ Two changes in `filterToolsByMode`:
114116
if (mode === 'draft-write') {
115117
const result: Record<string, ExecutableTool> = {}
116118
for (const [name, tool] of Object.entries(tools)) {
117-
if (name === 'delete') continue // destructive, no draft equivalent
119+
if (name === 'delete') continue // destructive, no draft equivalent
118120
if (name === 'callEndpoint') {
119121
result[name] = { ...tool, needsApproval: true } as ExecutableTool
120122
continue
@@ -154,7 +156,7 @@ Add a branch to the `mode === …` chain in `buildSystemPrompt` with the bullets
154156
### 5. `index.ts`
155157

156158
- Pass `req.payload.config` into `filterToolsByMode` (the `allTools` call at `index.ts:272-280` already has it).
157-
- No change to the `overrideAccess` logic — `draft-write` uses the default `overrideAccess: false`, so user ACL still applies to every write. It's *reversible*, not *privileged*.
159+
- No change to the `overrideAccess` logic — `draft-write` uses the default `overrideAccess: false`, so user ACL still applies to every write. It's _reversible_, not _privileged_.
158160

159161
### 6. `ui/ModeSelector.tsx`
160162

0 commit comments

Comments
 (0)