@karlorz/codexhost-cli-win32-x64 0.17.4-7 → 0.17.4-8

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.
@@ -15061,44 +15061,74 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15061
15061
  var THREAD_QUESTIONS_LIST_METHOD = "codexhost/thread/questions/list";
15062
15062
  var THREAD_QUESTION_RESPOND_METHOD = "codexhost/thread/question/respond";
15063
15063
  var THREAD_QUESTION_ACTIVITY_METHOD = "codexhost/thread/question/activity";
15064
- var threadQuestionsParamsSchema = external_exports.strictObject({ threadId: hostThreadIdSchema });
15064
+ var THREAD_QUESTION_RECORDS_LIST_METHOD = "codexhost/thread/question-records/list";
15065
+ var threadQuestionsParamsSchema = external_exports.strictObject({
15066
+ threadId: hostThreadIdSchema,
15067
+ unobserved: external_exports.literal(true).optional()
15068
+ });
15065
15069
  var field = { id: external_exports.string().min(1), prompt: external_exports.string(), optional: external_exports.boolean() };
15066
15070
  var questionAutoResolutionSchema = external_exports.strictObject({
15067
15071
  deadlineUnixMs: external_exports.number().int().min(0).max(864e13),
15068
15072
  action: external_exports.enum(["recommended", "decline"]),
15069
15073
  resetOnActivity: external_exports.boolean().optional()
15070
15074
  });
15075
+ var threadQuestionFieldSchema = external_exports.discriminatedUnion("type", [
15076
+ external_exports.strictObject({
15077
+ ...field,
15078
+ type: external_exports.literal("choice"),
15079
+ multiple: external_exports.boolean(),
15080
+ allowOther: external_exports.boolean(),
15081
+ options: external_exports.array(external_exports.strictObject({
15082
+ value: external_exports.string().min(1),
15083
+ label: external_exports.string(),
15084
+ description: external_exports.string().optional()
15085
+ })).min(1)
15086
+ }),
15087
+ external_exports.strictObject({
15088
+ ...field,
15089
+ type: external_exports.literal("text"),
15090
+ multiline: external_exports.boolean(),
15091
+ secret: external_exports.literal(false),
15092
+ placeholder: external_exports.string().optional(),
15093
+ prefill: external_exports.string().optional()
15094
+ })
15095
+ ]);
15071
15096
  var threadQuestionSchema = external_exports.strictObject({
15072
15097
  interactionId: hostInteractionIdSchema,
15073
15098
  turnId: hostTurnIdSchema,
15074
15099
  title: external_exports.string().optional(),
15075
15100
  expiresAt: external_exports.string().optional(),
15076
15101
  autoResolution: questionAutoResolutionSchema.optional(),
15077
- questions: external_exports.array(external_exports.discriminatedUnion("type", [
15078
- external_exports.strictObject({
15079
- ...field,
15080
- type: external_exports.literal("choice"),
15081
- multiple: external_exports.boolean(),
15082
- allowOther: external_exports.boolean(),
15083
- options: external_exports.array(external_exports.strictObject({
15084
- value: external_exports.string().min(1),
15085
- label: external_exports.string(),
15086
- description: external_exports.string().optional()
15087
- })).min(1)
15088
- }),
15089
- external_exports.strictObject({
15090
- ...field,
15091
- type: external_exports.literal("text"),
15092
- multiline: external_exports.boolean(),
15093
- secret: external_exports.literal(false),
15094
- placeholder: external_exports.string().optional(),
15095
- prefill: external_exports.string().optional()
15096
- })
15097
- ])).min(1)
15102
+ questions: external_exports.array(threadQuestionFieldSchema).min(1)
15098
15103
  });
15099
15104
  var threadQuestionsResultSchema = external_exports.strictObject({
15100
15105
  questions: external_exports.array(threadQuestionSchema)
15101
15106
  });
