@ch4acko3/dsh-turn-fold 0.4.4 → 0.5.1

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.
Files changed (2) hide show
  1. package/inline-source.cjs +28 -3
  2. package/package.json +1 -1
package/inline-source.cjs CHANGED
@@ -834,6 +834,19 @@ function __ch4acko3DshTurnFoldHasToolCallBlock(node) {
834
834
  var blocks = node.data === void 0 ? void 0 : node.data.blocks;
835
835
  return Array.isArray(blocks) && blocks.some(function (block) { return block !== void 0 && block.kind === "tool-call"; });
836
836
  }
837
+ // An image tool result is a primary visual artifact, not an intermediate step, so
838
+ // it should stay visible when the surrounding agent activity folds. Detection is
839
+ // content-based (any tool-result carrying an image block) rather than tied to a
840
+ // particular tool name, so it keeps working for any plugin that emits images.
841
+ function __ch4acko3DshTurnFoldIsPromotableImageResult(node) {
842
+ if (node === void 0 || node.kind !== "tool-call" || node.data === void 0) return false;
843
+ var root = node.data.root;
844
+ if (root === void 0 || root.kind !== "tool-result" || !Array.isArray(root.content)) return false;
845
+ for (var index = 0; index < root.content.length; index++) {
846
+ if (root.content[index] !== void 0 && root.content[index].type === "image") return true;
847
+ }
848
+ return false;
849
+ }
837
850
  function __ch4acko3DshTurnFoldIsActivityNode(node) {
838
851
  if (node.kind === "tool-call" || node.kind === "context") return true;
839
852
  if (node.kind !== "assistant-step" || __ch4acko3DshTurnFoldReasoningTexts(node).length === 0) return false;
@@ -1194,7 +1207,14 @@ function __ch4acko3DshTurnFoldRender(props) {
1194
1207
  loc = node.location;
1195
1208
  var isTurn = loc !== void 0 && (loc.kind === "turn" || loc.kind === "step");
1196
1209
  plan = isTurn ? plans.get(loc.turn.turn) : void 0;
1197
- var foldable = plan !== void 0 && plan.status === "closed" && (plan.endReason === "completed" || plan.endReason === "aborted" || plan.endReason === "interrupted") && !plan.hasError && !plan.branchUnavailable && !plan.hasAfterClosing && plan.closingKey !== void 0 && (plan.activity.length > 0 || plan.closingReasoning.length > 0) && !plan.activity.some(function (activityKey) { return interactionKeys.has(activityKey); });
1210
+ var turnFoldKey = plan === void 0 ? null : String(sessionId) + ":" + plan.turn;
1211
+ // Preserve an in-progress selection only when folding would newly hide one
1212
+ // of its rows. Text already visible inside an open disclosure, or promoted
1213
+ // image results that stay outside it, must not dismantle the fold on rerender.
1214
+ var interactionBlocksFold = plan !== void 0 && turnFoldKey !== null && !__ch4acko3DshTurnFoldOpenKeys.has(turnFoldKey) && plan.activity.some(function (activityKey) {
1215
+ return interactionKeys.has(activityKey) && !__ch4acko3DshTurnFoldIsPromotableImageResult(nodeStore.get(activityKey));
1216
+ });
1217
+ var foldable = plan !== void 0 && plan.status === "closed" && (plan.endReason === "completed" || plan.endReason === "aborted" || plan.endReason === "interrupted") && !plan.hasError && !plan.branchUnavailable && !plan.hasAfterClosing && plan.closingKey !== void 0 && (plan.activity.length > 0 || plan.closingReasoning.length > 0) && !interactionBlocksFold;
1198
1218
  if (foldable && FOLD_KINDS[node.kind] === true && key !== plan.closingKey) continue;
1199
1219
  var summaryAnchor = plan === void 0 ? void 0 : plan.closingKey !== void 0 && (plan.firstActivityOrder < 0 || plan.closingOrder < plan.firstActivityOrder) ? plan.closingKey : plan.activity[0];
1200
1220
  if (plan !== void 0 && !foldable && summaryAnchor !== void 0 && key === summaryAnchor) {
@@ -1208,8 +1228,10 @@ function __ch4acko3DshTurnFoldRender(props) {
1208
1228
  }, "ch4acko3-dsh-turn-fold-summary-" + String(sessionId) + "-" + plan.turn) });
1209
1229
  }
1210
1230
  if (foldable && key === plan.closingKey) {
1231
+ var promotedImageKeys = plan.activity.filter(function (activityKey) { return __ch4acko3DshTurnFoldIsPromotableImageResult(nodeStore.get(activityKey)); });
1232
+ var foldedActivityKeys = plan.activity.filter(function (activityKey) { return promotedImageKeys.indexOf(activityKey) < 0; });
1211
1233
  entries.push({ type: "element", element: react_jsx_runtime.jsx(__ch4acko3DshTurnFoldDisclosure, {
1212
- activity: plan.activity,
1234
+ activity: foldedActivityKeys,
1213
1235
  closingReasoning: plan.closingReasoning,
1214
1236
  completed: plan.endReason === "completed",
1215
1237
  metrics: __ch4acko3DshTurnFoldPlanMetrics(plan, nodeStore, timeline),
@@ -1217,10 +1239,13 @@ function __ch4acko3DshTurnFoldRender(props) {
1217
1239
  orderPositions: orderPositions,
1218
1240
  sessionId: sessionId,
1219
1241
  termination: plan.endReason === "aborted" || plan.endReason === "interrupted" ? plan.endReason : void 0,
1220
- foldKey: String(sessionId) + ":" + plan.turn,
1242
+ foldKey: turnFoldKey,
1221
1243
  renderNode: renderNode,
1222
1244
  t: props.t
1223
1245
  }, "ch4acko3-dsh-turn-fold-" + String(sessionId) + "-" + plan.turn) });
1246
+ for (var promotedImageIndex = 0; promotedImageIndex < promotedImageKeys.length; promotedImageIndex++) {
1247
+ entries.push({ type: "element", element: renderNode(promotedImageKeys[promotedImageIndex]) });
1248
+ }
1224
1249
  }
1225
1250
  entries.push({
1226
1251
  type: "node",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ch4acko3/dsh-turn-fold",
3
- "version": "0.4.4",
3
+ "version": "0.5.1",
4
4
  "description": "Codex-style turn folding for the DSH WebUI conversation, implemented as a dsh-harmony provider.",
5
5
  "main": "./index.cjs",
6
6
  "engines": {