You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: skills/clickui-email/SKILL.md
+45-29Lines changed: 45 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -170,9 +170,8 @@ else
170
170
fi
171
171
```
172
172
173
-
After each poll:
174
-
- Inspect `status`, `result`, and `pageStatus`
175
-
- If `pageStatus.stopMonitoring` is `true` → stop
173
+
After each poll result:
174
+
- If `pageStatus.stopMonitoring` is `true` → **stop immediately** (the `/wait` endpoint unblocks on this)
176
175
- If `status` is `"completed"` → stop
177
176
- If `status` is `"rewriting"` → handle the request (see Rewrite / Update Rules below), then poll again
178
177
- Otherwise → wait 1 second (`sleep 1` as a separate exec), then poll again
@@ -192,39 +191,55 @@ The UI is not only a final approval screen. The user may:
192
191
193
192
### Reply requests
194
193
195
-
If the result indicates `requestReplyDraft: true` for an email:
196
-
- update the payload quickly so the UI can show that email as loading
197
-
- generate the reply draft yourself as the agent — use the email body already present in the poll response payload (do not re-fetch from Gmail)
198
-
- PUT the finished draft back into the same session
199
-
- do not create a new session
194
+
When the result has `requestReplyDraft: true`, follow this exact two-PUT sequence:
200
195
201
-
**Important:** The reply draft must be placed **on the email item itself**, not in `payload.draft`. The UI reads `replyState`, `replyDraft`, and `replyUnread` from the individual email object in the inbox array.
196
+
**PUT 1 — mark as loading** (do this immediately so the UI shows a spinner):
202
197
203
-
Reply draft fields on the email item:
204
-
```json
198
+
```bash
199
+
curl -s -X PUT "$AGENTCLICK_BASE/api/sessions/${SESSION_ID}/payload" \
> **CRITICAL — paragraph format:**`paragraphs` must be an array of `{"id": "p1", "content": "..."}` objects. Plain strings will break the UI. The `id` can be any unique string (e.g. `"p1"`, `"p2"`).
237
+
238
+
> **CRITICAL — placement:** The draft goes inside the email item in `inbox`, NOT in `payload.draft`. The UI reads `replyState` and `replyDraft` from the individual email object.
- the user can keep browsing while reply is loading
227
-
- the email row can later show a ready state and unread dot when the draft arrives
242
+
Why two PUTs: The server keeps the session in `rewriting` state as long as any email has `replyState: "loading"`. PUT 1 sets loading to lock the rewriting state open; PUT 2 delivers the finished draft. Without PUT 1, the session drops back to `pending` between calls and the second PUT is rejected.
228
243
229
244
### Read more requests
230
245
@@ -286,8 +301,9 @@ curl -s -X PUT "$AGENTCLICK_BASE/api/sessions/${SESSION_ID}/payload" \
286
301
287
302
Rules:
288
303
- Reuse the same `SESSION_ID` for the full interaction.
289
-
-**Two-PUT pattern for replies:** first PUT a loading-state update (`replyState: "loading"`), then PUT the completed draft (`replyState: "ready"` with `replyDraft`). The server keeps the session in `rewriting` status as long as any email has `replyState: "loading"`, so the second PUT is accepted.
290
-
- If PUT fails, fix it before continuing.
304
+
- For reply drafts, always use the two-PUT sequence described in the Reply requests section above.
305
+
- If PUT fails with `"Session is not in rewriting state"`, the loading email item was not set — re-trigger by calling `/complete` with `regenerate: true`, then repeat the two-PUT sequence.
306
+
- If PUT fails for any other reason, fix it before continuing.
0 commit comments