fix(chat): settle authoritative turns and make capabilities explicit
This commit is contained in:
@@ -8,6 +8,25 @@ test, or a code change without a capture, is `partial` at best.
|
||||
|
||||
Status legend: `todo` · `partial` (some of it works) · `done` (working + captured).
|
||||
|
||||
### Chat audit follow-up (2026-10-20, partial — fresh UI captures pending)
|
||||
|
||||
The following supersedes older C8/B18 implementation details below:
|
||||
- Web attachments are limited to **1 MiB total and eight files**, matching the
|
||||
server. Unsupported harnesses reject attachments before upload storage/queueing.
|
||||
- Uploads live in a private durable `~/.pipelines-chat-attachments` directory
|
||||
(override: `PIPELINES_CHAT_ATTACHMENT_DIR`, must already have a parent and be
|
||||
private). Storage is capped at 64 MiB/512 files; the next upload collects unleased files
|
||||
older than seven days. Queued/in-flight uploads are leased, never collected.
|
||||
Restart retains files, but not in-memory leases or the existing prompt queue.
|
||||
- OpenCode provider-step ends are intermediate progress; foreground completion
|
||||
is read from V2 `/api/session/active`. Failed readback does not advance a queue.
|
||||
- Create replies report `instruction_status` as `applied`, `unsupported`, `failed`
|
||||
or `not_requested`; the UI shows applied/unsupported/failed as chat notices.
|
||||
- The model picker uses the shared modal manager for focus trapping and Escape.
|
||||
|
||||
Unit/HTTP-fixture regressions cover these changes. No live workflow or deployed
|
||||
service was used; new rendered-state captures are **not yet available**.
|
||||
|
||||
## Transport and connection
|
||||
| # | Feature (Android counterpart) | Protocol | Status |
|
||||
| --- | --- | --- | --- |
|
||||
|
||||
+3
-2
@@ -1612,6 +1612,7 @@ export function applyChatEvent(thread, frame, now = Date.now()) {
|
||||
case PART_TOOL:
|
||||
return applyTool(current, frame, now);
|
||||
case EVENT_STEP:
|
||||
if (frame?.step?.intermediate) return current;
|
||||
return setThreadRunning(current, str(frame?.step?.status) !== STEP_ENDED, now);
|
||||
// A shell frame only folds its shell into the retained set: it NEVER marks
|
||||
// the thread running, because a background process is not the turn — a shell
|
||||
@@ -1948,7 +1949,7 @@ export function queuedAfterFrame(queued, frame) {
|
||||
* running bit, which the composer's Stop control reads.
|
||||
*/
|
||||
export function runningAfterFrame(running, frame) {
|
||||
if (frame?.kind === "step" && frame?.step?.status === "ended") return false;
|
||||
if (frame?.kind === "step" && frame?.step?.status === "ended" && !frame?.step?.intermediate) return false;
|
||||
return running === true;
|
||||
}
|
||||
|
||||
@@ -1961,7 +1962,7 @@ export function runningAfterFrame(running, frame) {
|
||||
* A browser-side guard, so a runaway pick is refused with a reason instead of
|
||||
* being handed to the server; the server applies its own limits on top.
|
||||
*/
|
||||
export const MAX_ATTACHMENT_BYTES = 25 * 1024 * 1024;
|
||||
export const MAX_ATTACHMENT_BYTES = 1024 * 1024;
|
||||
|
||||
/** The fallback display name when neither the name nor the uri gives one. */
|
||||
export const ATTACHMENT_FALLBACK_NAME = "file";
|
||||
|
||||
@@ -555,6 +555,14 @@ function cancelNewChat() {
|
||||
* of the list, becomes the open conversation and loads its (empty) history; on
|
||||
* failure the server's own reason stays in the pane, which does not close.
|
||||
*/
|
||||
function reportInstructionStatus(created) {
|
||||
const status = created?.instruction_status;
|
||||
if (status === "applied") addChatNotice(created.id, "Session instructions applied.");
|
||||
else if (status === "unsupported" || status === "failed") {
|
||||
addChatNotice(created.id, `Session instructions ${status}: ${created.instruction_error || "this harness does not support preloaded instructions"}.`);
|
||||
}
|
||||
}
|
||||
|
||||
async function createNewChat() {
|
||||
const create = state.chatCreate;
|
||||
if (!create || create.creating) return;
|
||||
@@ -570,6 +578,7 @@ async function createNewChat() {
|
||||
state.chatCreate = null;
|
||||
state.chatSessions = chatCreateSucceeded(state.chatSessions, created);
|
||||
await openChatSession(created.id);
|
||||
reportInstructionStatus(created);
|
||||
await loadChatSessions();
|
||||
} catch (error) {
|
||||
if (!state.chatCreate) return;
|
||||
@@ -1559,6 +1568,7 @@ async function startChatSession(directory) {
|
||||
});
|
||||
const title = String(created.title ?? "").trim() || "New chat";
|
||||
addChatNotice(created.id, `Started a new session “${title}” in ${directory}.`);
|
||||
reportInstructionStatus(created);
|
||||
await openChatSession(created.id);
|
||||
// An ephemeral (verification) create is intentionally absent from the server's
|
||||
// list, so a refresh here would replace the just-opened conversation and drop
|
||||
@@ -1717,6 +1727,7 @@ function base64FromBuffer(buffer) {
|
||||
async function chatAttachmentPayloads(attachments) {
|
||||
const valid = (attachments ?? []).filter((attachment) => attachment?.error == null);
|
||||
if (valid.length === 0) return [];
|
||||
if (valid.length > 8) throw new Error("At most 8 attachments are allowed.");
|
||||
let total = 0;
|
||||
const payloads = [];
|
||||
for (const attachment of valid) {
|
||||
@@ -2736,6 +2747,10 @@ function renderChatModelDialog(session) {
|
||||
);
|
||||
panel.append(actions);
|
||||
overlay.append(panel);
|
||||
modal.stage("chat-model", overlay, {
|
||||
onClose: closeChatModelPicker,
|
||||
fallbackSelectors: ["#chatComposer", "#detailTitle", "#pane-main"],
|
||||
});
|
||||
return overlay;
|
||||
}
|
||||
|
||||
|
||||
+16
-3
@@ -888,14 +888,27 @@ test("attachmentDisplayName prefers the name, then the uri's basename, then file
|
||||
assert.equal(attachmentDisplayName("", ""), "file");
|
||||
});
|
||||
|
||||
test("attachmentError reports an unreadable file and the 25 MiB limit by name", () => {
|
||||
test("intermediate tool steps preserve Stop and the running turn", () => {
|
||||
let thread = applyChatEvent(newChatThread("ses_1"), { kind: "step", step: { status: "started" } }, 100);
|
||||
for (let index = 0; index < 3; index++) {
|
||||
const frame = { kind: "step", step: { status: "ended", intermediate: true, index } };
|
||||
thread = applyChatEvent(thread, frame, 200 + index);
|
||||
assert.equal(thread.running, true);
|
||||
assert.equal(runningAfterFrame(true, frame), true);
|
||||
assert.equal(composerAction(thread), "stop");
|
||||
}
|
||||
thread = applyChatEvent(thread, { kind: "step", step: { status: "ended" } }, 300);
|
||||
assert.equal(thread.running, false);
|
||||
});
|
||||
|
||||
test("attachmentError reports an unreadable file and the server's 1 MiB limit by name", () => {
|
||||
assert.equal(attachmentError("a.txt", 3, true), null);
|
||||
assert.equal(attachmentError("a.txt", 3, false), '"a.txt" could not be read.');
|
||||
assert.equal(attachmentError("", 3, false), '"file" could not be read.');
|
||||
assert.equal(MAX_ATTACHMENT_BYTES, 25 * 1024 * 1024);
|
||||
assert.equal(MAX_ATTACHMENT_BYTES, 1024 * 1024);
|
||||
assert.equal(
|
||||
attachmentError("big.bin", MAX_ATTACHMENT_BYTES + 1, true),
|
||||
'"big.bin" is too large (25.0 MiB limit).',
|
||||
'"big.bin" is too large (1.0 MiB limit).',
|
||||
);
|
||||
// Exactly at the limit is allowed; the limit reads through the shared humanBytes.
|
||||
assert.equal(attachmentError("big.bin", MAX_ATTACHMENT_BYTES, true), null);
|
||||
|
||||
Reference in New Issue
Block a user