@burdenoff/microfe-healthybowl 2026.903.13 → 2026.903.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,35 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return e.metadata?.voice === !0;
|
|
4
|
-
}
|
|
5
|
-
function t(e) {
|
|
6
|
-
let t = e.metadata?.voiceSessionId;
|
|
7
|
-
return typeof t == "string" && t.length > 0 ? t : void 0;
|
|
8
|
-
}
|
|
9
|
-
function n(e) {
|
|
10
|
-
return e ? {
|
|
11
|
-
voice: !0,
|
|
12
|
-
voiceSessionId: e
|
|
13
|
-
} : {};
|
|
14
|
-
}
|
|
15
|
-
function r(t) {
|
|
16
|
-
return t.filter((t) => !e(t));
|
|
17
|
-
}
|
|
18
|
-
function i(t) {
|
|
19
|
-
return t.filter(e);
|
|
20
|
-
}
|
|
21
|
-
function a(e, t) {
|
|
22
|
-
let n = [];
|
|
23
|
-
for (let r of e) {
|
|
24
|
-
let e = t(r), i = n[n.length - 1];
|
|
25
|
-
i && i.sessionId === e ? i.turns.push(r) : n.push({
|
|
26
|
-
sessionId: e,
|
|
27
|
-
turns: [r]
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
return n;
|
|
31
|
-
}
|
|
32
|
-
//#endregion
|
|
33
|
-
export { r as chatTurns, a as groupConsecutiveBySession, e as isVoiceTurn, n as voiceMarker, t as voiceSessionIdOf, i as voiceTurnsOnly };
|
|
34
|
-
|
|
35
|
-
//# sourceMappingURL=voiceTurnVisibility.js.map
|
|
1
|
+
import { chatTurns as e, groupConsecutiveBySession as t, isVoiceTurn as n, voiceMarker as r, voiceSessionIdOf as i, voiceTurnsOnly as a } from "@burdenoff/fe-libs/shared/assistant";
|
|
2
|
+
export { e as chatTurns, t as groupConsecutiveBySession, n as isVoiceTurn, r as voiceMarker, i as voiceSessionIdOf, a as voiceTurnsOnly };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@burdenoff/microfe-healthybowl",
|
|
3
|
-
"version": "2026.903.
|
|
3
|
+
"version": "2026.903.15",
|
|
4
4
|
"description": "Burdenoff HealthyBowl Microfrontend - Comprehensive organic farming and agro-foods management platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@apollo/client": "^4.0.11",
|
|
51
|
-
"@burdenoff/fe-libs": "2026.
|
|
51
|
+
"@burdenoff/fe-libs": "2026.903.5",
|
|
52
52
|
"@burdenoff/planmagnet-fe-sdk": "2026.831.1",
|
|
53
53
|
"@tanstack/react-query": "^5.90.16",
|
|
54
54
|
"clsx": "^2.1.1",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"voiceTurnVisibility.js","names":[],"sources":["../../src/utils/voiceTurnVisibility.ts"],"sourcesContent":["/**\n * Which surface does a turn belong to?\n *\n * Voice and chat share ONE conversation: the live session was built as an\n * overlay over the chat thread, so `submitVoiceTurn` calls the same `handleSend`\n * the composer does and both write into the same persisted `messages` array.\n * That is why every spoken exchange appeared in the typed thread, and why the\n * voice panel painted the last six messages of the whole conversation —\n * including typed replies full of `##` and `**`, which it renders as literal\n * text.\n *\n * One marker fixes both directions:\n * - the chat panel hides turns that happened in voice\n * - the voice panel shows ONLY turns that happened in voice\n *\n * ★ Deliberately a display split, not separate persistence. It survives a\n * reload because the chat transcript is never rehydrated from the backend — the\n * store is the only source of truth for what either panel shows. The backend\n * session is still shared, so the model keeps full context of the conversation\n * across both surfaces, which is what makes \"carry on where we left off\" work.\n * Genuinely separate backend sessions are a larger change and would cost that.\n */\n\ninterface TurnLike {\n metadata?: ({ voice?: boolean; voiceSessionId?: string } & Record<string, unknown>) | undefined;\n}\n\n/** True when this turn happened inside a live voice session. */\nexport function isVoiceTurn(message: TurnLike): boolean {\n return message.metadata?.voice === true;\n}\n\n/**\n * WHICH voice session produced this turn, if we know.\n *\n * ★ `undefined` is a real answer, not a failure: every spoken turn recorded\n * before session ids existed carries `voice: true` and nothing else, and those\n * conversations are in users' localStorage today. It means \"some earlier\n * session\" and must never be read as \"not spoken\" — `isVoiceTurn` remains the\n * only thing that decides which surface a turn belongs to.\n */\nexport function voiceSessionIdOf(message: TurnLike): string | undefined {\n const id = message.metadata?.voiceSessionId;\n return typeof id === 'string' && id.length > 0 ? id : undefined;\n}\n\n/**\n * The marker as a fragment to spread into a message's `metadata`.\n *\n * ★ `patchMessage` REPLACES `metadata` instead of merging it, so every write\n * that rebuilds the object has to re-assert this or the turn silently demotes\n * itself to a chat turn. That is exactly what shipped: the marker was stamped\n * at creation and destroyed the instant the reply completed, so a spoken answer\n * appeared in the typed thread AND disappeared from the voice transcript at the\n * same moment — the transcript could only ever show the user's questions.\n *\n * Spreading one helper at all four sites is what keeps them from drifting;\n * `voiceMarkerCallSitesAreComplete` in the test file fails the build if a new\n * metadata write forgets it.\n *\n * ★ Takes the SESSION ID rather than a boolean, and stamps both fields from it.\n * There used to be a separate `dictated` flag that call sites passed straight\n * through, which made it possible to mark a turn as spoken while recording no\n * session — a state with no meaning that only the transcript would ever notice.\n * One argument means the two can never disagree.\n *\n * An absent id yields an EMPTY object, so a typed turn gets no marker at all:\n * `chatTurns` is allow-by-default, and a stray `voice: false` would be a second\n * way of saying the same thing.\n */\nexport function voiceMarker(sessionId: string | undefined): { voice?: true; voiceSessionId?: string } {\n return sessionId ? { voice: true, voiceSessionId: sessionId } : {};\n}\n\n/**\n * The turns the CHAT panel should show: everything that was not spoken.\n *\n * Untagged turns are treated as chat, so every conversation recorded before the\n * marker existed keeps rendering exactly as it did.\n */\nexport function chatTurns<T extends TurnLike>(messages: readonly T[]): T[] {\n return messages.filter((message) => !isVoiceTurn(message));\n}\n\n/**\n * The turns the VOICE panel should show: only what was spoken.\n *\n * This is also what scopes the voice transcript to the session. Previously it\n * took the last six messages of the whole conversation, so opening voice on an\n * existing thread immediately painted typed replies — the wall of raw markdown\n * in the operator's screenshot.\n */\nexport function voiceTurnsOnly<T extends TurnLike>(messages: readonly T[]): T[] {\n return messages.filter(isVoiceTurn);\n}\n\n/** One microphone-on-to-End, and the turns it produced, oldest first. */\nexport interface VoiceSessionGroup<T> {\n /**\n * `undefined` for turns recorded before session ids existed. Rendered as one\n * leading group rather than dropped — it is real history the user spoke.\n */\n sessionId: string | undefined;\n turns: T[];\n}\n\n/**\n * Split spoken turns into the sessions that produced them.\n *\n * The transcript shows a conversation's whole spoken history, which is the more\n * useful of the two options — you can go back to what you asked last time — but\n * run together it reads as one long exchange, and a question from a session\n * three days ago looks like it was just asked. Grouping is what makes showing\n * everything honest.\n *\n * ★ Groups by RUNS, not by collecting every turn with the same id. Turns are\n * stored in the order they happened, so a run IS a session; gathering by id\n * instead would silently reorder history if two sessions ever interleaved, and\n * would hide it rather than show it if they did.\n *\n * ★ Consecutive un-stamped turns collapse into a single leading group. Treating\n * each as its own session would print a divider between every pre-existing turn\n * — one long exchange shattered into fragments, which is worse than the\n * undivided version this is meant to fix.\n */\nexport function groupBySession<T extends TurnLike>(turns: readonly T[]): VoiceSessionGroup<T>[] {\n return groupConsecutiveBySession(turns, voiceSessionIdOf);\n}\n\n/**\n * The same grouping for turns that have already been flattened for display.\n *\n * The transcript renders `{id, role, text}`, not `Message`, so it cannot reach\n * `metadata`. Passing the extractor keeps ONE implementation of the run logic\n * instead of a second copy that drifts — the subtle part is the `undefined`\n * merge, and having it in two places is how one of them stops doing it.\n */\nexport function groupConsecutiveBySession<T>(\n turns: readonly T[],\n sessionIdOf: (turn: T) => string | undefined\n): VoiceSessionGroup<T>[] {\n const groups: VoiceSessionGroup<T>[] = [];\n for (const turn of turns) {\n const sessionId = sessionIdOf(turn);\n const current = groups[groups.length - 1];\n // A run continues while the id is unchanged. `undefined === undefined` is\n // what merges the legacy turns, and is deliberate rather than incidental.\n if (current && current.sessionId === sessionId) current.turns.push(turn);\n else groups.push({ sessionId, turns: [turn] });\n }\n return groups;\n}\n\n/**\n * A spoken turn flattened for display.\n *\n * ★ Shared by every component between the chat area and the transcript, so the\n * session id is carried in the TYPE and not merely at runtime. The intermediate\n * props used to declare `{id, role, text}` while the objects flowing through\n * happened to have more: it compiled, and the dividers worked, purely because\n * JavaScript keeps the extra property. Any future refactor that rebuilt one of\n * those objects would have dropped the id and silently run every session back\n * together — the exact defect this field was added to fix, reintroduced with no\n * type error.\n */\nexport interface VoiceTranscriptTurn {\n id: string;\n role: 'user' | 'assistant';\n text: string;\n /**\n * When the turn happened, ISO.\n *\n * Carried for the SAVED transcript rather than for the on-screen one: a file\n * that outlives the session is read later, when \"when did I ask that?\" is the\n * actual question, and a record without times answers it badly.\n */\n timestamp: string;\n /**\n * `undefined` on turns recorded before session ids existed.\n *\n * ★ REQUIRED-but-nullable rather than optional, and the difference is the\n * whole point. With `sessionId?: string`, an object rebuilt without the key is\n * still structurally assignable — so a refactor that mapped turns through and\n * dropped it would compile, and every session would silently run back\n * together. Written this way, omitting the key is a type error and passing\n * `undefined` is a decision someone made on purpose.\n */\n sessionId: string | undefined;\n}\n"],"mappings":";AA4BA,SAAgB,EAAY,GAA4B;CACtD,OAAO,EAAQ,UAAU,UAAU;AACrC;AAWA,SAAgB,EAAiB,GAAuC;CACtE,IAAM,IAAK,EAAQ,UAAU;CAC7B,OAAO,OAAO,KAAO,YAAY,EAAG,SAAS,IAAI,IAAK,KAAA;AACxD;AA0BA,SAAgB,EAAY,GAA0E;CACpG,OAAO,IAAY;EAAE,OAAO;EAAM,gBAAgB;CAAU,IAAI,CAAC;AACnE;AAQA,SAAgB,EAA8B,GAA6B;CACzE,OAAO,EAAS,QAAQ,MAAY,CAAC,EAAY,CAAO,CAAC;AAC3D;AAUA,SAAgB,EAAmC,GAA6B;CAC9E,OAAO,EAAS,OAAO,CAAW;AACpC;AA2CA,SAAgB,EACd,GACA,GACwB;CACxB,IAAM,IAAiC,CAAC;CACxC,KAAK,IAAM,KAAQ,GAAO;EACxB,IAAM,IAAY,EAAY,CAAI,GAC5B,IAAU,EAAO,EAAO,SAAS;EAGvC,AAAI,KAAW,EAAQ,cAAc,IAAW,EAAQ,MAAM,KAAK,CAAI,IAClE,EAAO,KAAK;GAAE;GAAW,OAAO,CAAC,CAAI;EAAE,CAAC;CAC/C;CACA,OAAO;AACT"}
|