jg-agent-hq 13.1.4 → 13.1.5

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 13.1.5
4
+
5
+ - Show a message Claude Code takes into a running turn, such as a steer at a tool boundary, in that turn's saved history. Claude Code saves it as a `queued_command` attachment rather than a user record, so it was missing from history and its live row never flushed. It reads as a `user-message` whose `provenance.nativeInputId` is the input the attachment names; background task notifications stay hidden. The reader's projection revision changes, so existing transcripts are indexed again on their next read.
6
+ - Flush a live input once history holds the queued record that names it, matching its turn, kind and text.
7
+
3
8
  ## 13.1.4
4
9
 
5
10
  - Correlate live user inputs against the same acknowledged native identity, turn and content fingerprint as saved history. Verified browser inputs also expose their original optional `browserActionId`, allowing an optimistic row to reconcile before the HTTP receipt arrives.
package/api/README.md CHANGED
@@ -242,9 +242,9 @@ The existing SQLite worker incrementally records file identity, complete-line of
242
242
 
243
243
  Current-chain membership and turn starts are indexed as metadata. Item continuations seek those indexes; they do not walk the full chain per page. A changed branch rebuilds membership before exposing that revision. Repeated native message identities can replace content while retaining their parent; a changed parent for the same identity is an unsupported format.
244
244
 
245
- Selected history reads refresh only that file, retain incomplete tails, and detect truncation or replaced identity. Changed branch/file revisions invalidate item continuations. Only the current parent-linked conversation chain is returned. A compaction's boundary has no parent and names the record before it, which the chain follows back to the start of the conversation; when the transcript holds no such record before the boundary, as in a chat Claude Code moved into a new session, whose boundary names the old session's record, the chain starts at the boundary. Claude Code links each tool result to its own call, so parallel calls whose results finish out of order would leave the later calls and results on a side branch; such a result follows the latest record of its call's turn instead, keeping every call of the response and all their results on the chain without changing its revision. Text is reread from the native file for the selected page and normalized as plain text. Thinking blocks are left out, and a record holding only thinking is hidden, as are `<task-notification>` records and a subagent's sidechain records. Live items leave a subagent's stream frames out likewise, and those frames start no turn, though a subagent's tool results still settle the approvals it asked for. Compaction summaries, `<local-command-stdout>` output and interruption markers are `notice` items, and a slash command is a `user-message` reading `/name args`. A `!` shell input and its output are `command` items, the output's `callId` being the input's UUID. A tool call shows its native name and input, with the block's ID as `callId`, which is null for a record calling several tools; its result is a `tool` item carrying that ID, `failed` when it has `is_error` and `succeeded` otherwise. An Edit or Write result whose metadata has a `filePath` and a `structuredPatch` is a `file-change` item reading the path and its patch lines, or a created file's content, every line of which counts as added. A result Claude Code saved to a file reads `Output too large (<size>), saved to a file` followed by its preview, without the file's path. A result made of content blocks, such as a screenshot with its caption, reads as its text blocks, each image as `[Image]`. Other non-text content has explicit native block labels. The index stores each entry's presented kind and visibility, so evidence kind filters match `items` and hidden records never shorten a page. An unknown record containing content is returned as an `unsupported` item when its identity and chain are trustworthy; it cannot imply an agent response, idle state or completion. Each selected page reads at most 4 MiB of record bytes beyond its first record and returns at most 4 MiB of serialized item presentation, so a large-text page can contain fewer rows than its requested limit.
245
+ Selected history reads refresh only that file, retain incomplete tails, and detect truncation or replaced identity. Changed branch/file revisions invalidate item continuations. Only the current parent-linked conversation chain is returned. A compaction's boundary has no parent and names the record before it, which the chain follows back to the start of the conversation; when the transcript holds no such record before the boundary, as in a chat Claude Code moved into a new session, whose boundary names the old session's record, the chain starts at the boundary. Claude Code links each tool result to its own call, so parallel calls whose results finish out of order would leave the later calls and results on a side branch; such a result follows the latest record of its call's turn instead, keeping every call of the response and all their results on the chain without changing its revision. Text is reread from the native file for the selected page and normalized as plain text. Thinking blocks are left out, and a record holding only thinking is hidden, as are `<task-notification>` records and a subagent's sidechain records. A message Claude Code takes into a running turn, such as a steer it takes in at a tool boundary, is saved as a `queued_command` attachment instead of a user record; it is a `user-message` of that turn whose `provenance.nativeInputId` is the native input the attachment names, and other queued commands, such as background task notifications, stay hidden. Live items leave a subagent's stream frames out likewise, and those frames start no turn, though a subagent's tool results still settle the approvals it asked for. Compaction summaries, `<local-command-stdout>` output and interruption markers are `notice` items, and a slash command is a `user-message` reading `/name args`. A `!` shell input and its output are `command` items, the output's `callId` being the input's UUID. A tool call shows its native name and input, with the block's ID as `callId`, which is null for a record calling several tools; its result is a `tool` item carrying that ID, `failed` when it has `is_error` and `succeeded` otherwise. An Edit or Write result whose metadata has a `filePath` and a `structuredPatch` is a `file-change` item reading the path and its patch lines, or a created file's content, every line of which counts as added. A result Claude Code saved to a file reads `Output too large (<size>), saved to a file` followed by its preview, without the file's path. A result made of content blocks, such as a screenshot with its caption, reads as its text blocks, each image as `[Image]`. Other non-text content has explicit native block labels. The index stores each entry's presented kind and visibility, so evidence kind filters match `items` and hidden records never shorten a page. An unknown record containing content is returned as an `unsupported` item when its identity and chain are trustworthy; it cannot imply an agent response, idle state or completion. Each selected page reads at most 4 MiB of record bytes beyond its first record and returns at most 4 MiB of serialized item presentation, so a large-text page can contain fewer rows than its requested limit.
246
246
 