15107
+ var questionRecordOutcomeSchema = external_exports.enum([
15108
+ "answered",
15109
+ "skipped",
15110
+ "closedByHarness",
15111
+ "expired",
15112
+ "turnEnded"
15113
+ ]);
15114
+ var threadQuestionRecordSchema = external_exports.strictObject({
15115
+ interactionId: hostInteractionIdSchema,
15116
+ turnId: hostTurnIdSchema,
15117
+ itemId: hostItemIdSchema,
15118
+ title: external_exports.string().optional(),
15119
+ questions: external_exports.array(threadQuestionFieldSchema).min(1),
15120
+ outcome: questionRecordOutcomeSchema,
15121
+ answers: external_exports.record(external_exports.string(), external_exports.array(external_exports.string()))
15122
+ });
15123
+ var threadQuestionPendingAnchorSchema = external_exports.strictObject({
15124
+ interactionId: hostInteractionIdSchema,
15125
+ turnId: hostTurnIdSchema,
15126
+ itemId: hostItemIdSchema
15127
+ });
15128
+ var threadQuestionRecordsResultSchema = external_exports.strictObject({
15129
+ records: external_exports.array(threadQuestionRecordSchema),
15130
+ pendingAnchors: external_exports.array(threadQuestionPendingAnchorSchema)
15131
+ });
15102
15132
  var threadQuestionRespondParamsSchema = external_exports.strictObject({
15103
15133
  threadId: hostThreadIdSchema,
15104
15134
  interactionId: hostInteractionIdSchema,
@@ -20093,9 +20123,43 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
20093
20123
  }
20094
20124
  .title { display: flex; align-items: center; gap: 10px; flex-shrink: 0; margin: 0 6px 14px; color: var(--question-muted); font-weight: 400; }
20095
20125
  .question-icon { display: inline-flex; justify-content: center; align-items: center; width: 16px; height: 16px; flex-shrink: 0; }
20096
- .countdown { margin-left: auto; font-size: 12px; font-variant-numeric: tabular-nums; text-align: right; }
20126
+ .countdown, .outcome { margin-left: auto; font-size: 12px; font-variant-numeric: tabular-nums; text-align: right; }
20097
20127
  .countdown[hidden] { display: none; }
20098
20128
  .countdown:not([hidden]) + .dismiss { margin-left: 0; }
20129
+ .card.record .option { cursor: default; }
20130
+ .card.record :disabled { cursor: default; opacity: 1; }
20131
+ .card.record.compact { padding: 12px 12px 10px; }
20132
+ .card.record.compact .title { margin-bottom: 8px; }
20133
+ .card.record.compact fieldset { margin-bottom: 8px; }
20134
+ .card.record.compact legend { margin-bottom: 8px; }
20135
+ .answers { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 6px; }
20136
+ .answer {
20137
+ display: inline-flex;
20138
+ align-items: center;
20139
+ gap: 8px;
20140
+ max-width: 100%;
20141
+ padding: 4px 10px 4px 6px;
20142
+ border-radius: 999px;
20143
+ background: var(--question-selected);
20144
+ overflow-wrap: anywhere;
20145
+ }
20146
+ .answer-mark {
20147
+ display: inline-flex;
20148
+ align-items: center;
20149
+ justify-content: center;
20150
+ width: 18px;
20151
+ height: 18px;
20152
+ flex-shrink: 0;
20153
+ border-radius: 999px;
20154
+ background: var(--question-primary);
20155
+ color: var(--question-primary-text);
20156
+ font-size: 11px;
20157
+ font-weight: 600;
20158
+ font-variant-numeric: tabular-nums;
20159
+ line-height: 18px;
20160
+ }
20161
+ .answer-mark svg { width: 12px; height: 12px; stroke: currentColor; }
20162
+ .answer-label { min-width: 0; }
20099
20163
  svg { display: block; width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
20100
20164
  .body { min-height: 0; overflow: auto; }
20101
20165
  fieldset { min-width: 0; border: 0; padding: 0; margin: 0 0 14px; }
@@ -20193,7 +20257,56 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
20193
20257
  `;
20194
20258
 
20195
20259
  // src/renderer-question-card.ts
20196
- function createQuestionCard(document2, question, submit, initial = {}) {
20260
+ var RECORD_OUTCOME_LABEL = {
20261
+ answered: "Answered",
20262
+ skipped: "Skipped (you cancelled)",
20263
+ closedByHarness: "Closed by Harness",
20264
+ expired: "Expired",
20265
+ turnEnded: "Turn ended"
20266
+ };
20267
+ function answerChip(document2, label, markContent) {
20268
+ const chip = document2.createElement("div");
20269
+ chip.className = "answer";
20270
+ const mark = document2.createElement("span");
20271
+ mark.className = "answer-mark";
20272
+ mark.setAttribute("aria-hidden", "true");
20273
+ if (typeof markContent === "string") {
20274
+ mark.dataset.optionOrder = markContent;
20275
+ mark.textContent = markContent;
20276
+ } else {
20277
+ mark.append(markContent);
20278
+ }
20279
+ const text = document2.createElement("span");
20280
+ text.className = "answer-label";
20281
+ text.textContent = label;
20282
+ chip.append(mark, text);
20283
+ return chip;
20284
+ }
20285
+ function appendSelectedHistory(document2, body, question, answers, icon2) {
20286
+ for (const field2 of question.questions) {
20287
+ const group = document2.createElement("fieldset");
20288
+ const legend = document2.createElement("legend");
20289
+ legend.textContent = field2.prompt;
20290
+ group.append(legend);
20291
+ const saved = answers[field2.id] ?? [];
20292
+ const chips = document2.createElement("div");
20293
+ chips.className = "answers";
20294
+ if (field2.type === "text") {
20295
+ const text = saved[0]?.trim();
20296
+ if (text) chips.append(answerChip(document2, text, icon2(Check)));
20297
+ } else {
20298
+ for (const value of saved) {
20299
+ const optionIndex = field2.options.findIndex((item) => item.value === value);
20300
+ const option = optionIndex >= 0 ? field2.options[optionIndex] : void 0;
20301
+ const mark = optionIndex >= 0 ? String(optionIndex + 1) : icon2(Pencil);
20302
+ chips.append(answerChip(document2, option?.label ?? value, mark));
20303
+ }
20304
+ }
20305
+ if (chips.childNodes.length > 0) group.append(chips);
20306
+ body.append(group);
20307
+ }
20308
+ }
20309
+ function createQuestionCard(document2, question, submit, initial = {}, record21) {
20197
20310
  const icon2 = (node) => document2.adoptNode(
20198
20311
  createElement(node, {
20199
20312
  width: 16,
@@ -20210,7 +20323,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
20210
20323
  return selected;
20211
20324
  };
20212
20325
  const root = document2.createElement("section");
20213
- root.dataset.codexhostQuestion = question.interactionId;
20326
+ if (record21) {
20327
+ root.dataset.codexhostQuestionRecord = question.interactionId;
20328
+ root.dataset.outcome = record21.outcome;
20329
+ } else {
20330
+ root.dataset.codexhostQuestion = question.interactionId;
20331
+ }
20214
20332
  root.setAttribute("aria-label", question.title ?? "Question");
20215
20333
  root.addEventListener("keydown", (event) => {
20216
20334
  event.stopPropagation();
@@ -20222,6 +20340,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
20222
20340
  style.textContent = QUESTION_CARD_CSS;
20223
20341
  const surface = document2.createElement("div");
20224
20342
  surface.className = "card";
20343
+ const historyMode = record21?.history ?? (record21 ? "selected" : void 0);
20344
+ if (record21) {
20345
+ root.dataset.history = historyMode ?? "selected";
20346
+ surface.classList.add("record");
20347
+ if (historyMode === "selected") surface.classList.add("compact");
20348
+ }
20225
20349
  shadow.append(style, surface);
20226
20350
  const title = document2.createElement("div");
20227
20351
  title.className = "title";
@@ -20253,7 +20377,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
20253
20377
  dismiss.className = "dismiss";
20254
20378
  dismiss.append(icon2(X));
20255
20379
  dismiss.setAttribute("aria-label", "Dismiss question");
20256
- title.append(titleIcon, titleText, countdown, dismiss);
20380
+ const outcome = document2.createElement("span");
20381
+ outcome.className = "outcome";
20382
+ if (record21) {
20383
+ outcome.textContent = RECORD_OUTCOME_LABEL[record21.outcome];
20384
+ title.append(titleIcon, titleText, outcome);
20385
+ } else {
20386
+ title.append(titleIcon, titleText, countdown, dismiss);
20387
+ }
20257
20388
  const body = document2.createElement("div");
20258
20389
  body.className = "body";
20259
20390
  surface.append(title, body);
@@ -20262,99 +20393,107 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
20262
20393
  const readers = /* @__PURE__ */ new Map();
20263
20394
  const controls = [dismiss];
20264
20395
  const validOther = [];
20265
- for (const [index, field2] of question.questions.entries()) {
20266
- const group = document2.createElement("fieldset");
20267
- const legend = document2.createElement("legend");
20268
- legend.textContent = field2.prompt;
20269
- group.append(legend);
20270
- const saved = initial[field2.id] ?? [];
20271
- if (field2.type === "text") {
20272
- const input = document2.createElement(field2.multiline ? "textarea" : "input");
20273
- input.value = saved[0] ?? field2.prefill ?? "";
20274
- input.placeholder = field2.placeholder ?? "Your answer";
20275
- input.setAttribute("aria-label", field2.prompt);
20276
- controls.push(input);
20277
- group.append(input);
20278
- readers.set(field2.id, () => input.value.trim() ? [input.value] : []);
20279
- } else {
20280
- const hint = document2.createElement("div");
20281
- hint.className = "hint";
20282
- hint.textContent = "Select all that apply";
20283
- if (field2.multiple) group.append(hint);
20284
- const inputs = [];
20285
- const name = `codexhost-${question.interactionId}-${index}`;
20286
- for (const [optionIndex, option] of field2.options.entries()) {
20287
- const label = document2.createElement("label");
20288
- label.className = "option";
20289
- const input = document2.createElement("input");
20290
- input.type = field2.multiple ? "checkbox" : "radio";
20291
- input.name = name;
20292
- input.value = option.value;
20293
- input.checked = saved.includes(option.value);
20294
- const shortcut = document2.createElement("span");
20295
- shortcut.className = "shortcut";
20296
- shortcut.setAttribute("aria-hidden", "true");
20297
- shortcut.textContent = String(optionIndex + 1);
20298
- const selected = selectedIndicator();
20299
- const text = document2.createElement("span");
20300
- text.className = "option-copy";
20301
- const optionName = document2.createElement("span");
20302
- optionName.className = "option-name";
20303
- optionName.textContent = option.label;
20304
- text.append(optionName);
20305
- if (option.description) {
20306
- const description = document2.createElement("span");
20307
- description.className = "description";
20308
- description.textContent = option.description;
20309
- text.append(description);
20310
- }
20311
- label.append(input, shortcut, text, selected);
20312
- group.append(label);
20313
- inputs.push(input);
20396
+ const compactHistory = historyMode === "selected";
20397
+ if (compactHistory) {
20398
+ appendSelectedHistory(document2, body, question, initial, icon2);
20399
+ for (const field2 of question.questions) {
20400
+ readers.set(field2.id, () => initial[field2.id] ?? []);
20401
+ }
20402
+ } else {
20403
+ for (const [index, field2] of question.questions.entries()) {
20404
+ const group = document2.createElement("fieldset");
20405
+ const legend = document2.createElement("legend");
20406
+ legend.textContent = field2.prompt;
20407
+ group.append(legend);
20408
+ const saved = initial[field2.id] ?? [];
20409
+ if (field2.type === "text") {
20410
+ const input = document2.createElement(field2.multiline ? "textarea" : "input");
20411
+ input.value = saved[0] ?? field2.prefill ?? "";
20412
+ input.placeholder = field2.placeholder ?? "Your answer";
20413
+ input.setAttribute("aria-label", field2.prompt);
20314
20414
  controls.push(input);
20415
+ group.append(input);
20416
+ readers.set(field2.id, () => input.value.trim() ? [input.value] : []);
20417
+ } else {
20418
+ const hint = document2.createElement("div");
20419
+ hint.className = "hint";
20420
+ hint.textContent = "Select all that apply";
20421
+ if (field2.multiple) group.append(hint);
20422
+ const inputs = [];
20423
+ const name = `codexhost-${question.interactionId}-${index}`;
20424
+ for (const [optionIndex, option] of field2.options.entries()) {
20425
+ const label = document2.createElement("label");
20426
+ label.className = "option";
20427
+ const input = document2.createElement("input");
20428
+ input.type = field2.multiple ? "checkbox" : "radio";
20429
+ input.name = name;
20430
+ input.value = option.value;
20431
+ input.checked = saved.includes(option.value);
20432
+ const shortcut = document2.createElement("span");
20433
+ shortcut.className = "shortcut";
20434
+ shortcut.setAttribute("aria-hidden", "true");
20435
+ shortcut.textContent = String(optionIndex + 1);
20436
+ const selected = selectedIndicator();
20437
+ const text = document2.createElement("span");
20438
+ text.className = "option-copy";
20439
+ const optionName = document2.createElement("span");
20440
+ optionName.className = "option-name";
20441
+ optionName.textContent = option.label;
20442
+ text.append(optionName);
20443
+ if (option.description) {
20444
+ const description = document2.createElement("span");
20445
+ description.className = "description";
20446
+ description.textContent = option.description;
20447
+ text.append(description);
20448
+ }
20449
+ label.append(input, shortcut, text, selected);
20450
+ group.append(label);
20451
+ inputs.push(input);
20452
+ controls.push(input);
20453
+ }
20454
+ let other;
20455
+ let notes;
20456
+ if (field2.allowOther) {
20457
+ const label = document2.createElement("label");
20458
+ label.className = "option other";
20459
+ other = document2.createElement("input");
20460
+ other.type = field2.multiple ? "checkbox" : "radio";
20461
+ other.name = name;
20462
+ other.setAttribute("aria-label", `Other: ${field2.prompt}`);
20463
+ const unknown2 = saved.find(
20464
+ (value) => !field2.options.some((option) => option.value === value)
20465
+ );
20466
+ other.checked = unknown2 !== void 0;
20467
+ notes = document2.createElement("input");
20468
+ notes.value = unknown2 ?? "";
20469
+ notes.placeholder = "Or write your own response";
20470
+ notes.setAttribute("aria-label", `${field2.prompt}: Other`);
20471
+ const checkbox = other;
20472
+ const otherText = notes;
20473
+ validOther.push(() => !checkbox.checked || otherText.value.trim().length > 0);
20474
+ notes.addEventListener("input", () => {
20475
+ checkbox.checked = true;
20476
+ });
20477
+ const copy = document2.createElement("span");
20478
+ copy.className = "other-copy";
20479
+ copy.append(notes);
20480
+ const pencil = document2.createElement("span");
20481
+ pencil.className = "shortcut pencil";
20482
+ pencil.append(icon2(Pencil));
20483
+ pencil.setAttribute("aria-hidden", "true");
20484
+ const selected = selectedIndicator();
20485
+ label.append(other, pencil, copy, selected);
20486
+ if (question.questions.length === 1) footer.append(label);
20487
+ else group.append(label);
20488
+ controls.push(other, notes);
20489
+ }
20490
+ readers.set(field2.id, () => [
20491
+ ...inputs.filter((input) => input.checked).map((input) => input.value),
20492
+ ...other?.checked && notes?.value.trim() ? [notes.value] : []
20493
+ ]);
20315
20494
  }
20316
- let other;
20317
- let notes;
20318
- if (field2.allowOther) {
20319
- const label = document2.createElement("label");
20320
- label.className = "option other";
20321
- other = document2.createElement("input");
20322
- other.type = field2.multiple ? "checkbox" : "radio";
20323
- other.name = name;
20324
- other.setAttribute("aria-label", `Other: ${field2.prompt}`);
20325
- const unknown2 = saved.find(
20326
- (value) => !field2.options.some((option) => option.value === value)
20327
- );
20328
- other.checked = unknown2 !== void 0;
20329
- notes = document2.createElement("input");
20330
- notes.value = unknown2 ?? "";
20331
- notes.placeholder = "Or write your own response";
20332
- notes.setAttribute("aria-label", `${field2.prompt}: Other`);
20333
- const checkbox = other;
20334
- const otherText = notes;
20335
- validOther.push(() => !checkbox.checked || otherText.value.trim().length > 0);
20336
- notes.addEventListener("input", () => {
20337
- checkbox.checked = true;
20338
- });
20339
- const copy = document2.createElement("span");
20340
- copy.className = "other-copy";
20341
- copy.append(notes);
20342
- const pencil = document2.createElement("span");
20343
- pencil.className = "shortcut pencil";
20344
- pencil.append(icon2(Pencil));
20345
- pencil.setAttribute("aria-hidden", "true");
20346
- const selected = selectedIndicator();
20347
- label.append(other, pencil, copy, selected);
20348
- if (question.questions.length === 1) footer.append(label);
20349
- else group.append(label);
20350
- controls.push(other, notes);
20351
- }
20352
- readers.set(field2.id, () => [
20353
- ...inputs.filter((input) => input.checked).map((input) => input.value),
20354
- ...other?.checked && notes?.value.trim() ? [notes.value] : []
20355
- ]);
20495
+ body.append(group);
20356
20496
  }
20357
- body.append(group);
20358
20497
  }
20359
20498
  const error51 = document2.createElement("div");
20360
20499
  error51.setAttribute("role", "alert");
@@ -20362,6 +20501,24 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
20362
20501
  const actions = document2.createElement("div");
20363
20502
  actions.className = "actions";
20364
20503
  const readAnswers = () => Object.fromEntries([...readers].map(([id, read]) => [id, read()]));
20504
+ if (record21) {
20505
+ for (const control of controls) control.disabled = true;
20506
+ if (footer.childNodes.length > 0) surface.append(footer);
20507
+ return {
20508
+ root,
20509
+ readAnswers,
20510
+ historyMode,
20511
+ get autoResolution() {
20512
+ return autoResolution;
20513
+ },
20514
+ updateAutoResolution() {
20515
+ },
20516
+ dispose() {
20517
+ if (countdownTimer !== void 0) document2.defaultView?.clearInterval(countdownTimer);
20518
+ root.remove();
20519
+ }
20520
+ };
20521
+ }
20365
20522
  let busy = false;
20366
20523
  const send = async (cancelled) => {
20367
20524
  if (busy) return;
@@ -20408,6 +20565,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
20408
20565
  return {
20409
20566
  root,
20410
20567
  readAnswers,
20568
+ historyMode,
20411
20569
  get autoResolution() {
20412
20570
  return autoResolution;
20413
20571
  },
@@ -20482,20 +20640,592 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
20482
20640
  };
20483
20641
  }
20484
20642
 
20643
+ // src/renderer-transcript-dom.ts
20644
+ var TRANSCRIPT_ITEM_SELECTOR = "[data-local-conversation-item-target-ids]";
20645
+ var TRANSCRIPT_ITEM_IDS_ATTRIBUTE = "data-local-conversation-item-target-ids";
20646
+ var TRANSCRIPT_TURN_KEY_ATTRIBUTE = "data-content-search-turn-key";
20647
+ var TRANSCRIPT_TEXT_BODY_SELECTOR = '[data-testid="exec-shell-body"]';
20648
+ var REASONING_SOFT_WRAP_STORAGE_KEY = "codexhost.reasoning-soft-wrap.v1";
20649
+ var REASONING_SOFT_WRAP_CHANGE_EVENT = "codexhost:reasoning-soft-wrap-changed";
20650
+ function readReasoningTranscriptSoftWrap(ownerWindow) {
20651
+ return ownerWindow.localStorage.getItem(REASONING_SOFT_WRAP_STORAGE_KEY) === "true";
20652
+ }
20653
+ function setReasoningTranscriptSoftWrap(ownerWindow, enabled) {
20654
+ ownerWindow.localStorage.setItem(REASONING_SOFT_WRAP_STORAGE_KEY, String(enabled));
20655
+ ownerWindow.dispatchEvent(new Event(REASONING_SOFT_WRAP_CHANGE_EVENT));
20656
+ }
20657
+ function installReasoningTranscriptSoftWrap(ownerDocument) {
20658
+ const ownerWindow = ownerDocument.defaultView;
20659
+ if (!ownerWindow) return () => {
20660
+ };
20661
+ const style = ownerDocument.createElement("style");
20662
+ style.setAttribute("data-codexhost-reasoning-soft-wrap", "true");
20663
+ const body = `${TRANSCRIPT_TEXT_BODY_SELECTOR}:has([aria-label="$ ${REASONING_TRANSCRIPT_COMMAND}"])`;
20664
+ style.textContent = `
20665
+ ${body} .whitespace-pre {
20666
+ white-space: pre-wrap;
20667
+ overflow-wrap: anywhere;
20668
+ }
20669
+ ${body} .whitespace-pre > .w-max {
20670
+ width: 100%;
20671
+ min-width: 0;
20672
+ }
20673
+ `;
20674
+ ownerDocument.head.append(style);
20675
+ const refresh = () => {
20676
+ style.disabled = !readReasoningTranscriptSoftWrap(ownerWindow);
20677
+ };
20678
+ const onStorage = (event) => {
20679
+ if (event.key === REASONING_SOFT_WRAP_STORAGE_KEY || event.key === null) refresh();
20680
+ };
20681
+ refresh();
20682
+ ownerWindow.addEventListener(REASONING_SOFT_WRAP_CHANGE_EVENT, refresh);
20683
+ ownerWindow.addEventListener("storage", onStorage);
20684
+ return () => {
20685
+ ownerWindow.removeEventListener(REASONING_SOFT_WRAP_CHANGE_EVENT, refresh);
20686
+ ownerWindow.removeEventListener("storage", onStorage);
20687
+ style.remove();
20688
+ };
20689
+ }
20690
+
20691
+ // src/renderer-question-anchors.ts
20692
+ var QUESTION_HISTORY_SLOT_ATTRIBUTE = "data-codexhost-question-history";
20693
+ function elementIsDisplayed(node) {
20694
+ const rect = node.getBoundingClientRect();
20695
+ return rect.width > 0 && rect.height > 0;
20696
+ }
20697
+ function elementIsShown(node) {
20698
+ let current = node;
20699
+ while (current) {
20700
+ if (!elementIsDisplayed(current)) return false;
20701
+ current = current.parentElement;
20702
+ }
20703
+ return true;
20704
+ }
20705
+ function itemIds(node) {
20706
+ return (node.getAttribute(TRANSCRIPT_ITEM_IDS_ATTRIBUTE) ?? "").split(/\s+/).filter((entry) => entry.length > 0);
20707
+ }
20708
+ function findTranscriptItem(root, itemId) {
20709
+ for (const node of root.querySelectorAll(TRANSCRIPT_ITEM_SELECTOR)) {
20710
+ if (itemIds(node).includes(itemId)) return node;
20711
+ }
20712
+ return null;
20713
+ }
20714
+ function findDisplayedTranscriptItem(root, itemId) {
20715
+ const row = findTranscriptItem(root, itemId);
20716
+ return row && elementIsDisplayed(row) ? row : null;
20717
+ }
20718
+ function findTranscriptTurn(root, turnId) {
20719
+ for (const node of root.querySelectorAll(`[${TRANSCRIPT_TURN_KEY_ATTRIBUTE}]`)) {
20720
+ if (node.getAttribute(TRANSCRIPT_TURN_KEY_ATTRIBUTE) === turnId) return node;
20721
+ }
20722
+ return null;
20723
+ }
20724
+ function nonemptyText(node) {
20725
+ return (node.textContent ?? "").trim().length > 0;
20726
+ }
20727
+ function isFoldControl(node) {
20728
+ return node.getAttribute("aria-expanded") !== null;
20729
+ }
20730
+ function firstDisplayedChildAwayFrom(container, hiddenRow) {
20731
+ for (const child of container.children) {
20732
+ if (!elementIsDisplayed(child) || !nonemptyText(child) || isFoldControl(child)) continue;
20733
+ if (child === hiddenRow || child.contains(hiddenRow)) continue;
20734
+ return child;
20735
+ }
20736
+ return null;
20737
+ }
20738
+ function nextDisplayedSibling(parent, node, hiddenRow) {
20739
+ let passed = false;
20740
+ for (const child of parent.children) {
20741
+ if (child === node) {
20742
+ passed = true;
20743
+ continue;
20744
+ }
20745
+ if (!passed) continue;
20746
+ if (!elementIsDisplayed(child) || !nonemptyText(child) || isFoldControl(child)) continue;
20747
+ if (hiddenRow && (child === hiddenRow || child.contains(hiddenRow))) {
20748
+ const nested = firstDisplayedChildAwayFrom(child, hiddenRow);
20749
+ if (nested) return nested;
20750
+ continue;
20751
+ }
20752
+ return child;
20753
+ }
20754
+ return null;
20755
+ }
20756
+ function walkForward(start, turn, hiddenRow) {
20757
+ let node = start;
20758
+ while (node && node !== turn && node.parentElement) {
20759
+ const parent = node.parentElement;
20760
+ const found = nextDisplayedSibling(parent, node, hiddenRow);
20761
+ if (found) return found;
20762
+ node = parent;
20763
+ }
20764
+ return null;
20765
+ }
20766
+ function isTurnProgressControl(node) {
20767
+ if (node.getAttribute("aria-expanded") !== null) return true;
20768
+ const text = (node.textContent ?? "").trim();
20769
+ return /^(Working for|Worked for|Thinking)\b/i.test(text);
20770
+ }
20771
+ function findWorkingColumn(turn) {
20772
+ for (const control of turn.querySelectorAll("button")) {
20773
+ if (!elementIsDisplayed(control) || !isTurnProgressControl(control)) continue;
20774
+ let node = control;
20775
+ while (node.parentElement && node.parentElement !== turn) {
20776
+ const parent = node.parentElement;
20777
+ let hasEarlier = false;
20778
+ for (const child of parent.children) {
20779
+ if (child === node) break;
20780
+ if (elementIsDisplayed(child) && nonemptyText(child) && !isFoldControl(child)) {
20781
+ hasEarlier = true;
20782
+ break;
20783
+ }
20784
+ }
20785
+ if (hasEarlier && elementIsDisplayed(node)) return node;
20786
+ node = parent;
20787
+ }
20788
+ if (elementIsDisplayed(node)) return node;
20789
+ }
20790
+ return elementIsDisplayed(turn) ? turn : null;
20791
+ }
20792
+ function findVisibleReplyColumn(turn, hiddenRow) {
20793
+ if (hiddenRow) {
20794
+ const beside = walkForward(hiddenRow, turn, hiddenRow);
20795
+ if (beside) return beside;
20796
+ }
20797
+ for (const fold of turn.querySelectorAll("button[aria-expanded]")) {
20798
+ if (!elementIsDisplayed(fold)) continue;
20799
+ const found = walkForward(fold, turn, hiddenRow);
20800
+ if (found) return found;
20801
+ }
20802
+ const items = [...turn.querySelectorAll(TRANSCRIPT_ITEM_SELECTOR)].filter(
20803
+ (el) => el !== hiddenRow && elementIsDisplayed(el)
20804
+ );
20805
+ return items.at(-1) ?? null;
20806
+ }
20807
+ function findVisibleHistoryMount(root, itemId, turnId) {
20808
+ const row = findTranscriptItem(root, itemId);
20809
+ const turn = findTranscriptTurn(root, turnId) ?? row?.closest(`[${TRANSCRIPT_TURN_KEY_ATTRIBUTE}]`);
20810
+ const reply = turn ? findVisibleReplyColumn(turn, row) : null;
20811
+ if (reply) return reply;
20812
+ if (row && elementIsDisplayed(row)) return row;
20813
+ return turn ? findWorkingColumn(turn) : null;
20814
+ }
20815
+ function findLiveQuestionMount(root, itemId, turnId) {
20816
+ const displayed = findDisplayedTranscriptItem(root, itemId);
20817
+ if (displayed) return displayed;
20818
+ const row = findTranscriptItem(root, itemId);
20819
+ if (!row?.closest(`[${TRANSCRIPT_TURN_KEY_ATTRIBUTE}]`)) return null;
20820
+ return findVisibleHistoryMount(root, itemId, turnId);
20821
+ }
20822
+ function isFlexRow(node) {
20823
+ const style = getComputedStyle(node);
20824
+ return (style.display === "flex" || style.display === "inline-flex") && (style.flexDirection === "row" || style.flexDirection === "row-reverse");
20825
+ }
20826
+ function childrenLaidOutInRow(parent) {
20827
+ const rects = [...parent.children].map((child) => child.getBoundingClientRect()).filter((rect) => rect.width > 0 && rect.height > 0);
20828
+ for (let i = 0; i < rects.length; i++) {
20829
+ for (let j = i + 1; j < rects.length; j++) {
20830
+ const a = rects[i];
20831
+ const b = rects[j];
20832
+ if (!a || !b) continue;
20833
+ const separateX = a.right <= b.left + 1 || b.right <= a.left + 1;
20834
+ const overlapY = a.top < b.bottom - 4 && b.top < a.bottom - 4;
20835
+ if (separateX && overlapY) return true;
20836
+ }
20837
+ }
20838
+ return false;
20839
+ }
20840
+ function containingBlockWidth(mount) {
20841
+ let node = mount.parentElement;
20842
+ while (node) {
20843
+ const width = node.getBoundingClientRect().width;
20844
+ if (width > 0 && getComputedStyle(node).display !== "contents") return width;
20845
+ node = node.parentElement;
20846
+ }
20847
+ return 0;
20848
+ }
20849
+ function isHorizontalLayout(node) {
20850
+ const style = getComputedStyle(node);
20851
+ if (style.display === "contents") return false;
20852
+ return isFlexRow(node) || childrenLaidOutInRow(node);
20853
+ }
20854
+ function questionHistorySlotCeiling(mount) {
20855
+ return mount.closest(`[${TRANSCRIPT_TURN_KEY_ATTRIBUTE}]`) ?? mount.closest(TRANSCRIPT_ITEM_SELECTOR) ?? mount;
20856
+ }
20857
+ function insertBeforeSafe(parent, node, before) {
20858
+ try {
20859
+ if (before && before.parentNode === parent) parent.insertBefore(node, before);
20860
+ else parent.append(node);
20861
+ } catch {
20862
+ try {
20863
+ parent.append(node);
20864
+ } catch {
20865
+ return;
20866
+ }
20867
+ }
20868
+ }
20869
+ function rowStackInsert(mount) {
20870
+ const ceiling = questionHistorySlotCeiling(mount);
20871
+ if (mount === ceiling) return null;
20872
+ const full = containingBlockWidth(mount);
20873
+ const mountWidth = mount.getBoundingClientRect().width;
20874
+ const parent = mount.parentElement;
20875
+ if (!parent || !ceiling.contains(parent)) return null;
20876
+ const needsLift = isFlexRow(mount) || Boolean(isHorizontalLayout(parent)) || full > 0 && mountWidth < full * 0.7;
20877
+ if (!needsLift) return null;
20878
+ let before = mount;
20879
+ let host = parent;
20880
+ while (host && ceiling.contains(host)) {
20881
+ if (host === ceiling) return { parent: host, before };
20882
+ const style = getComputedStyle(host);
20883
+ const contents = style.display === "contents";
20884
+ const row = !contents && isHorizontalLayout(host);
20885
+ const width = host.getBoundingClientRect().width;
20886
+ if (!contents && !row && width >= full * 0.9) return { parent: host, before };
20887
+ before = host;
20888
+ host = host.parentElement;
20889
+ }
20890
+ return null;
20891
+ }
20892
+ function applyHistorySlotLayout(slot2) {
20893
+ slot2.style.display = "block";
20894
+ slot2.style.width = "100%";
20895
+ slot2.style.minWidth = "0";
20896
+ slot2.style.flex = "none";
20897
+ slot2.style.alignSelf = "stretch";
20898
+ }
20899
+ function ensureQuestionHistorySlot(document2, mount) {
20900
+ const insert = rowStackInsert(mount);
20901
+ const host = insert?.parent ?? mount;
20902
+ for (const child of host.children) {
20903
+ if (!child.hasAttribute(QUESTION_HISTORY_SLOT_ATTRIBUTE)) continue;
20904
+ applyHistorySlotLayout(child);
20905
+ return child;
20906
+ }
20907
+ const ceiling = questionHistorySlotCeiling(mount);
20908
+ const parked = ceiling.querySelector(`[${QUESTION_HISTORY_SLOT_ATTRIBUTE}]`);
20909
+ if (parked) {
20910
+ if (parked.parentElement !== host && !elementIsShown(parked)) {
20911
+ if (insert) insertBeforeSafe(insert.parent, parked, insert.before);
20912
+ else host.prepend(parked);
20913
+ }
20914
+ applyHistorySlotLayout(parked);
20915
+ return parked;
20916
+ }
20917
+ const slot2 = document2.createElement("div");
20918
+ slot2.setAttribute(QUESTION_HISTORY_SLOT_ATTRIBUTE, "");
20919
+ applyHistorySlotLayout(slot2);
20920
+ if (insert) insertBeforeSafe(insert.parent, slot2, insert.before);
20921
+ else mount.prepend(slot2);
20922
+ return slot2;
20923
+ }
20924
+
20925
+ // src/renderer-question-jump.ts
20926
+ var SIDEBAR_THREAD_ROW_SELECTOR = "[data-app-action-sidebar-thread-row]";
20927
+ var SIDEBAR_THREAD_ID_ATTRIBUTE = "data-app-action-sidebar-thread-id";
20928
+ var NATIVE_MESSAGE_JUMP = /^Jump to user message (\d+)$/;
20929
+ var JUMP_WAIT_MS = 2e3;
20930
+ var jumpWait;
20931
+ function sidebarRowForThread(root, hostId2, threadId) {
20932
+ for (const node of root.querySelectorAll(SIDEBAR_THREAD_ROW_SELECTOR)) {
20933
+ if (!(node instanceof HTMLElement)) continue;
20934
+ const raw = node.getAttribute(SIDEBAR_THREAD_ID_ATTRIBUTE) ?? "";
20935
+ if (raw === threadId || raw === `${hostId2}:${threadId}` || raw.endsWith(`:${threadId}`)) {
20936
+ return node;
20937
+ }
20938
+ }
20939
+ return null;
20940
+ }
20941
+ function threadTitleHint(row, fallback) {
20942
+ return (row?.textContent ?? "").replace(/\s+/g, " ").trim() || fallback.trim();
20943
+ }
20944
+ function tabLabel(tab) {
20945
+ return (tab.getAttribute("aria-label") ?? tab.textContent ?? "").replace(/\s+/g, " ").trim();
20946
+ }
20947
+ function titleMatchesTab(titleHint, label) {
20948
+ return label.length > 0 && (titleHint === label || titleHint.endsWith(label) || titleHint.includes(label));
20949
+ }
20950
+ function selectOwningChatTab(root, titleHint) {
20951
+ if (!titleHint) return;
20952
+ for (const tab of root.querySelectorAll('[role="tab"]')) {
20953
+ if (!(tab instanceof HTMLElement)) continue;
20954
+ const label = tabLabel(tab);
20955
+ if (!titleMatchesTab(titleHint, label)) continue;
20956
+ if (tab.getAttribute("aria-selected") !== "true") tab.click();
20957
+ return;
20958
+ }
20959
+ }
20960
+ function clickThreadTitleControl(root, titleHint) {
20961
+ if (!titleHint) return;
20962
+ for (const node of root.querySelectorAll("button, a")) {
20963
+ if (!(node instanceof HTMLElement) || !elementIsDisplayed(node)) continue;
20964
+ if (node.getAttribute("role") === "tab") continue;
20965
+ if (node.closest(SIDEBAR_THREAD_ROW_SELECTOR)) continue;
20966
+ if (node.dataset.codexhostQuestionJump !== void 0) continue;
20967
+ const label = tabLabel(node);
20968
+ if (!titleMatchesTab(titleHint, label)) continue;
20969
+ node.click();
20970
+ return;
20971
+ }
20972
+ }
20973
+ function clickLatestNativeMessageJump(root) {
20974
+ let best;
20975
+ for (const node of root.querySelectorAll("button")) {
20976
+ if (!(node instanceof HTMLElement) || !elementIsDisplayed(node)) continue;
20977
+ const match = NATIVE_MESSAGE_JUMP.exec(node.getAttribute("aria-label") ?? "");
20978
+ if (!match) continue;
20979
+ const n = Number(match[1]);
20980
+ if (!best || n > best.n) best = { button: node, n };
20981
+ }
20982
+ best?.button.click();
20983
+ }
20984
+ function revealOwningConversation(document2, hostId2, threadId) {
20985
+ const row = sidebarRowForThread(document2, hostId2, threadId);
20986
+ const hint = threadTitleHint(row, document2.title);
20987
+ selectOwningChatTab(document2, hint);
20988
+ clickThreadTitleControl(document2, hint);
20989
+ row?.click();
20990
+ clickLatestNativeMessageJump(document2);
20991
+ }
20992
+ function waitForDisplayedRow(document2, itemId, timeoutMs) {
20993
+ jumpWait?.cancel();
20994
+ jumpWait = void 0;
20995
+ if (findDisplayedTranscriptItem(document2, itemId)) return Promise.resolve(true);
20996
+ const ownerWindow = document2.defaultView;
20997
+ if (!ownerWindow) return Promise.resolve(false);
20998
+ return new Promise((resolve) => {
20999
+ let settled2 = false;
21000
+ let frame = 0;
21001
+ const finish = (ok) => {
21002
+ if (settled2) return;
21003
+ settled2 = true;
21004
+ jumpWait = void 0;
21005
+ ownerWindow.cancelAnimationFrame(frame);
21006
+ ownerWindow.clearTimeout(timer);
21007
+ resolve(ok);
21008
+ };
21009
+ const tick = () => {
21010
+ if (settled2) return;
21011
+ if (findDisplayedTranscriptItem(document2, itemId)) {
21012
+ finish(true);
21013
+ return;
21014
+ }
21015
+ frame = ownerWindow.requestAnimationFrame(tick);
21016
+ };
21017
+ frame = ownerWindow.requestAnimationFrame(tick);
21018
+ const timer = ownerWindow.setTimeout(() => finish(false), timeoutMs);
21019
+ jumpWait = { cancel: () => finish(false) };
21020
+ });
21021
+ }
21022
+ async function jumpRevealsQuestionRow(document2, hostId2, threadId, itemId) {
21023
+ revealOwningConversation(document2, hostId2, threadId);
21024
+ if (!itemId) return false;
21025
+ findTranscriptItem(document2, itemId)?.scrollIntoView({ block: "nearest", inline: "nearest" });
21026
+ return waitForDisplayedRow(document2, itemId, JUMP_WAIT_MS);
21027
+ }
21028
+
21029
+ // src/renderer-question-history-preference.ts
21030
+ var HARNESS_QUESTION_HISTORY_STORAGE_KEY = "codexhost.harness-question-history.v1";
21031
+ var HARNESS_QUESTION_HISTORY_CHANGE_EVENT = "codexhost:harness-question-history-changed";
21032
+ function readHarnessQuestionHistory(owner) {
21033
+ if (!owner) return "selected";
21034
+ try {
21035
+ return owner.localStorage.getItem(HARNESS_QUESTION_HISTORY_STORAGE_KEY) === "all" ? "all" : "selected";
21036
+ } catch {
21037
+ return "selected";
21038
+ }
21039
+ }
21040
+ function writeHarnessQuestionHistory(owner, selectedOnly) {
21041
+ try {
21042
+ owner.localStorage.setItem(
21043
+ HARNESS_QUESTION_HISTORY_STORAGE_KEY,
21044
+ selectedOnly ? "selected" : "all"
21045
+ );
21046
+ } catch {
21047
+ return false;
21048
+ }
21049
+ owner.dispatchEvent(new Event(HARNESS_QUESTION_HISTORY_CHANGE_EVENT));
21050
+ return true;
21051
+ }
21052
+
21053
+ // src/renderer-question-placement-preference.ts
21054
+ var HARNESS_QUESTION_PLACEMENT_STORAGE_KEY = "codexhost.harness-question-placement.v1";
21055
+ var HARNESS_QUESTION_PLACEMENT_CHANGE_EVENT = "codexhost:harness-question-placement-changed";
21056
+ function readHarnessQuestionPlacement(owner) {
21057
+ if (!owner) return "in-chat";
21058
+ try {
21059
+ return owner.localStorage.getItem(HARNESS_QUESTION_PLACEMENT_STORAGE_KEY) === "overlay" ? "overlay" : "in-chat";
21060
+ } catch {
21061
+ return "in-chat";
21062
+ }
21063
+ }
21064
+ function writeHarnessQuestionPlacement(owner, inChat) {
21065
+ try {
21066
+ owner.localStorage.setItem(
21067
+ HARNESS_QUESTION_PLACEMENT_STORAGE_KEY,
21068
+ inChat ? "in-chat" : "overlay"
21069
+ );
21070
+ } catch {
21071
+ return false;
21072
+ }
21073
+ owner.dispatchEvent(new Event(HARNESS_QUESTION_PLACEMENT_CHANGE_EVENT));
21074
+ return true;
21075
+ }
21076
+
21077
+ // src/renderer-composer-request.ts
21078
+ var NATIVE_COMPOSER_REQUEST_ATTRIBUTES = [
21079
+ "data-codex-composer-request-navigation",
21080
+ "data-codex-composer-request"
21081
+ ];
21082
+ var NATIVE_REQUEST_SELECTOR = NATIVE_COMPOSER_REQUEST_ATTRIBUTES.map(
21083
+ (attribute) => `[${attribute}]`
21084
+ ).join(", ");
21085
+ var COMPOSER_ROOT_SELECTOR = "[data-codex-composer-root]";
21086
+ var SHARED_QUESTION_NATIVE_COVER_ATTRIBUTE = "data-codexhost-shared-question-cover";
21087
+ var COVER_STYLE_ID = "codexhost-shared-question-cover-style";
21088
+ var COVER_CSS = `[${SHARED_QUESTION_NATIVE_COVER_ATTRIBUTE}]{position:absolute!important;width:1px!important;height:1px!important;padding:0!important;margin:-1px!important;overflow:hidden!important;clip:rect(0,0,0,0)!important;clip-path:inset(50%)!important;white-space:nowrap!important;border:0!important;opacity:0!important;pointer-events:none!important}`;
21089
+ function isNativeComposerRequest(element) {
21090
+ return element.closest(NATIVE_REQUEST_SELECTOR) !== null;
21091
+ }
21092
+ function hasNativeComposerRequest(composer) {
21093
+ return isNativeComposerRequest(composer) || composer.querySelector(NATIVE_REQUEST_SELECTOR) !== null;
21094
+ }
21095
+ function nativeRequestElements(composer) {
21096
+ const nodes = [];
21097
+ const seen = /* @__PURE__ */ new Set();
21098
+ const add = (node) => {
21099
+ if (!(node instanceof HTMLElement) || seen.has(node)) return;
21100
+ if (!node.matches(NATIVE_REQUEST_SELECTOR)) return;
21101
+ if (node.matches(COMPOSER_ROOT_SELECTOR)) return;
21102
+ seen.add(node);
21103
+ nodes.push(node);
21104
+ };
21105
+ const addTree = (root) => {
21106
+ add(root);
21107
+ for (const node of root.querySelectorAll(NATIVE_REQUEST_SELECTOR)) add(node);
21108
+ };
21109
+ addTree(composer);
21110
+ let sibling = composer.previousElementSibling;
21111
+ while (sibling) {
21112
+ if (sibling.matches(COMPOSER_ROOT_SELECTOR)) break;
21113
+ addTree(sibling);
21114
+ sibling = sibling.previousElementSibling;
21115
+ }
21116
+ const parent = composer.parentElement;
21117
+ if (parent) {
21118
+ for (const node of parent.querySelectorAll(NATIVE_REQUEST_SELECTOR)) {
21119
+ if (!(node instanceof HTMLElement) || node.contains(composer)) continue;
21120
+ const other = node.closest(COMPOSER_ROOT_SELECTOR);
21121
+ if (other && other !== composer) continue;
21122
+ add(node);
21123
+ }
21124
+ }
21125
+ return nodes;
21126
+ }
21127
+ function hasNearbyNativeComposerRequest(composer) {
21128
+ return hasNativeComposerRequest(composer) || nativeRequestElements(composer).length > 0;
21129
+ }
21130
+ function ensureCoverStyle(document2) {
21131
+ if (document2.getElementById(COVER_STYLE_ID)) return;
21132
+ const style = document2.createElement("style");
21133
+ style.id = COVER_STYLE_ID;
21134
+ style.textContent = COVER_CSS;
21135
+ (document2.head ?? document2.documentElement).append(style);
21136
+ }
21137
+ function coverNativeComposerRequest(composer) {
21138
+ ensureCoverStyle(composer.ownerDocument);
21139
+ const wanted = new Set(nativeRequestElements(composer));
21140
+ for (const node of composer.ownerDocument.querySelectorAll(
21141
+ `[${SHARED_QUESTION_NATIVE_COVER_ATTRIBUTE}]`
21142
+ )) {
21143
+ if (!(node instanceof HTMLElement)) continue;
21144
+ if (!wanted.has(node)) node.removeAttribute(SHARED_QUESTION_NATIVE_COVER_ATTRIBUTE);
21145
+ }
21146
+ for (const node of wanted) {
21147
+ if (!node.hasAttribute(SHARED_QUESTION_NATIVE_COVER_ATTRIBUTE)) {
21148
+ node.setAttribute(SHARED_QUESTION_NATIVE_COVER_ATTRIBUTE, "");
21149
+ }
21150
+ }
21151
+ }
21152
+ function uncoverNativeComposerRequest(root) {
21153
+ for (const node of root.querySelectorAll(`[${SHARED_QUESTION_NATIVE_COVER_ATTRIBUTE}]`)) {
21154
+ if (!(node instanceof HTMLElement)) continue;
21155
+ node.removeAttribute(SHARED_QUESTION_NATIVE_COVER_ATTRIBUTE);
21156
+ }
21157
+ }
21158
+
20485
21159
  // src/renderer-questions.ts
20486
21160
  function same2(a, b) {
20487
21161
  return a?.hostId === b?.hostId && a?.threadId === b?.threadId && a?.composer === b?.composer && a?.route === b?.route;
20488
21162
  }
21163
+ function sharedCard(question) {
21164
+ return Boolean(
21165
+ question?.questions.some(
21166
+ (field2) => field2.type === "choice" && (field2.multiple || field2.allowOther)
21167
+ )
21168
+ );
21169
+ }
21170
+ function createJumpPill(document2, onJump) {
21171
+ const button2 = document2.createElement("button");
21172
+ button2.type = "button";
21173
+ button2.dataset.codexhostQuestionJump = "";
21174
+ button2.textContent = "Question waiting \u2014 Jump";
21175
+ button2.addEventListener("click", (event) => {
21176
+ event.preventDefault();
21177
+ event.stopPropagation();
21178
+ onJump();
21179
+ });
21180
+ Object.assign(button2.style, {
21181
+ display: "block",
21182
+ position: "relative",
21183
+ zIndex: "4",
21184
+ pointerEvents: "auto",
21185
+ width: "100%",
21186
+ margin: "0 0 8px",
21187
+ minHeight: "28px",
21188
+ border: "1px solid color-mix(in srgb, currentColor 12%, transparent)",
21189
+ borderRadius: "999px",
21190
+ background: "transparent",
21191
+ color: "inherit",
21192
+ font: "13px/1.4 system-ui, sans-serif",
21193
+ cursor: "pointer"
21194
+ });
21195
+ return button2;
21196
+ }
20489
21197
  function installRendererQuestions(window2, readContext) {
20490
21198
  let disposed = false;
20491
21199
  let inFlight = false;
20492
21200
  let revision = 0;
21201
+ let placement = readHarnessQuestionPlacement(window2);
21202
+ let historyMode = readHarnessQuestionHistory(window2);
20493
21203
  let context2 = null;
20494
21204
  let card = null;
20495
21205
  let cardKey = null;
21206
+ let mountedPlacement = null;
21207
+ let jump = null;
20496
21208
  let stopActivity;
20497
21209
  const unsupported = /* @__PURE__ */ new WeakSet();
21210
+ const unsupportedRecords = /* @__PURE__ */ new WeakSet();
21211
+ const listUnobserved = (current) => {
21212
+ if (unsupported.has(current.route)) return;
21213
+ void Promise.resolve(
21214
+ current.route.sendRequest(
21215
+ THREAD_QUESTIONS_LIST_METHOD,
21216
+ { threadId: current.threadId, unobserved: true },
21217
+ { priority: "background", timeoutMs: 4e3 }
21218
+ )
21219
+ ).catch((error51) => {
21220
+ if (isUnsupportedMethod(error51, THREAD_QUESTIONS_LIST_METHOD)) unsupported.add(current.route);
21221
+ });
21222
+ };
20498
21223
  const drafts = /* @__PURE__ */ new Map();
21224
+ const records = /* @__PURE__ */ new Map();
21225
+ const clearJump = () => {
21226
+ jump?.remove();
21227
+ jump = null;
21228
+ };
20499
21229
  const clear = (retain = true) => {
20500
21230
  stopActivity?.();
20501
21231
  stopActivity = void 0;
@@ -20507,12 +21237,110 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
20507
21237
  card?.dispose();
20508
21238
  card = null;
20509
21239
  cardKey = null;
21240
+ mountedPlacement = null;
21241
+ clearJump();
21242
+ };
21243
+ const clearRecords = () => {
21244
+ for (const view of records.values()) view.dispose();
21245
+ records.clear();
21246
+ };
21247
+ const syncNativeCover = (current, live) => {
21248
+ if (live) coverNativeComposerRequest(current.composer);
21249
+ else uncoverNativeComposerRequest(current.composer.ownerDocument);
21250
+ };
21251
+ const liveMount = (document2, anchor) => {
21252
+ if (!anchor?.itemId) return null;
21253
+ return findLiveQuestionMount(document2, anchor.itemId, anchor.turnId);
21254
+ };
21255
+ const resolveLivePlacement = (document2, anchor) => {
21256
+ if (placement !== "in-chat") return "overlay";
21257
+ if (liveMount(document2, anchor)) return "in-chat";
21258
+ if (anchor?.itemId) return "jump";
21259
+ return "overlay";
21260
+ };
21261
+ const placeLive = (current, anchor) => {
21262
+ const document2 = current.composer.ownerDocument;
21263
+ const placement2 = resolveLivePlacement(document2, anchor);
21264
+ if (!card) return placement2;
21265
+ if (placement2 === "in-chat") {
21266
+ const mount = liveMount(document2, anchor);
21267
+ if (mount) {
21268
+ ensureQuestionHistorySlot(document2, mount).append(card.root);
21269
+ return "in-chat";
21270
+ }
21271
+ }
21272
+ if (placement2 === "jump") {
21273
+ jump = createJumpPill(document2, () => {
21274
+ void jumpRevealsQuestionRow(
21275
+ document2,
21276
+ current.hostId,
21277
+ current.threadId,
21278
+ anchor?.itemId
21279
+ ).then(() => {
21280
+ if (!disposed) void refresh();
21281
+ });
21282
+ });
21283
+ current.composer.before(jump);
21284
+ return "jump";
21285
+ }
21286
+ current.composer.before(card.root);
21287
+ return "overlay";
21288
+ };
21289
+ const syncRecords = (current, closed, liveId) => {
21290
+ const document2 = current.composer.ownerDocument;
21291
+ const visible2 = /* @__PURE__ */ new Set();
21292
+ for (const record21 of closed) {
21293
+ if (record21.interactionId === liveId) continue;
21294
+ const mount = findVisibleHistoryMount(document2, record21.itemId, record21.turnId);
21295
+ if (!mount) continue;
21296
+ const host = ensureQuestionHistorySlot(document2, mount);
21297
+ visible2.add(record21.interactionId);
21298
+ const existing = records.get(record21.interactionId);
21299
+ if (existing?.root.isConnected && existing.root.parentElement === host && existing.historyMode === historyMode)
21300
+ continue;
21301
+ existing?.dispose();
21302
+ const view = createQuestionCard(
21303
+ document2,
21304
+ {
21305
+ interactionId: record21.interactionId,
21306
+ turnId: record21.turnId,
21307
+ ...record21.title !== void 0 ? { title: record21.title } : {},
21308
+ questions: record21.questions
21309
+ },
21310
+ async () => void 0,
21311
+ record21.answers,
21312
+ { outcome: record21.outcome, history: historyMode }
21313
+ );
21314
+ host.append(view.root);
21315
+ records.set(record21.interactionId, view);
21316
+ }
21317
+ for (const [id, view] of records) {
21318
+ if (visible2.has(id) && view.root.isConnected) continue;
21319
+ view.dispose();
21320
+ records.delete(id);
21321
+ }
21322
+ while (records.size > 50) {
21323
+ const oldest = records.keys().next().value;
21324
+ if (oldest === void 0) break;
21325
+ records.get(oldest)?.dispose();
21326
+ records.delete(oldest);
21327
+ }
21328
+ };
21329
+ const syncRecordsSafe = (current, closed, liveId) => {
21330
+ try {
21331
+ syncRecords(current, closed, liveId);
21332
+ } catch {
21333
+ return;
21334
+ }
20510
21335
  };
20511
21336
  const refresh = async () => {
20512
21337
  if (disposed) return;
20513
21338
  const next = readContext();
20514
21339
  if (!same2(context2, next)) {
21340
+ if (context2 && context2.threadId !== next?.threadId) listUnobserved(context2);
21341
+ if (context2) syncNativeCover(context2, false);
20515
21342
  clear();
21343
+ clearRecords();
20516
21344
  context2 = next;
20517
21345
  revision++;
20518
21346
  }
@@ -20521,35 +21349,63 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
20521
21349
  const startedRevision = revision;
20522
21350
  inFlight = true;
20523
21351
  try {
20524
- const raw = await current.route.sendRequest(
20525
- THREAD_QUESTIONS_LIST_METHOD,
20526
- { threadId: current.threadId },
20527
- { priority: "background", timeoutMs: 5e3 }
20528
- );
21352
+ const listParams = { threadId: current.threadId };
21353
+ const listOptions = { priority: "background", timeoutMs: 5e3 };
21354
+ const recordsPromise = unsupportedRecords.has(current.route) ? Promise.resolve(void 0) : Promise.resolve(
21355
+ current.route.sendRequest(THREAD_QUESTION_RECORDS_LIST_METHOD, listParams, listOptions)
21356
+ ).catch((error51) => {
21357
+ if (isUnsupportedMethod(error51, THREAD_QUESTION_RECORDS_LIST_METHOD)) {
21358
+ unsupportedRecords.add(current.route);
21359
+ }
21360
+ return void 0;
21361
+ });
21362
+ const [raw, recordRaw] = await Promise.all([
21363
+ current.route.sendRequest(THREAD_QUESTIONS_LIST_METHOD, listParams, listOptions),
21364
+ recordsPromise
21365
+ ]);
20529
21366
  if (disposed || revision !== startedRevision || !same2(current, readContext())) return;
20530
21367
  const question = threadQuestionsResultSchema.parse(raw).questions[0];
20531
- if (!question || !question.questions.some(
20532
- (field2) => field2.type === "choice" && (field2.multiple || field2.allowOther)
20533
- )) {
21368
+ const live = sharedCard(question) ? question : void 0;
21369
+ let closed = [];
21370
+ let pendingAnchors = [];
21371
+ if (recordRaw !== void 0) {
21372
+ const parsed = threadQuestionRecordsResultSchema.safeParse(recordRaw);
21373
+ if (parsed.success) {
21374
+ closed = parsed.data.records;
21375
+ pendingAnchors = parsed.data.pendingAnchors;
21376
+ }
21377
+ }
21378
+ if (!live) {
20534
21379
  if (cardKey) drafts.delete(cardKey);
20535
21380
  clear(false);
21381
+ syncNativeCover(current, false);
21382
+ syncRecordsSafe(current, closed, void 0);
20536
21383
  return;
20537
21384
  }
20538
21385
  const key = JSON.stringify([
20539
21386
  current.hostId,
20540
21387
  current.threadId,
20541
- question.turnId,
20542
- question.interactionId
21388
+ live.turnId,
21389
+ live.interactionId
20543
21390
  ]);
20544
- if (cardKey === key && card?.root.isConnected) {
20545
- card.updateAutoResolution(question.autoResolution);
20546
- return;
21391
+ const anchor = pendingAnchors.find(
21392
+ (candidate) => candidate.interactionId === live.interactionId
21393
+ );
21394
+ if (cardKey === key && mountedPlacement) {
21395
+ const expected = resolveLivePlacement(current.composer.ownerDocument, anchor);
21396
+ const stable = mountedPlacement === expected && (expected === "jump" ? jump?.isConnected === true : card?.root.isConnected === true && (expected !== "in-chat" || elementIsShown(card.root)));
21397
+ if (stable) {
21398
+ card?.updateAutoResolution(live.autoResolution);
21399
+ syncNativeCover(current, true);
21400
+ syncRecordsSafe(current, closed, live.interactionId);
21401
+ return;
21402
+ }
20547
21403
  }
20548
21404
  clear(cardKey === key);
20549
21405
  cardKey = key;
20550
21406
  card = createQuestionCard(
20551
21407
  current.composer.ownerDocument,
20552
- question,
21408
+ live,
20553
21409
  async (answers, cancelled) => {
20554
21410
  if (disposed || !same2(current, readContext()) || cardKey !== key)
20555
21411
  throw new Error("Question owner changed");
@@ -20557,8 +21413,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
20557
21413
  THREAD_QUESTION_RESPOND_METHOD,
20558
21414
  {
20559
21415
  threadId: current.threadId,
20560
- turnId: question.turnId,
20561
- interactionId: question.interactionId,
21416
+ turnId: live.turnId,
21417
+ interactionId: live.interactionId,
20562
21418
  answers,
20563
21419
  cancelled
20564
21420
  },
@@ -20569,11 +21425,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
20569
21425
  if (same2(current, context2)) {
20570
21426
  revision++;
20571
21427
  if (cardKey === key) clear(false);
21428
+ void refresh();
20572
21429
  }
20573
21430
  },
20574
21431
  drafts.get(key)
20575
21432
  );
20576
- current.composer.before(card.root);
21433
+ mountedPlacement = placeLive(current, anchor);
21434
+ syncNativeCover(current, true);
20577
21435
  const mounted = card;
20578
21436
  stopActivity = installQuestionActivity(
20579
21437
  window2,
@@ -20584,8 +21442,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
20584
21442
  THREAD_QUESTION_ACTIVITY_METHOD,
20585
21443
  {
20586
21444
  threadId: current.threadId,
20587
- turnId: question.turnId,
20588
- interactionId: question.interactionId
21445
+ turnId: live.turnId,
21446
+ interactionId: live.interactionId
20589
21447
  },
20590
21448
  { priority: "background", timeoutMs: 4e3 }
20591
21449
  );
@@ -20594,9 +21452,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
20594
21452
  if (ack) mounted.updateAutoResolution(ack);
20595
21453
  }
20596
21454
  );
21455
+ syncRecordsSafe(current, closed, live.interactionId);
20597
21456
  } catch (error51) {
20598
21457
  if (isUnsupportedMethod(error51, THREAD_QUESTIONS_LIST_METHOD)) unsupported.add(current.route);
20599
- if (revision === startedRevision && same2(current, context2)) clear();
21458
+ if (revision === startedRevision && same2(current, context2)) {
21459
+ clear();
21460
+ syncNativeCover(current, false);
21461
+ }
20600
21462
  } finally {
20601
21463
  inFlight = false;
20602
21464
  }
@@ -20604,16 +21466,41 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
20604
21466
  const timer = window2.setInterval(() => {
20605
21467
  void refresh();
20606
21468
  }, 750);
21469
+ const onPlacement = () => {
21470
+ placement = readHarnessQuestionPlacement(window2);
21471
+ void refresh();
21472
+ };
21473
+ const onHistory = () => {
21474
+ historyMode = readHarnessQuestionHistory(window2);
21475
+ clearRecords();
21476
+ void refresh();
21477
+ };
21478
+ const onVisibility = () => {
21479
+ if (disposed || window2.document.visibilityState !== "hidden") return;
21480
+ const current = context2 ?? readContext();
21481
+ if (current) listUnobserved(current);
21482
+ };
21483
+ window2.addEventListener(HARNESS_QUESTION_PLACEMENT_CHANGE_EVENT, onPlacement);
21484
+ window2.addEventListener(HARNESS_QUESTION_HISTORY_CHANGE_EVENT, onHistory);
21485
+ window2.document.addEventListener("visibilitychange", onVisibility);
20607
21486
  void refresh();
20608
21487
  return {
20609
21488
  refresh,
20610
21489
  refreshContext() {
20611
- if (!same2(context2, readContext()) || card && !card.root.isConnected) void refresh();
21490
+ if (context2 && (card || jump)) coverNativeComposerRequest(context2.composer);
21491
+ else if (context2) uncoverNativeComposerRequest(context2.composer.ownerDocument);
21492
+ if (!same2(context2, readContext()) || card && !card.root.isConnected || jump?.isConnected === false)
21493
+ void refresh();
20612
21494
  },
20613
21495
  dispose() {
20614
21496
  disposed = true;
20615
21497
  window2.clearInterval(timer);
21498
+ window2.removeEventListener(HARNESS_QUESTION_PLACEMENT_CHANGE_EVENT, onPlacement);
21499
+ window2.removeEventListener(HARNESS_QUESTION_HISTORY_CHANGE_EVENT, onHistory);
21500
+ window2.document.removeEventListener("visibilitychange", onVisibility);
21501
+ if (context2) syncNativeCover(context2, false);
20616
21502
  clear(false);
21503
+ clearRecords();
20617
21504
  drafts.clear();
20618
21505
  }
20619
21506
  };
@@ -23365,6 +24252,24 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
23365
24252
  "When this is on, that card is hidden on every Composer, including Codex threads. Reset usage and Upgrade stay available in Settings.",
23366
24253
  "Turning this off only shows the native card again. Send on this Composer, including Codex threads, is already separated from that quota card."
23367
24254
  ]),
24255
+ harnessQuestionInChatTitle: "Show Harness questions in the chat",
24256
+ harnessQuestionInChatDescription: "On: questions from external Harnesses appear in the conversation and stay there after you answer. Off: they appear above the message box and close after Send or Skip.",
24257
+ harnessQuestionInChatHelpLabel: "About Harness question placement",
24258
+ harnessQuestionInChatHelp: Object.freeze([
24259
+ "Codex's own questions always use the Codex Desktop layout.",
24260
+ "Some single-choice and text questions still use the Desktop card.",
24261
+ "Answered questions remain after reopening a chat only if the Harness's own history records them.",
24262
+ "Desktop still folds thinking and tool calls. The answered card stays visible as full-width history during the turn, then with the visible reply.",
24263
+ "Update both the Host and the Desktop extension, including remote Hosts."
24264
+ ]),
24265
+ harnessQuestionHistorySelectedTitle: "Keep only selected answers in question history",
24266
+ harnessQuestionHistorySelectedDescription: "On by default. After you answer an in-chat Harness question, history keeps the chosen answers and hides the other options. Turn this off to keep every option in the record.",
24267
+ harnessQuestionHistorySelectedHelpLabel: "About Harness question history",
24268
+ harnessQuestionHistorySelectedHelp: Object.freeze([
24269
+ "Live pickers still show every option until you send or skip.",
24270
+ "Skipped, expired, and closed questions keep the prompt and outcome without listing unused options.",
24271
+ "This is per viewer. It does not change how answers are stored."
24272
+ ]),
23368
24273
  loadedSessions: {
23369
24274
  title: "Loaded sessions",
23370
24275
  description: "Local external Harnesses only. Refreshes every 10 seconds without waking sessions or resetting activity. Released sessions disappear from this list.",
@@ -23695,6 +24600,24 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
23695
24600
  "\u5F00\u542F\u540E\uFF0C\u6240\u6709 Composer \u90FD\u9690\u85CF\u8BE5\u5361\u7247\uFF0C\u5305\u62EC Codex \u4F1A\u8BDD\u3002\u300C\u91CD\u7F6E\u7528\u91CF\u300D\u548C\u300C\u5347\u7EA7\u300D\u4ECD\u53EF\u5728\u8BBE\u7F6E\u4E2D\u4F7F\u7528\u3002",
23696
24601
  "\u5173\u95ED\u6B64\u5F00\u5173\u53EA\u4F1A\u91CD\u65B0\u663E\u793A\u539F\u751F\u5361\u7247\u3002\u5F53\u524D Composer \u7684\u53D1\u9001\uFF08\u5305\u62EC Codex \u4F1A\u8BDD\uFF09\u5DF2\u4E0E\u8BE5\u989D\u5EA6\u5361\u7247\u5206\u79BB\u3002"
23697
24602
  ]),
24603
+ harnessQuestionInChatTitle: "\u5728\u5BF9\u8BDD\u4E2D\u663E\u793A Harness \u63D0\u95EE",
24604
+ harnessQuestionInChatDescription: "\u5F00\u542F\uFF1A\u5916\u90E8 Harness \u7684\u63D0\u95EE\u51FA\u73B0\u5728\u5BF9\u8BDD\u4E2D\uFF0C\u56DE\u7B54\u540E\u4ECD\u4FDD\u7559\u3002\u5173\u95ED\uFF1A\u63D0\u95EE\u51FA\u73B0\u5728\u8F93\u5165\u6846\u4E0A\u65B9\uFF0C\u53D1\u9001\u6216\u8DF3\u8FC7\u540E\u5173\u95ED\u3002",
24605
+ harnessQuestionInChatHelpLabel: "Harness \u63D0\u95EE\u4F4D\u7F6E\u8BF4\u660E",
24606
+ harnessQuestionInChatHelp: Object.freeze([
24607
+ "Codex \u81EA\u5DF1\u7684\u63D0\u95EE\u59CB\u7EC8\u4F7F\u7528 Codex Desktop \u7684\u5E03\u5C40\u3002",
24608
+ "\u90E8\u5206\u5355\u9009\u548C\u6587\u672C\u63D0\u95EE\u4ECD\u4F7F\u7528 Desktop \u5361\u7247\u3002",
24609
+ "\u53EA\u6709 Harness \u81EA\u5DF1\u7684\u5386\u53F2\u8BB0\u5F55\u4E86\u63D0\u95EE\u548C\u7B54\u6848\u65F6\uFF0C\u91CD\u65B0\u6253\u5F00\u4F1A\u8BDD\u624D\u4F1A\u518D\u6B21\u663E\u793A\u5DF2\u56DE\u7B54\u7684\u63D0\u95EE\u3002",
24610
+ "Desktop \u4ECD\u4F1A\u6298\u53E0\u601D\u8003\u548C\u5DE5\u5177\u8C03\u7528\u3002\u5DF2\u56DE\u7B54\u7684\u5361\u7247\u5728\u56DE\u5408\u8FDB\u884C\u4E2D\u4E5F\u4FDD\u6301\u5168\u5BBD\u5386\u53F2\uFF0C\u968F\u540E\u7559\u5728\u53EF\u89C1\u56DE\u590D\u5904\u3002",
24611
+ "Host \u548C Desktop \u6269\u5C55\u9700\u8981\u4E00\u8D77\u66F4\u65B0\uFF0C\u5305\u62EC\u8FDC\u7A0B Host\u3002"
24612
+ ]),
24613
+ harnessQuestionHistorySelectedTitle: "\u63D0\u95EE\u5386\u53F2\u53EA\u4FDD\u7559\u5DF2\u9009\u7B54\u6848",
24614
+ harnessQuestionHistorySelectedDescription: "\u9ED8\u8BA4\u5F00\u542F\u3002\u5728\u5BF9\u8BDD\u4E2D\u56DE\u7B54 Harness \u63D0\u95EE\u540E\uFF0C\u5386\u53F2\u53EA\u7559\u4E0B\u6240\u9009\u7B54\u6848\uFF0C\u5E76\u9690\u85CF\u5176\u4ED6\u9009\u9879\u3002\u5173\u95ED\u540E\uFF0C\u8BB0\u5F55\u4F1A\u4FDD\u7559\u5168\u90E8\u9009\u9879\u3002",
24615
+ harnessQuestionHistorySelectedHelpLabel: "Harness \u63D0\u95EE\u5386\u53F2\u8BF4\u660E",
24616
+ harnessQuestionHistorySelectedHelp: Object.freeze([
24617
+ "\u672A\u53D1\u9001\u6216\u8DF3\u8FC7\u524D\uFF0C\u8FDB\u884C\u4E2D\u7684\u9009\u62E9\u5361\u7247\u4ECD\u663E\u793A\u5168\u90E8\u9009\u9879\u3002",
24618
+ "\u8DF3\u8FC7\u3001\u8FC7\u671F\u6216\u7531 Harness \u5173\u95ED\u7684\u63D0\u95EE\u4FDD\u7559\u9898\u5E72\u548C\u7ED3\u679C\uFF0C\u4E0D\u518D\u5217\u51FA\u672A\u4F7F\u7528\u7684\u9009\u9879\u3002",
24619
+ "\u6B64\u8BBE\u7F6E\u4E3A\u5F53\u524D\u67E5\u770B\u5668\u672C\u5730\u504F\u597D\uFF0C\u4E0D\u6539\u53D8\u7B54\u6848\u7684\u5B58\u50A8\u65B9\u5F0F\u3002"
24620
+ ]),
23698
24621
  loadedSessions: {
23699
24622
  title: "\u5DF2\u52A0\u8F7D\u4F1A\u8BDD",
23700
24623
  description: "\u4EC5\u663E\u793A\u672C\u5730\u5916\u90E8 Harness\u3002\u6BCF 10 \u79D2\u5237\u65B0\uFF0C\u4E0D\u5524\u9192\u4F1A\u8BDD\u3001\u4E0D\u91CD\u7F6E\u6D3B\u52A8\u65F6\u95F4\u3002\u91CA\u653E\u540E\u7684\u4F1A\u8BDD\u4ECE\u5217\u8868\u79FB\u9664\u3002",
@@ -27295,21 +28218,6 @@ Codex Fast mode prioritizes requests and may increase usage.`
27295
28218
  };
27296
28219
  }
