The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
chore: reformat thread slice and debug script
Steven Enamakel4ea04604f49b
diff --git a/app/src/providers/assistantUiMessages.ts b/app/src/providers/assistantUiMessages.tsindex 72cde3a314..ad8315e09d 100644--- a/app/src/providers/assistantUiMessages.ts+++ b/app/src/providers/assistantUiMessages.ts@@ -567,7 +567,9 @@ function assistantParts(for (const [index, item] of transcript.entries()) {if (item.kind === 'thinking') {if (item.text.trim().length > 0) {- parts.push(reasoningPart(item.text, item.startedAt ?? undefined, item.endedAt ?? undefined));+ parts.push(+ reasoningPart(item.text, item.startedAt ?? undefined, item.endedAt ?? undefined)+ );}continue;}diff --git a/app/src/store/__tests__/threadSlice.test.ts b/app/src/store/__tests__/threadSlice.test.tsindex 4cc2c9ddd1..0b634eda9a 100644--- a/app/src/store/__tests__/threadSlice.test.ts+++ b/app/src/store/__tests__/threadSlice.test.ts@@ -5,9 +5,9 @@ import { threadApi } from '../../services/api/threadApi';import { CoreRpcError } from '../../services/coreRpcClient';import type { Thread, ThreadMessage } from '../../types/thread';import threadReducer, {- applyChannelEvent,addInferenceResponse,addMessageLocal,+ applyChannelEvent,clearAllThreads,clearSelectedThread,clearStaleThread,@@ -115,12 +115,10 @@ describe('threadSlice synchronous reducers', () => {expect(store.getState().thread.messagesByThreadId['channel:telegram/alice/room-1']?.[0]?.extraMetadata?.channelActivity- ).toEqual({- reactions: [{ actorId: 'alice', value: '🔥' }],- readReceipts: [],- });- expect(store.getState().thread.messagesByThreadId['channel:telegram/alice/room-1']?.[0]?.id)- .toBe('user:row-42');+ ).toEqual({ reactions: [{ actorId: 'alice', value: '🔥' }], readReceipts: [] });+ expect(+ store.getState().thread.messagesByThreadId['channel:telegram/alice/room-1']?.[0]?.id+ ).toBe('user:row-42');});// [#1123] setWelcomeThreadId is now a true no-op — kept for TS compat butdiff --git a/app/src/store/threadSlice.ts b/app/src/store/threadSlice.tsindex b820f5c9b0..813536ed35 100644--- a/app/src/store/threadSlice.ts+++ b/app/src/store/threadSlice.ts@@ -494,7 +494,9 @@ const threadSlice = createSlice({if (!rowId || !event.thread_id) return;const thread = (state.channelActivityByThreadId[event.thread_id] ??= {});if (!thread[rowId]) {- const prior = state.messagesByThreadId[event.thread_id]?.find(message => message.id === rowId);+ const prior = state.messagesByThreadId[event.thread_id]?.find(+ message => message.id === rowId+ );const persisted = prior?.extraMetadata?.channelActivity;const saved = persisted && typeof persisted === 'object' ? persisted : undefined;thread[rowId] = {@@ -546,10 +548,7 @@ const threadSlice = createSlice({if (message.id !== rowId) return;message.extraMetadata = {...(message.extraMetadata ?? {}),- channelActivity: {- reactions: activity.reactions,- readReceipts: activity.readReceipts,- },+ channelActivity: { reactions: activity.reactions, readReceipts: activity.readReceipts },};};state.messagesByThreadId[event.thread_id]?.forEach(updateMessage);diff --git a/scripts/debug/web-scripts/typed-image-attachment-roundtrip.mjs b/scripts/debug/web-scripts/typed-image-attachment-roundtrip.mjsindex 925ff40c76..3be2716d87 100644--- a/scripts/debug/web-scripts/typed-image-attachment-roundtrip.mjs+++ b/scripts/debug/web-scripts/typed-image-attachment-roundtrip.mjs@@ -16,7 +16,12 @@ function unwrap(value) {return value;}-export default async function typedImageAttachmentRoundtrip({ page, mock, log, logDir }) {+export default async function typedImageAttachmentRoundtrip({+ page,+ mock,+ log,+ logDir,+}) {const rpcCalls = [];let rpcUrl;let authorization;@@ -35,7 +40,8 @@ export default async function typedImageAttachmentRoundtrip({ page, mock, log, lconst composer = page.getByRole("textbox", { name: "Message input" });await composer.waitFor({ state: "visible", timeout: 30_000 });let threadId = await page.evaluate(- () => window.__OPENHUMAN_STORE__?.getState?.().thread?.selectedThreadId ?? null,+ () =>+ window.__OPENHUMAN_STORE__?.getState?.().thread?.selectedThreadId ?? null,);if (!threadId) {await page.getByRole("button", { name: /new conversation/i }).click();@@ -54,13 +60,20 @@ export default async function typedImageAttachmentRoundtrip({ page, mock, log, lmimeType: "image/png",buffer: IMAGE_BYTES,});- await page.getByText(FILE_NAME, { exact: true }).waitFor({ state: "visible" });+ await page+ .getByText(FILE_NAME, { exact: true })+ .waitFor({ state: "visible" });await composer.fill(USER_TEXT);await page.getByTestId("send-message-button").click();await page.getByText(REPLY, { exact: false }).waitFor({ timeout: 90_000 });- const append = rpcCalls.find((call) => call.method === "openhuman.threads_message_append");- if (!append) throw new Error("composer did not persist the user message through the core");+ const append = rpcCalls.find(+ (call) => call.method === "openhuman.threads_message_append",+ );+ if (!append)+ throw new Error(+ "composer did not persist the user message through the core",+ );const part = append.params?.attachments?.[0];const dataUri = part?.media?.url;if (@@ -69,32 +82,42 @@ export default async function typedImageAttachmentRoundtrip({ page, mock, log, lpart?.media?.fileName !== FILE_NAME ||!dataUri?.startsWith("data:image/png;name=")) {- throw new Error(`core append lacked the typed PNG payload: ${JSON.stringify(part)}`);+ throw new Error(+ `core append lacked the typed PNG payload: ${JSON.stringify(part)}`,+ );}const stagedMessage = unwrap(- await page.evaluate(async ({ rpcUrl: url, token, threadId: id }) => {- const response = await fetch(url, {- method: "POST",- headers: { authorization: token, "content-type": "application/json" },- body: JSON.stringify({- jsonrpc: "2.0",- id: "typed-image-attachment-roundtrip-read",- method: "openhuman.threads_messages_list",- params: { thread_id: id },- }),- });- return response.json();- }, { rpcUrl, token: authorization, threadId }),+ await page.evaluate(+ async ({ rpcUrl: url, token, threadId: id }) => {+ const response = await fetch(url, {+ method: "POST",+ headers: { authorization: token, "content-type": "application/json" },+ body: JSON.stringify({+ jsonrpc: "2.0",+ id: "typed-image-attachment-roundtrip-read",+ method: "openhuman.threads_messages_list",+ params: { thread_id: id },+ }),+ });+ return response.json();+ },+ { rpcUrl, token: authorization, threadId },+ ),);const persisted = stagedMessage?.messages?.find(- (message) => message.sender === "user" && message.content.includes(FILE_NAME),+ (message) =>+ message.sender === "user" && message.content.includes(FILE_NAME),);- if (!persisted) throw new Error("typed image was not persisted in the thread message list");+ if (!persisted)+ throw new Error("typed image was not persisted in the thread message list");if (/\[(?:IMAGE|FILE):/i.test(persisted.content))- throw new Error("modern typed upload leaked a legacy [IMAGE:]/[FILE:] marker");+ throw new Error(+ "modern typed upload leaked a legacy [IMAGE:]/[FILE:] marker",+ );const encoded = persisted.content.match(/\[ATTACHMENT:([^\]]+)\]/)?.[1];- if (!encoded) throw new Error("persisted message has no durable attachment reference");+ if (!encoded)+ throw new Error("persisted message has no durable attachment reference");const reference = JSON.parse(decodeURIComponent(encoded));if (reference.name !== FILE_NAME ||@@ -102,47 +125,79 @@ export default async function typedImageAttachmentRoundtrip({ page, mock, log, lreference.size_bytes !== IMAGE_BYTES.length ||!reference.path.startsWith("uploads/")) {- throw new Error(`staged reference lost image metadata: ${JSON.stringify(reference)}`);+ throw new Error(+ `staged reference lost image metadata: ${JSON.stringify(reference)}`,+ );}const stagedBytes = readFileSync(join(logDir, "workspace", reference.path));if (!stagedBytes.equals(IMAGE_BYTES))throw new Error("staged image bytes differ from the browser upload");- log(`core staged ${reference.mime} ${reference.name} (${stagedBytes.length} bytes) at ${reference.path}`);+ log(+ `core staged ${reference.mime} ${reference.name} (${stagedBytes.length} bytes) at ${reference.path}`,+ );- const chatRequest = rpcCalls.find((call) => call.method === "openhuman.channel_web_chat");+ const chatRequest = rpcCalls.find(+ (call) => call.method === "openhuman.channel_web_chat",+ );if (!chatRequest || chatRequest.params?.message !== persisted.content)- throw new Error("chat turn did not reuse the staged durable reference as its message");+ throw new Error(+ "chat turn did not reuse the staged durable reference as its message",+ );if (/\[(?:IMAGE|FILE):/i.test(chatRequest.params.message))throw new Error("chat turn sent a legacy attachment marker");if (chatRequest.params?.attachments?.length)- throw new Error("ordinary attachment was staged twice as a chat part and durable reference");+ throw new Error(+ "ordinary attachment was staged twice as a chat part and durable reference",+ );- const inferenceRequest = mock.requests().find((request) =>- /(?:^|\/)chat\/completions(?:\?|$)/.test(request.url),- );+ const inferenceRequest = mock+ .requests()+ .find((request) => /(?:^|\/)chat\/completions(?:\?|$)/.test(request.url));if (!inferenceRequest)- throw new Error("mock backend did not receive the model request for the image turn");+ throw new Error(+ "mock backend did not receive the model request for the image turn",+ );const inferenceBody = JSON.parse(inferenceRequest.body);- const userMessages = inferenceBody.messages?.filter((message) => message.role === "user") ?? [];+ const userMessages =+ inferenceBody.messages?.filter((message) => message.role === "user") ?? [];const userText = JSON.stringify(userMessages);if (/\[(?:ATTACHMENT|IMAGE|FILE):/i.test(userText))- throw new Error("legacy or durable staging markers reached the model's user text");+ throw new Error(+ "legacy or durable staging markers reached the model's user text",+ );if (!userText.includes(IMAGE_BYTES.toString("base64")))- throw new Error("model request did not receive the uploaded image bytes as typed media");+ throw new Error(+ "model request did not receive the uploaded image bytes as typed media",+ );log("mock model request contained typed image bytes and clean user text");await page.reload();await composer.waitFor({ state: "visible", timeout: 30_000 });- await page.evaluate((id) => window.__OPENHUMAN_STORE__?.dispatch({- type: "thread/setSelectedThread",- payload: id,- }), threadId);+ await page.evaluate(+ (id) =>+ window.__OPENHUMAN_STORE__?.dispatch({+ type: "thread/setSelectedThread",+ payload: id,+ }),+ threadId,+ );await page.getByText(REPLY, { exact: false }).waitFor({ timeout: 30_000 });const restored = await page.evaluate((id) => {- const messages = window.__OPENHUMAN_STORE__?.getState?.().thread?.messagesByThreadId?.[id] ?? [];- return messages.find((message) => message.sender === "user" && message.content.includes("typed-roundtrip.png"))?.content;+ const messages =+ window.__OPENHUMAN_STORE__?.getState?.().thread?.messagesByThreadId?.[+ id+ ] ?? [];+ return messages.find(+ (message) =>+ message.sender === "user" &&+ message.content.includes("typed-roundtrip.png"),+ )?.content;}, threadId);if (restored !== persisted.content)- throw new Error("reloaded conversation did not restore the durable image reference");- log("typed image attachment survived core staging, chat submission and reload");+ throw new Error(+ "reloaded conversation did not restore the durable image reference",+ );+ log(+ "typed image attachment survived core staging, chat submission and reload",+ );}