@lynn123411/dsh-chat-translate 3.9.0 → 3.9.3

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/lib/client.js CHANGED
@@ -1709,6 +1709,9 @@ function useSearchableHidden(hidden, reveal) {
1709
1709
  }, [reveal]);
1710
1710
  return ref;
1711
1711
  }
1712
+ function useFallbackGroupAction(hidden, reveal) {
1713
+ return useSearchableHidden(hidden, reveal);
1714
+ }
1712
1715
  var subscribeSettings = (listener) => settingsStore.subscribe(listener);
1713
1716
  function useSettledInView(ref, armed) {
1714
1717
  const noObserver = typeof IntersectionObserver === "undefined";
@@ -1807,7 +1810,8 @@ function ProseBlock({
1807
1810
  streaming,
1808
1811
  labels,
1809
1812
  mentions,
1810
- pathImages
1813
+ pathImages,
1814
+ textInteractionSource
1811
1815
  }) {
1812
1816
  const action = proseAction(mark);
1813
1817
  const source = mark === "translated" && !showingOriginal ? translated : text;
@@ -1901,13 +1905,15 @@ function ProseBlock({
1901
1905
  streaming,
1902
1906
  labels,
1903
1907
  fileMentions: mentions,
1904
- pathImages
1908
+ pathImages,
1909
+ textInteractionSource
1905
1910
  })
1906
1911
  );
1907
1912
  }