27297
28220
 
27298
- // src/renderer-composer-request.ts
27299
- var NATIVE_COMPOSER_REQUEST_ATTRIBUTES = [
27300
- "data-codex-composer-request-navigation",
27301
- "data-codex-composer-request"
27302
- ];
27303
- var NATIVE_REQUEST_SELECTOR = NATIVE_COMPOSER_REQUEST_ATTRIBUTES.map(
27304
- (attribute) => `[${attribute}]`
27305
- ).join(", ");
27306
- function isNativeComposerRequest(element) {
27307
- return element.closest(NATIVE_REQUEST_SELECTOR) !== null;
27308
- }
27309
- function hasNativeComposerRequest(composer) {
27310
- return isNativeComposerRequest(composer) || composer.querySelector(NATIVE_REQUEST_SELECTOR) !== null;
27311
- }
27312
-
27313
28221
  // src/renderer-harness-command-control.ts
27314
28222
  var CONTROL_ATTRIBUTE2 = "data-codexhost-harness-command-control";
27315
28223
  var SVG_NS2 = "http://www.w3.org/2000/svg";
@@ -28002,52 +28910,6 @@ Codex Fast mode prioritizes requests and may increase usage.`
28002
28910
  control.picker.dispose();
28003
28911
  }
28004
28912
 
28005
- // src/renderer-transcript-dom.ts
28006
- var TRANSCRIPT_ITEM_SELECTOR = "[data-local-conversation-item-target-ids]";
28007
- var TRANSCRIPT_TEXT_BODY_SELECTOR = '[data-testid="exec-shell-body"]';
28008
- var REASONING_SOFT_WRAP_STORAGE_KEY = "codexhost.reasoning-soft-wrap.v1";
28009
- var REASONING_SOFT_WRAP_CHANGE_EVENT = "codexhost:reasoning-soft-wrap-changed";
28010
- function readReasoningTranscriptSoftWrap(ownerWindow) {
28011
- return ownerWindow.localStorage.getItem(REASONING_SOFT_WRAP_STORAGE_KEY) === "true";
28012
- }
28013
- function setReasoningTranscriptSoftWrap(ownerWindow, enabled) {
28014
- ownerWindow.localStorage.setItem(REASONING_SOFT_WRAP_STORAGE_KEY, String(enabled));
28015
- ownerWindow.dispatchEvent(new Event(REASONING_SOFT_WRAP_CHANGE_EVENT));
28016
- }
28017
- function installReasoningTranscriptSoftWrap(ownerDocument) {
28018
- const ownerWindow = ownerDocument.defaultView;
28019
- if (!ownerWindow) return () => {
28020
- };
28021
- const style = ownerDocument.createElement("style");
28022
- style.setAttribute("data-codexhost-reasoning-soft-wrap", "true");
28023
- const body = `${TRANSCRIPT_TEXT_BODY_SELECTOR}:has([aria-label="$ ${REASONING_TRANSCRIPT_COMMAND}"])`;
28024
- style.textContent = `
28025
- ${body} .whitespace-pre {
28026
- white-space: pre-wrap;
28027
- overflow-wrap: anywhere;
28028
- }
28029
- ${body} .whitespace-pre > .w-max {
28030
- width: 100%;
28031
- min-width: 0;
28032
- }
28033
- `;
28034
- ownerDocument.head.append(style);
28035
- const refresh = () => {
28036
- style.disabled = !readReasoningTranscriptSoftWrap(ownerWindow);
28037
- };
28038
- const onStorage = (event) => {
28039
- if (event.key === REASONING_SOFT_WRAP_STORAGE_KEY || event.key === null) refresh();
28040
- };
28041
- refresh();
28042
- ownerWindow.addEventListener(REASONING_SOFT_WRAP_CHANGE_EVENT, refresh);
28043
- ownerWindow.addEventListener("storage", onStorage);
28044
- return () => {
28045
- ownerWindow.removeEventListener(REASONING_SOFT_WRAP_CHANGE_EVENT, refresh);
28046
- ownerWindow.removeEventListener("storage", onStorage);
28047
- style.remove();
28048
- };
28049
- }
28050
-
28051
28913
  // src/renderer-codex-account-state.ts
28052
28914
  function resolveCurrentCodexAccountId(accounts, currentAccountId) {
28053
28915
  return accounts.some((account) => account.accountId === currentAccountId) ? currentAccountId : null;
@@ -29911,17 +30773,17 @@ Codex Fast mode prioritizes requests and may increase usage.`
29911
30773
 