247
- File timestamps and records do not prove that a native process is idle or a turn completed. Claude file-backed thread and turn states are therefore `unknown`, with no invented completion timestamp. Explicit native custom titles are preserved; a missing title remains null. A turn starts at a message the operator sends, including a slash command; task notifications, compaction summaries, local command output, interruption markers and `!` shell records belong to the turn before them. Grouping follows parent links and is not an authoritative execution boundary. A compaction starts a new chain whose first record names the record before it, so history reads on past the compaction to the start of the conversation.
247
+ File timestamps and records do not prove that a native process is idle or a turn completed. Claude file-backed thread and turn states are therefore `unknown`, with no invented completion timestamp. Explicit native custom titles are preserved; a missing title remains null. A turn starts at a message the operator sends, including a slash command, except a message taken into a running turn, which belongs to it; task notifications, compaction summaries, local command output, interruption markers and `!` shell records belong to the turn before them. Grouping follows parent links and is not an authoritative execution boundary. A compaction starts a new chain whose first record names the record before it, so history reads on past the compaction to the start of the conversation.
248
248
 
249
249
  ## Thread control and live input
250
250
 
@@ -369,7 +369,7 @@ The installed CLI exposes `suggest-thread-name --topic <topic>`. Suggestions nor
369
369
 
370
370
  Control pages default to 32 and cap at 128. Seek cursors are bound to their complete query and ordering. Reads recheck allowed workspaces. Rejected controls retain their known thread association, and native availability failures appear in each affected thread's replay. Lifecycle replay contains metadata, not token or tool output. Each provider has a bounded native lifecycle backlog; overflow stops that source and marks its state uncertain rather than losing events silently. Live items don't count toward it. The runtime recognizes a repeated lifecycle observation within one runtime; startup forgets the observations earlier runtimes recorded. Other providers retain their independent connection and admission state.
371
371
 