1908
1913
  var AssistantStepView = (0, import_react3.memo)(function AssistantStepView2(props) {
1909
1914
  ensureAssistantStyles();
1910
- const { store, node, groupPart, useDisclosure, useTurnData, turnProcess, openFile, renderMessageImages, fileMentions, usePresentation, t } = props;
1915
+ const { store, node, groupPart, useDisclosure, useTurnData, turnProcess, openFile, renderFactorySlot, loadImage, fileMentions, usePresentation, useGroupAction, t } = props;
1916
+ const groupAction = typeof useGroupAction === "function" ? useGroupAction : useFallbackGroupAction;
1911
1917
  const data = node.data;
1912
1918
  const streaming = data.status === "running";
1913
1919
  const interrupted = data.status === "interrupted";
@@ -1936,7 +1942,10 @@ var AssistantStepView = (0, import_react3.memo)(function AssistantStepView2(prop
1936
1942
  if (tail?.closing?.finalNode?.seq !== data.finalNode.seq) return void 0;
1937
1943
  return { turn, seq: data.finalNode.seq, openFile };
1938
1944
  }, [data.finalNode, openFile, tail, turn]);
1939
- const mentions = (0, import_react3.useMemo)(() => owner === void 0 ? void 0 : fileMentions(owner), [fileMentions, owner]);
1945
+ const mentions = (0, import_react3.useMemo)(
1946
+ () => owner === void 0 || typeof fileMentions !== "function" ? void 0 : fileMentions(owner),
1947
+ [fileMentions, owner]
1948
+ );
1940
1949
  const blocks = (0, import_react3.useMemo)(() => data.blocks ?? [], [data.blocks]);
1941
1950
  const turnSteps = turn?.steps?.map((entry) => entry.step);
1942
1951
  const conclusion = isConclusionRow({
@@ -1987,7 +1996,8 @@ var AssistantStepView = (0, import_react3.memo)(function AssistantStepView2(prop
1987
1996
  }),
1988
1997
  [blocks, streaming, interrupted, groupPart, channel, rowState, frozenCount, originalKeys, conclusion]
1989
1998
  );
1990
- const reasoningHidden = turnProcess !== void 0 && turnProcess.foldable && turnProcess.spec.answerStep === data.step && turnProcess.spec.inlineReasoning && !turnProcess.open;
1999
+ const keepReplies = usePresentation((policy) => policy.foldedReplies === "all");
2000
+ const reasoningHidden = turnProcess !== void 0 && turnProcess.foldable && (keepReplies ? groupPart !== "reasoning" : turnProcess.spec.answerStep === data.step && turnProcess.spec.inlineReasoning) && !turnProcess.open;
1991
2001
  const revealProcess = (0, import_react3.useCallback)(() => {
1992
2002
  turnProcess?.setOpen(true);
1993
2003
  }, [turnProcess]);
@@ -2012,6 +2022,7 @@ var AssistantStepView = (0, import_react3.memo)(function AssistantStepView2(prop
2012
2022
  }, [frozenCount, plan, rowKey, rowState, translate]);
2013
2023
  if (displayed.entries === null) return null;
2014
2024
  const last = blocks.length - 1;
2025
+ const textInteractionSource = data.status === "settled" && data.finalNode?.messageId !== void 0;
2015
2026
  const rendered = [];
2016
2027
  for (const entry of displayed.entries) {
2017
2028
  switch (entry.type) {
@@ -2031,7 +2042,8 @@ var AssistantStepView = (0, import_react3.memo)(function AssistantStepView2(prop
2031
2042
  streaming,
2032
2043
  labels,
2033
2044
  mentions,
2034
- pathImages
2045
+ pathImages,
2046
+ textInteractionSource
2035
2047
  })
2036
2048
  );
2037
2049
  break;
@@ -2043,6 +2055,7 @@ var AssistantStepView = (0, import_react3.memo)(function AssistantStepView2(prop
2043
2055
  key: entry.key,
2044
2056
  hidden: reasoningHidden,
2045
2057
  reveal: revealProcess,
2058
+ useGroupAction: groupAction,
2046
2059
  children: React.createElement(ReasoningRow, {
2047
2060
  text: entry.text,
2048
2061
  running: streaming && entry.blockIndex === last,
@@ -2058,7 +2071,11 @@ var AssistantStepView = (0, import_react3.memo)(function AssistantStepView2(prop
2058
2071
  rendered.push(
2059
2072
  React.createElement(React.Fragment, {
2060
2073
  key: entry.key
2061
- }, renderMessageImages({ images: entry.attachments.map((attachment) => ({ attachment })), align: "start" }))
2074
+ }, renderFactorySlot === void 0 ? null : renderFactorySlot("conversation.images.content", {
2075
+ images: entry.attachments.map((attachment) => ({ attachment })),
2076
+ loadImage,
2077
+ align: "start"
2078
+ }))
2062
2079
  );
2063
2080
  break;
2064
2081
  case "unknown":
@@ -2083,7 +2100,7 @@ var AssistantStepView = (0, import_react3.memo)(function AssistantStepView2(prop
2083
2100
  );
2084
2101
  });
2085
2102
  function ProcessReasoning(props) {
2086
- const ref = useSearchableHidden(props.hidden, props.reveal);
2103
+ const ref = props.useGroupAction(props.hidden, props.reveal);
2087
2104
  return React.createElement(
2088
2105
  "div",
2089
2106
  { ref, "data-turn-process-inline": props.hidden || void 0 },
@@ -2094,10 +2111,20 @@ function ProcessReasoning(props) {
2094
2111
  // src/client/chat/presentation.ts
2095
2112
  var NO_PREVIEW_MODE = "compact";
2096
2113
  var DEFAULT_MODE = "standard";
2097
- var WITH_PREVIEW = Object.freeze({ settledReasoningPreview: true });
2098
- var WITHOUT_PREVIEW = Object.freeze({ settledReasoningPreview: false });
2114
+ var DEFAULT_FOLDED_REPLIES = "all";
2115
+ var SNAPSHOTS = {
2116
+ "preview:all": Object.freeze({ settledReasoningPreview: true, foldedReplies: "all" }),
2117
+ "preview:final": Object.freeze({ settledReasoningPreview: true, foldedReplies: "final" }),
2118
+ "plain:all": Object.freeze({ settledReasoningPreview: false, foldedReplies: "all" }),
2119
+ "plain:final": Object.freeze({ settledReasoningPreview: false, foldedReplies: "final" })
2120
+ };
2121
+ function policyFor(mode, foldedReplies) {
2122
+ const preview = mode !== NO_PREVIEW_MODE ? "preview" : "plain";
2123
+ const folded = foldedReplies === "final" ? "final" : "all";
2124
+ return SNAPSHOTS[`${preview}:${folded}`];
2125
+ }
2099
2126
  function policyForMode(mode) {
2100
- return mode === NO_PREVIEW_MODE ? WITHOUT_PREVIEW : WITH_PREVIEW;
2127
+ return policyFor(mode, DEFAULT_FOLDED_REPLIES);
2101
2128
  }
2102
2129
  var ChatPresentation = class {
2103
2130
  policy = policyForMode(DEFAULT_MODE);
@@ -2137,7 +2164,8 @@ var ChatPresentation = class {
2137
2164
  value = void 0;
2138
2165
  }
2139
2166
  const raw = typeof value?.transcriptView === "string" ? value.transcriptView : "";
2140
- const next = policyForMode(raw);
2167
+ const rawFolded = typeof value?.foldedReplies === "string" ? value.foldedReplies : "";
2168
+ const next = policyFor(raw, rawFolded);
2141
2169
  if (next !== this.policy) {
2142
2170
  this.policy = next;
2143
2171
  for (const listener of [...this.listeners]) {
@@ -2173,8 +2201,19 @@ function apply(ctx) {
2173
2201
  // 两侧渲染逐字一致;t 由座次按该命名空间合成。
2174
2202
  locale: "chat",
2175
2203
  priority: -1,
2176
- // 思考行的 settledReasoningPreview 来自活的工作细节模式。
2177
- inject: () => ({ hooks: { presentation: chatPresentation } })
2204
+ // 思考行的 settledReasoningPreview 与 foldedReplies 来自活的工作细节模式;
2205
+ // fileMentions 由这条注册项自己提供(0.2.2 起不再走 owner props)。
2206
+ inject: (sessionId) => ({
2207
+ hooks: { presentation: chatPresentation },
2208
+ fileMentions: (owner) => {
2209
+ try {
2210
+ const service = ctx.get?.("chatFileMentions");
2211
+ return service?.forClosing?.(owner, sessionId);
2212
+ } catch {
2213
+ return void 0;
2214
+ }
2215
+ }
2216
+ })
2178
2217
  },
2179
2218
  AssistantStepView
2180
2219
  )