29912
30774
  // src/renderer-sidebar-agent-icons.ts
29913
30775
  var SIDEBAR_THREAD_ROW_ATTRIBUTE = "data-app-action-sidebar-thread-row";
29914
- var SIDEBAR_THREAD_ROW_SELECTOR = `[${SIDEBAR_THREAD_ROW_ATTRIBUTE}]`;
29915
- var SIDEBAR_THREAD_ID_ATTRIBUTE = "data-app-action-sidebar-thread-id";
30776
+ var SIDEBAR_THREAD_ROW_SELECTOR2 = `[${SIDEBAR_THREAD_ROW_ATTRIBUTE}]`;
30777
+ var SIDEBAR_THREAD_ID_ATTRIBUTE2 = "data-app-action-sidebar-thread-id";
29916
30778
  var SIDEBAR_THREAD_HOST_ID_ATTRIBUTE = "data-app-action-sidebar-thread-host-id";
29917
30779
  var SIDEBAR_AGENT_ICON_ATTRIBUTE = "data-codexhost-sidebar-agent-icon";
29918
- var SIDEBAR_AGENT_ICON_ROW_SELECTOR = `${SIDEBAR_THREAD_ROW_SELECTOR}, ${NATIVE_SCHEDULE_SIDEBAR_ROW_SELECTOR}`;
30780
+ var SIDEBAR_AGENT_ICON_ROW_SELECTOR = `${SIDEBAR_THREAD_ROW_SELECTOR2}, ${NATIVE_SCHEDULE_SIDEBAR_ROW_SELECTOR}`;
29919
30781
  var OWNERSHIP_RETRY_DELAYS_MS = [100, 300, 800, 1500, 3e3];
