fix(chat): settle authoritative turns and make capabilities explicit
This commit is contained in:
+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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user