372
- Live item presentation is bounded to 128 items per cached thread, 32 windows and 4 MiB of serialized presentation across the runtime, including escaped text and identifiers. This leaves room inside the IPC response limit. Display text uses the same truncation contract as native history. Eviction, an unavailable window or missing chunks sets `hasGap`. Completed items remain `awaiting-flush` after thread closure until a native history page holds the same item, with exactly matching normalized content or, for an item with an outcome, the same final outcome, or the bounded cache evicts them. The outcome is enough because Codex shortens long command output when it saves it. An item still streaming when its turn ended, such as a message an interrupt or a Codex steer cut, stays `awaiting-flush` until a native history page holds an item of that turn, since the provider may never save it; the history then shows what was saved of it. A client's `items` read is one such page, and when a turn ends the runtime reads that turn's own history too, newest first and at most 8 pages of 128, until none of its finished items remain, so the window doesn't wait on a client that never reads them. Codex's saved state can trail its turn's end, so a turn whose items remain is read once more 2 seconds later; a failed read leaves them to the next history read. A client that shows live items should therefore expect them to leave the window before its own history read holds them. Read persisted history and the live window together after reconnect; a process restart cannot reconstruct unflushed in-memory content.
372
+ Live item presentation is bounded to 128 items per cached thread, 32 windows and 4 MiB of serialized presentation across the runtime, including escaped text and identifiers. This leaves room inside the IPC response limit. Display text uses the same truncation contract as native history. Eviction, an unavailable window or missing chunks sets `hasGap`. Completed items remain `awaiting-flush` after thread closure until a native history page holds the same item, with exactly matching normalized content or, for an item with an outcome, the same final outcome, or the bounded cache evicts them. A message Claude Code saved as a queued command matches the live input its `provenance.nativeInputId` names. The outcome is enough because Codex shortens long command output when it saves it. An item still streaming when its turn ended, such as a message an interrupt or a Codex steer cut, stays `awaiting-flush` until a native history page holds an item of that turn, since the provider may never save it; the history then shows what was saved of it. A client's `items` read is one such page, and when a turn ends the runtime reads that turn's own history too, newest first and at most 8 pages of 128, until none of its finished items remain, so the window doesn't wait on a client that never reads them. Codex's saved state can trail its turn's end, so a turn whose items remain is read once more 2 seconds later; a failed read leaves them to the next history read. A client that shows live items should therefore expect them to leave the window before its own history read holds them. Read persisted history and the live window together after reconnect; a process restart cannot reconstruct unflushed in-memory content.
373
373
 
374
374
  Items expose only normalized presentation fields, and one mapping per provider presents `items`, live items and `session-evidence` alike, as the provider's CLI shows them. Kinds are `user-message`, `agent-message`, `command`, `tool`, `file-change`, `notice` and `unsupported`. `callId` pairs a tool call with its result, or is null. `outcome` is `succeeded`, `failed`, or null when unknown or still running. `files` lists each file a file change touched, at most 128, with its added and removed lines, and is empty on other items. `outcome` and `files` come from the full native record, so `textLimit` never changes them. Unknown native kinds report `unsupported` without copying arbitrary payloads. Display text is bounded to 65,536 UTF-16 code units without splitting a surrogate pair; `isTruncated` reports omissions. An unsupported or oversized native transport frame fails explicitly. `createdAt` is the item's time in Unix milliseconds, or null when the provider records none. A Claude item takes its record's `timestamp`, and a live one the time its frame arrived. A Codex item takes its own native lifecycle timestamps, already in milliseconds: operator input prefers `startedAtMs`, and other items prefer `completedAtMs`, using the other item timestamp when the preferred one is missing. History entries and live notifications use the same mapping, with entry/notification metadata preferred over the matching embedded item field. Missing item timestamps remain null; turn times and observation times are never substituted. History pages and item details need no additional turn reads for timing.
375
375
 