29920
30782
  function isRecord12(value) {
29921
30783
  return typeof value === "object" && value !== null && !Array.isArray(value);
29922
30784
  }
29923
30785
  function sidebarThreadAttributes(element) {
29924
- const taskKey = element.getAttribute(SIDEBAR_THREAD_ID_ATTRIBUTE);
30786
+ const taskKey = element.getAttribute(SIDEBAR_THREAD_ID_ATTRIBUTE2);
29925
30787
  const hostId2 = element.getAttribute(SIDEBAR_THREAD_HOST_ID_ATTRIBUTE);
29926
30788
  const rowMarker = element.getAttribute(SIDEBAR_THREAD_ROW_ATTRIBUTE);
29927
30789
  if (taskKey === null || hostId2 === null || rowMarker === null) return null;
@@ -29952,7 +30814,7 @@ Codex Fast mode prioritizes requests and may increase usage.`
29952
30814
  if (isRecord12(props) && isRecord12(props.dataAttributes)) {
29953
30815
  const dataAttributes = props.dataAttributes;
29954
30816
  const threadId = hostThreadIdSchema.safeParse(props.conversationId);
29955
- if (threadId.success && dataAttributes[SIDEBAR_THREAD_ROW_ATTRIBUTE] === rowMarker && dataAttributes[SIDEBAR_THREAD_ID_ATTRIBUTE] === taskKey && dataAttributes[SIDEBAR_THREAD_HOST_ID_ATTRIBUTE] === hostId2) {
30817
+ if (threadId.success && dataAttributes[SIDEBAR_THREAD_ROW_ATTRIBUTE] === rowMarker && dataAttributes[SIDEBAR_THREAD_ID_ATTRIBUTE2] === taskKey && dataAttributes[SIDEBAR_THREAD_HOST_ID_ATTRIBUTE] === hostId2) {
29956
30818
  candidates.add(threadId.data);
29957
30819
  }
29958
30820
  }
@@ -30089,7 +30951,7 @@ Codex Fast mode prioritizes requests and may increase usage.`
30089
30951
  attributes: true,
30090
30952
  attributeFilter: [
30091
30953
  SIDEBAR_THREAD_ROW_ATTRIBUTE,
30092
- SIDEBAR_THREAD_ID_ATTRIBUTE,
30954
+ SIDEBAR_THREAD_ID_ATTRIBUTE2,
30093
30955
  SIDEBAR_THREAD_HOST_ID_ATTRIBUTE,
30094
30956
  "data-sidebar-cycle-item",
30095
30957
  "aria-labelledby",
@@ -30330,7 +31192,7 @@ Codex Fast mode prioritizes requests and may increase usage.`
30330
31192
  }
30331
31193
  function openRendererThread(threadId, options = {}) {
30332
31194
  const find = () => {
30333
- for (const row of document.querySelectorAll(SIDEBAR_THREAD_ROW_SELECTOR)) {
31195
+ for (const row of document.querySelectorAll(SIDEBAR_THREAD_ROW_SELECTOR2)) {
30334
31196
  if ((options.hostId === void 0 || row.getAttribute(SIDEBAR_THREAD_HOST_ID_ATTRIBUTE) === options.hostId) && threadIdFromSidebarRowElement(row) === threadId) {
30335
31197
  return row;
30336
31198
  }
@@ -36713,6 +37575,48 @@ ${detail}` : ""}`
36713
37575
  ownerWindow.addEventListener(CODEX_USAGE_BANNER_CHANGE_EVENT, syncUsageBanner);
36714
37576
  usageBannerRow.item.append(usageBanner);
36715
37577
  card.append(usageBannerRow.item);
37578
+ const inChatId = preferenceId("harness-question-in-chat");
37579
+ const inChatRow = createPreferenceItem(document2, {
37580
+ title: messages.harnessQuestionInChatTitle,
37581
+ description: messages.harnessQuestionInChatDescription,
37582
+ controlId: inChatId,
37583
+ help: {
37584
+ label: messages.harnessQuestionInChatHelpLabel,
37585
+ lines: messages.harnessQuestionInChatHelp
37586
+ }
37587
+ });
37588
+ const inChat = createPreferenceSwitch(document2, inChatId, inChatRow.description.id);
37589
+ inChat.checked = readHarnessQuestionPlacement(ownerWindow) === "in-chat";
37590
+ inChat.addEventListener("change", () => {
37591
+ writeHarnessQuestionPlacement(ownerWindow, inChat.checked);
37592
+ });
37593
+ const syncInChat = () => {
37594
+ inChat.checked = readHarnessQuestionPlacement(ownerWindow) === "in-chat";
37595
+ };
37596
+ ownerWindow.addEventListener(HARNESS_QUESTION_PLACEMENT_CHANGE_EVENT, syncInChat);
37597
+ inChatRow.item.append(inChat);
37598
+ card.append(inChatRow.item);
37599
+ const historyId = preferenceId("harness-question-history-selected");
37600
+ const historyRow = createPreferenceItem(document2, {
37601
+ title: messages.harnessQuestionHistorySelectedTitle,
37602
+ description: messages.harnessQuestionHistorySelectedDescription,
37603
+ controlId: historyId,
37604
+ help: {
37605
+ label: messages.harnessQuestionHistorySelectedHelpLabel,
37606
+ lines: messages.harnessQuestionHistorySelectedHelp
37607
+ }
37608
+ });
37609
+ const history = createPreferenceSwitch(document2, historyId, historyRow.description.id);
37610
+ history.checked = readHarnessQuestionHistory(ownerWindow) === "selected";
37611
+ history.addEventListener("change", () => {
37612
+ writeHarnessQuestionHistory(ownerWindow, history.checked);
37613
+ });
37614
+ const syncHistory = () => {
37615
+ history.checked = readHarnessQuestionHistory(ownerWindow) === "selected";
37616
+ };
37617
+ ownerWindow.addEventListener(HARNESS_QUESTION_HISTORY_CHANGE_EVENT, syncHistory);
37618
+ historyRow.item.append(history);
37619
+ card.append(historyRow.item);
36716
37620
  const softWrapId = preferenceId("reasoning-soft-wrap");
36717
37621
  const row = createPreferenceItem(document2, {
36718
37622
  title: messages.reasoningSoftWrapTitle,
@@ -36738,6 +37642,8 @@ ${detail}` : ""}`
36738
37642
  );
36739
37643
  return () => {
36740
37644
  ownerWindow.removeEventListener(CODEX_USAGE_BANNER_CHANGE_EVENT, syncUsageBanner);
37645
+ ownerWindow.removeEventListener(HARNESS_QUESTION_PLACEMENT_CHANGE_EVENT, syncInChat);
37646
+ ownerWindow.removeEventListener(HARNESS_QUESTION_HISTORY_CHANGE_EVENT, syncHistory);
36741
37647
  ownerWindow.removeEventListener(REASONING_SOFT_WRAP_CHANGE_EVENT, sync);
36742
37648
  disposeIdleRelease();
36743
37649
  };
@@ -46660,7 +47566,7 @@ ${usage_default}`;
46660
47566
  if (target.closest(CODEX_COMPOSER_SELECTOR)) return true;