@@ -50,6 +50,8 @@ export declare class LiveItems {
50
50
  * content, or, for an item with an outcome, the same final outcome, since a provider can shorten
51
51
  * long output when it saves it, as Codex does. An item its turn ended before the provider
52
52
  * finished goes once persisted history holds that turn, which then shows what was saved of it.
53
+ * A message saved under another record than the live input it came from, as Claude Code saves a
54
+ * message sent while a turn ran, matches that input by the native input it names.
53
55
  */
54
56
  reconcile(nativeId: string, persisted: IHistoryItem[]): void;
55
57
  /**
@@ -152,6 +152,8 @@ export class LiveItems {
152
152
  * content, or, for an item with an outcome, the same final outcome, since a provider can shorten
153
153
  * long output when it saves it, as Codex does. An item its turn ended before the provider
154
154
  * finished goes once persisted history holds that turn, which then shows what was saved of it.
155
+ * A message saved under another record than the live input it came from, as Claude Code saves a
156
+ * message sent while a turn ran, matches that input by the native input it names.
155
157
  */
156
158
  reconcile(nativeId, persisted) {
157
159
  const thread = this.__threads.get(nativeId);
@@ -165,16 +167,22 @@ export class LiveItems {
165
167
  thread.revision = this.__change();
166
168
  }
167
169
  for (const item of persisted) {
168
- const key = JSON.stringify([item.turnId, item.nativeId]);
169
- const entry = thread.items.get(key);
170
- if (entry?.isComplete &&
171
- entry.item.nativeType === item.nativeType &&
172
- entry.item.kind === item.kind &&
173
- ((entry.item.text === item.text && entry.item.isTruncated === item.isTruncated) ||
174
- (item.outcome !== null && entry.item.outcome === item.outcome))) {
175
- this.__bytes -= entry.bytes;
176
- thread.items.delete(key);
177
- thread.revision = this.__change();
170
+ const { nativeInputId } = item.provenance;
171
+ const liveIds = item.kind === 'user-message' && nativeInputId !== null && nativeInputId !== item.nativeId
172
+ ? [item.nativeId, nativeInputId]
173
+ : [item.nativeId];
174
+ for (const liveId of liveIds) {
175
+ const key = JSON.stringify([item.turnId, liveId]);
176
+ const entry = thread.items.get(key);
177
+ if (entry?.isComplete &&
178
+ entry.item.nativeType === item.nativeType &&
179
+ entry.item.kind === item.kind &&
180
+ ((entry.item.text === item.text && entry.item.isTruncated === item.isTruncated) ||
181
+ (item.outcome !== null && entry.item.outcome === item.outcome))) {
182
+ this.__bytes -= entry.bytes;
183
+ thread.items.delete(key);
184
+ thread.revision = this.__change();
185
+ }
178
186
  }
179
187
  }
180
188
  }
@@ -8,13 +8,13 @@ import { createRequestCursors, decodeBase64Image, imageUnavailable, } from '../.
8
8
  import { evidencePosition, buildEvidencePage, EVIDENCE_SOURCE_PAGE_SIZE, } from '../../../sessions/evidence/index.js';
9
9
  import { HQ_ERRORS } from '../../../errors/index.js';
10
10
  import { EntrySeekSchema, RecordSchema, ApiRequestMetadataSchema, SeekSchema, } from './types.js';
11
- import { isClaudeAnswer, isClaudeCallFor, isClaudeRecordCwd, isClaudeWorkspaceCwd, openTranscript, projectDirectory, readClaudeParentUuid, readContinuedIn, toClaudeDetail, toClaudeImageData, toClaudeItem, } from './utilities.js';
11
+ import { isClaudeAnswer, isClaudeCallFor, isClaudeRecordCwd, isClaudeWorkspaceCwd, openTranscript, projectDirectory, readClaudeParentUuid, readClaudeQueuedInput, readContinuedIn, toClaudeDetail, toClaudeImageData, toClaudeItem, } from './utilities.js';
12
12
  // an item page continues before its oldest record
13
13
  const itemCursors = createRequestCursors(EntrySeekSchema);
14
14
  // a thread page's continuation: the activity time and session ID of the last transcript listed
15
15
  const THREAD_CURSOR = /^(\d{1,16}):(.+)$/;
16
16
  // identifies the path and record interpretation used by persisted projection entries
17
- const HISTORY_PROJECTION_VERSION = 10;
17
+ const HISTORY_PROJECTION_VERSION = 11;
18
18
  // the transcripts whose continuing session is remembered, oldest dropped first
19
19
  const MAX_CONTINUED_ANSWERS = 1_024;
20
20
  // one record, such as a tool result holding images
@@ -779,13 +779,18 @@ export class ClaudeHistoryModel {
779
779
  const nativeParent = nativeParentUuid
780
780
  ? this.__statements.get(PARENT_TURN, root, nativeId, nativeParentUuid)
781
781
  : undefined;
782
+ // a message sent while a turn ran is an attachment that shows, though it starts no turn
783
+ const isQueuedInput = readClaudeQueuedInput(record) !== null;
782
784
  // the CLI's presentation decides what is shown, the kind evidence filters on and where turns start
783
- const item = record.message !== undefined && !record.isMeta ? toClaudeItem(record, record.uuid) : null;
785
+ const item = (record.message !== undefined || isQueuedInput) && !record.isMeta
786
+ ? toClaudeItem(record, record.uuid)
787
+ : null;
784
788
  const visible = item !== null;
785
789
  if (nativeParentUuid === record.uuid)
786
790
  this.__unavailable();
787
791
  if (nativeParentUuid && !nativeParent) {
788
- if (visible)
792
+ // an attachment may come a few lines before its parent, so a queued message waits like one
793
+ if (visible && !isQueuedInput)
789
794
  this.__unavailable();
790
795
  /*
791
796
  * A compaction's boundary has no parent and names the record before it, which is indexed
@@ -809,7 +814,7 @@ export class ClaudeHistoryModel {
809
814
  const parent = parentUuid === nativeParentUuid
810
815
  ? nativeParent
811
816
  : this.__statements.get(PARENT_TURN, root, nativeId, parentUuid);
812
- const textPrompt = item?.kind === 'user-message';
817
+ const textPrompt = item?.kind === 'user-message' && !isQueuedInput;
813
818
  const turnId = textPrompt
814
819
  ? record.uuid
815
820
  : typeof parent?.turn_id === 'string'
@@ -57,8 +57,15 @@ export declare const RecordSchema: z.ZodObject<{
57
57
  }, z.core.$strip>>;
58
58
  toolUseResult: z.ZodOptional<z.ZodUnknown>;
59
59
  sourceToolAssistantUUID: z.ZodOptional<z.ZodString>;
60
+ attachment: z.ZodOptional<z.ZodUnknown>;
60
61
  }, z.core.$strip>;
61
62
  export type IRecord = z.infer<typeof RecordSchema>;
63
+ export declare const QueuedPromptSchema: z.ZodObject<{
64
+ type: z.ZodLiteral<"queued_command">;
65
+ commandMode: z.ZodLiteral<"prompt">;
66
+ prompt: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodUnknown>]>;
67
+ source_uuid: z.ZodOptional<z.ZodString>;
68
+ }, z.core.$strip>;
62
69
  export declare const FilePatchSchema: z.ZodObject<{
63
70
  filePath: z.ZodString;
64
71
  type: z.ZodOptional<z.ZodString>;
@@ -27,6 +27,19 @@ export const RecordSchema = z.object({
27
27
  toolUseResult: z.unknown().optional(),
28
28
  // the call a tool result answers, which Claude Code also writes as the result's parent
29
29
  sourceToolAssistantUUID: z.string().optional(),
30
+ // what an attachment record carries, such as a message queued while a turn ran
31
+ attachment: z.unknown().optional(),
32
+ });
33
+ /*
34
+ * A message sent while a turn ran, which Claude Code takes into that turn and records as a queued
35
+ * command attachment instead of a user record; `source_uuid` names the native input it came from.
36
+ * Other queued commands, such as background task notifications, aren't messages.
37
+ */
38
+ export const QueuedPromptSchema = z.object({
39
+ type: z.literal('queued_command'),
40
+ commandMode: z.literal('prompt'),
41
+ prompt: z.union([z.string(), z.array(z.unknown())]),
42
+ source_uuid: z.string().min(1).max(4096).optional(),
30
43
  });
31
44
  // the file Claude Code records on an Edit or Write result; a created file's patch is empty
32
45
  export const FilePatchSchema = z.object({
@@ -60,17 +60,30 @@ export declare const deleteTranscript: (workspaceRoot: string, nativeId: string)
60
60
  * @returns The continuing session's ID, or null, including when a transcript can't be read.
61
61
  */
62
62
  export declare const readContinuedIn: (directory: string, nativeId: string) => string | null;
63
+ /**
64
+ * Reads the message a queued command attachment holds: input Claude Code took into a running turn,
65
+ * which it records as an attachment rather than a user record.
66
+ * @param record The record.
67
+ * @returns The message as a user record's content and the native input it came from, or null for
68
+ * any other record, such as a background task notification.
69
+ */
70
+ export declare const readClaudeQueuedInput: (record: IRecord) => {
71
+ content: string | unknown[];
72
+ inputId: string | null;
73
+ } | null;
63
74
  /**
64
75
  * Presents one native record as the CLI shows it, shared by history pages, live items and
65
76
  * evidence. Outcome and files come from the full record, before the text is cut, and its time
66
- * from the record's `timestamp`.
77
+ * from the record's `timestamp`. A message queued while a turn ran shows as the user message it
78
+ * is, whose native input is the one Claude Code names.
67
79
  * @returns The item, or null for a record the CLI leaves out, such as thinking or a task notification.
68
80
  * @throws
69
81
  * - JG_AGENT_HQ_CLAUDE_HISTORY_UNAVAILABLE: The Claude history is unavailable
70
82
  */
71
- export declare const toClaudeItem: (record: IRecord, turnId: string, fullBody?: boolean) => IHistoryItem | null;
83
+ export declare const toClaudeItem: (native: IRecord, turnId: string, fullBody?: boolean) => IHistoryItem | null;
72
84
  /**
73
- * Lists the images a record holds, in its message and in its tool results' content, in order.
85
+ * Lists the images a record holds, in its message, a queued message included, and in its tool
86
+ * results' content, in order.
74
87
  * @param record The record.
75
88
  * @returns At most 64 images, each its base64 data, or null for one that has no base64 source.
76
89
  */
@@ -93,9 +106,10 @@ export declare const isClaudeCallFor: (candidate: IRecord, item: IHistoryItem) =
93
106
  /**
94
107
  * Reads what a developer inspects in one record beyond its display text: a Bash command or `!`
95
108
  * shell input with its output, a tool call or result, an Edit or Write patch, and the images it
96
- * holds. A result takes its command or tool name from the call it answers.
97
- * @param record The item's record.
109
+ * holds. A result takes its command or tool name from the call it answers, and a queued message
110
+ * reads as the user message it is.
111
+ * @param native The item's record.
98
112
  * @param call The call it answers, or null when it answers none or the call isn't found.
99
113
  * @returns The detail's parts; the item itself comes from `toClaudeItem`.
100
114
  */
101
- export declare const toClaudeDetail: (record: IRecord, call: IRecord | null) => Omit<IItemDetail, "item">;
115
+ export declare const toClaudeDetail: (native: IRecord, call: IRecord | null) => Omit<IItemDetail, "item">;
@@ -9,7 +9,7 @@ import { MAX_ITEM_IMAGES, MAX_ITEM_TEXT_LENGTH, } from '../../../contracts/index
9
9
  import { countLines, describeBase64Image, keepTextEnd, toWholeFileDiff, } from '../../../sessions/index.js';
10
10
  import { nativeProvenance } from '../../../sessions/evidence/index.js';
11
11
  import { HQ_ERRORS } from '../../../errors/index.js';
12
- import { FilePatchSchema } from './types.js';
12
+ import { FilePatchSchema, QueuedPromptSchema } from './types.js';
13
13
  const EXCLUDED = new Set(['_archive', '_archives', '_backup', '_backups']);
14
14
  const hasExcludedSegment = (path) => path.split(sep).some((part) => EXCLUDED.has(part));
15
15
  /**
@@ -405,19 +405,43 @@ const toPresentation = (record) => {
405
405
  callId: calls.length === 1 ? (calls[0].id ?? null) : null,
406
406
  };
407
407
  };
408
+ /**
409
+ * Reads the message a queued command attachment holds: input Claude Code took into a running turn,
410
+ * which it records as an attachment rather than a user record.
411
+ * @param record The record.
412
+ * @returns The message as a user record's content and the native input it came from, or null for
413
+ * any other record, such as a background task notification.
414
+ */
415
+ export const readClaudeQueuedInput = (record) => {
416
+ if (record.type !== 'attachment')
417
+ return null;
418
+ const queued = QueuedPromptSchema.safeParse(record.attachment);
419
+ return queued.success
420
+ ? { content: queued.data.prompt, inputId: queued.data.source_uuid ?? null }
421
+ : null;
422
+ };
423
+ // presents a queued command's message as the user record it stands for, and any other record as is
424
+ const toMessageRecord = (record) => {
425
+ const queued = readClaudeQueuedInput(record);
426
+ return queued
427
+ ? { ...record, type: 'user', message: { role: 'user', content: queued.content } }
428
+ : record;
429
+ };
408
430
  /**
409
431
  * Presents one native record as the CLI shows it, shared by history pages, live items and
410
432
  * evidence. Outcome and files come from the full record, before the text is cut, and its time
411
- * from the record's `timestamp`.
433
+ * from the record's `timestamp`. A message queued while a turn ran shows as the user message it
434
+ * is, whose native input is the one Claude Code names.
412
435
  * @returns The item, or null for a record the CLI leaves out, such as thinking or a task notification.
413
436
  * @throws
414
437
  * - JG_AGENT_HQ_CLAUDE_HISTORY_UNAVAILABLE: The Claude history is unavailable
415
438
  */
416
- export const toClaudeItem = (record, turnId, fullBody = false) => {
417
- if (!record.uuid)
439
+ export const toClaudeItem = (native, turnId, fullBody = false) => {
440
+ if (!native.uuid)
418
441
  throw HQ_ERRORS.create('claudeHistoryUnavailable', {
419
442
  data: { kind: 'agent-unavailable' },
420
443
  });
444
+ const record = toMessageRecord(native);
421
445
  const presentation = toPresentation(record);
422
446
  if (!presentation)
423
447
  return null;
@@ -428,10 +452,10 @@ export const toClaudeItem = (record, turnId, fullBody = false) => {
428
452
  const createdAt = Date.parse(record.timestamp ?? '');
429
453
  return {
430
454
  ...presentation,
431
- nativeId: record.uuid,
455
+ nativeId: native.uuid,
432
456
  turnId,
433
457
  provenance: presentation.kind === 'user-message'
434
- ? nativeProvenance(presentation.kind, record.uuid, readInputText(record))
458
+ ? nativeProvenance(presentation.kind, readClaudeQueuedInput(native)?.inputId ?? native.uuid, readInputText(record))
435
459
  : nativeProvenance(presentation.kind),
436
460
  text: text.slice(0, end),
437
461
  isTruncated: end < text.length,
@@ -495,11 +519,12 @@ const toResultBody = (block) => Array.isArray(block.content)
495
519
  // a Bash call's command
496
520
  const toShellCommand = (input) => z.object({ command: z.string() }).safeParse(input).data?.command ?? null;
497
521
  /**
498
- * Lists the images a record holds, in its message and in its tool results' content, in order.
522
+ * Lists the images a record holds, in its message, a queued message included, and in its tool
523
+ * results' content, in order.
499
524
  * @param record The record.
500
525
  * @returns At most 64 images, each its base64 data, or null for one that has no base64 source.
501
526
  */
502
- export const toClaudeImageData = (record) => toBlocks(record)
527
+ export const toClaudeImageData = (record) => toBlocks(toMessageRecord(record))
503
528
  .flatMap((block) => block.type === 'tool_result' && Array.isArray(block.content)
504
529
  ? block.content.flatMap((part) => BlockSchema.safeParse(part).data ?? [])
505
530
  : [block])
@@ -532,12 +557,14 @@ export const isClaudeCallFor = (candidate, item) => item.nativeType === 'tool-re
532
557
  /**
533
558
  * Reads what a developer inspects in one record beyond its display text: a Bash command or `!`
534
559
  * shell input with its output, a tool call or result, an Edit or Write patch, and the images it
535
- * holds. A result takes its command or tool name from the call it answers.
536
- * @param record The item's record.
560
+ * holds. A result takes its command or tool name from the call it answers, and a queued message
561
+ * reads as the user message it is.
562
+ * @param native The item's record.
537
563
  * @param call The call it answers, or null when it answers none or the call isn't found.
538
564
  * @returns The detail's parts; the item itself comes from `toClaudeItem`.
539
565
  */
540
- export const toClaudeDetail = (record, call) => {
566
+ export const toClaudeDetail = (native, call) => {
567
+ const record = toMessageRecord(native);
541
568
  const detail = {
542
569
  command: null,
543
570
  tool: null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jg-agent-hq",
3
- "version": "13.1.4",
3
+ "version": "13.1.5",
4
4
  "description": "Native Claude Code and Codex session control, history, usage and recoverable local storage for Node.js apps.",
5
5
  "type": "module",
6
6
  "license": "MIT",