46661
47567
  if (mutation.type === "characterData") return false;
46662
47568
  if (!target.closest(
46663
- `${TRANSCRIPT_ITEM_SELECTOR}, [data-turn-key], [data-content-search-turn-key], [data-app-action-sidebar-scroll], [data-app-action-sidebar-section], ${SIDEBAR_THREAD_ROW_SELECTOR}`
47569
+ `${TRANSCRIPT_ITEM_SELECTOR}, [data-turn-key], [data-content-search-turn-key], [data-app-action-sidebar-scroll], [data-app-action-sidebar-section], ${SIDEBAR_THREAD_ROW_SELECTOR2}`
46664
47570
  ))
46665
47571
  return true;
46666
47572
  if (mutation.type === "attributes") return target.querySelector(CODEX_COMPOSER_SELECTOR) !== null;
@@ -48847,7 +49753,41 @@ ${usage_default}`;
48847
49753
  const route = hostId2 ? window.__codexhostHostRoutingV1?.forHost(hostId2) : null;
48848
49754
  return mounted && threadId && hostId2 && route ? { hostId: hostId2, threadId, composer: mounted.composer, route: route.manager } : null;
48849
49755
  };
48850
- const questions = installRendererQuestions(window, readActivityContext);
49756
+ const visibleQuestionComposer = (composer) => composer.isConnected && composer.matches(CODEX_COMPOSER_SELECTOR) && orbitComposerKind(composer) === "codex" && composer.getClientRects().length > 0 && window.getComputedStyle(composer).visibility === "visible" && !composer.closest('[hidden], [inert], [aria-hidden="true"]');
49757
+ const readNativeRequestQuestionContext = () => {
49758
+ const composers = [...window.document.querySelectorAll(CODEX_COMPOSER_SELECTOR)].filter(
49759
+ (composer2) => visibleQuestionComposer(composer2) && hasNearbyNativeComposerRequest(composer2)
49760
+ );
49761
+ const composer = composers.length === 1 ? composers[0] : void 0;
49762
+ if (!composer) return null;
49763
+ const threadId = threadIdFromComposerModelTarget(findComposerModelTarget(composer));
49764
+ const hostId2 = activeModelHostId(composer);
49765
+ const route = hostId2 ? window.__codexhostHostRoutingV1?.forHost(hostId2) : null;
49766
+ return threadId && hostId2 && route ? { hostId: hostId2, threadId, composer, route: route.manager } : null;
49767
+ };
49768
+ let lastQuestionOwner = null;
49769
+ const readQuestionContext = () => {
49770
+ const live = readActivityContext();
49771
+ if (live) {
49772
+ lastQuestionOwner = live;
49773
+ return live;
49774
+ }
49775
+ const native = readNativeRequestQuestionContext();
49776
+ if (native) {
49777
+ lastQuestionOwner = native;
49778
+ return native;
49779
+ }
49780
+ const owner = lastQuestionOwner;
49781
+ if (!owner?.composer.isConnected || !hasNearbyNativeComposerRequest(owner.composer)) {
49782
+ lastQuestionOwner = null;
49783
+ return null;
49784
+ }
49785
+ const threadId = threadIdFromComposerModelTarget(findComposerModelTarget(owner.composer));
49786
+ const routed = window.__codexhostHostRoutingV1?.forHost(owner.hostId);
49787
+ if (!threadId || !routed) return null;
49788
+ return { hostId: owner.hostId, threadId, composer: owner.composer, route: routed.manager };
49789
+ };
49790
+ const questions = installRendererQuestions(window, readQuestionContext);
48851
49791
  const backgroundActivity = installRendererBackgroundActivity(window, readActivityContext);
48852
49792
  const rpcRegistry = rendererRpcClientRegistryReader(window, () => rpcSubmission.refresh());
48853
49793
  const rpcSubmission = installRendererRpcSubmissionPreparation(
@@ -48945,6 +49885,7 @@ ${usage_default}`;
48945
49885
  void refreshCommands(mounted);
48946
49886
  if (controller.get(mounted.composer).agent !== "codex") void refreshDraftUsage(mounted);
48947
49887
  }
49888
+ questions.refreshContext();
48948
49889
  },
48949
49890
  dispose() {
48950
49891
  if (disposed) return;