@yushaw/sanqian-chat 0.3.5 → 0.3.6

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.
@@ -9105,6 +9105,16 @@ var ChatInput = (0, import_react23.memo)(
9105
9105
  // src/renderer/components/HitlCard.tsx
9106
9106
  var import_react24 = require("react");
9107
9107
  var import_jsx_runtime12 = require("react/jsx-runtime");
9108
+ function parseOption(option) {
9109
+ if (typeof option === "string") return { label: option };
9110
+ if (option && typeof option === "object") {
9111
+ const obj = option;
9112
+ const label = (typeof obj.label === "string" ? obj.label : void 0) ?? (typeof obj.name === "string" ? obj.name : void 0) ?? JSON.stringify(option);
9113
+ const description = typeof obj.description === "string" ? obj.description : void 0;
9114
+ return { label, description };
9115
+ }
9116
+ return { label: String(option) };
9117
+ }
9108
9118
  var defaultStrings = {
9109
9119
  approve: "Approve",
9110
9120
  reject: "Reject",
@@ -9230,7 +9240,7 @@ var HitlCard = (0, import_react24.memo)(function HitlCard2({
9230
9240
  return;
9231
9241
  }
9232
9242
  if (hasOptions) {
9233
- const selectedAnswers = selectedIndices.map((i) => interrupt.options[i]).join(", ");
9243
+ const selectedAnswers = selectedIndices.map((i) => parseOption(interrupt.options[i]).label).join(", ");
9234
9244
  onSubmit?.({
9235
9245
  answer: selectedAnswers,
9236
9246
  selected_indices: selectedIndices
@@ -9267,6 +9277,7 @@ var HitlCard = (0, import_react24.memo)(function HitlCard2({
9267
9277
  width: "1.125rem",
9268
9278
  height: "1.125rem",
9269
9279
  margin: 0,
9280
+ marginTop: "0.125rem",
9270
9281
  flexShrink: 0
9271
9282
  };
9272
9283
  const cardStyle = {
@@ -9370,11 +9381,12 @@ var HitlCard = (0, import_react24.memo)(function HitlCard2({
9370
9381
  ] }),
9371
9382
  isUserInput && interrupt.options && interrupt.options.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "space-y-1.5", children: interrupt.options.map((option, index) => {
9372
9383
  const isSelected = selectedIndices.includes(index);
9384
+ const { label: optLabel, description: optDesc } = parseOption(option);
9373
9385
  const optionStyle = isSelected ? isDarkMode ? { borderColor: "rgba(96, 165, 250, 0.75)", background: "rgba(59, 130, 246, 0.24)" } : { borderColor: "rgba(37, 99, 235, 0.36)", background: "rgba(239, 246, 255, 0.98)" } : isDarkMode ? { borderColor: "rgba(113, 113, 122, 0.6)", background: "rgba(9, 9, 11, 0.84)" } : { borderColor: "rgba(113, 113, 122, 0.34)", background: "rgba(250, 250, 250, 0.96)" };
9374
9386
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
9375
9387
  "label",
9376
9388
  {
9377
- className: `flex cursor-pointer items-center gap-2 rounded p-2 transition-colors ${isSelected ? isDarkMode ? "border-blue-500/50 bg-blue-500/20" : "border-blue-200 bg-blue-50" : `${inputBg} border-transparent hover:border-zinc-300`} border`,
9389
+ className: `flex cursor-pointer items-start gap-2 rounded p-2 transition-colors ${isSelected ? isDarkMode ? "border-blue-500/50 bg-blue-500/20" : "border-blue-200 bg-blue-50" : `${inputBg} border-transparent hover:border-zinc-300`} border`,
9378
9390
  style: optionStyle,
9379
9391
  children: [
9380
9392
  /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
@@ -9387,7 +9399,10 @@ var HitlCard = (0, import_react24.memo)(function HitlCard2({
9387
9399
  style: optionControlStyle
9388
9400
  }
9389
9401
  ),
9390
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: `text-sm ${textPrimary} break-words ${isSelected ? "font-semibold" : "font-medium"}`, children: option })
9402
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { className: "min-w-0 break-words", children: [
9403
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: `text-sm ${textPrimary} ${isSelected ? "font-semibold" : "font-medium"}`, children: optLabel }),
9404
+ optDesc && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: `block text-xs ${textSecondary} mt-0.5 leading-snug`, children: optDesc })
9405
+ ] })
9391
9406
  ]
9392
9407
  },
9393
9408
  index
@@ -9033,6 +9033,16 @@ var ChatInput = memo7(
9033
9033
  // src/renderer/components/HitlCard.tsx
9034
9034
  import { memo as memo8, useState as useState15, useEffect as useEffect18, useRef as useRef10 } from "react";
9035
9035
  import { jsx as jsx12, jsxs as jsxs6 } from "react/jsx-runtime";
9036
+ function parseOption(option) {
9037
+ if (typeof option === "string") return { label: option };
9038
+ if (option && typeof option === "object") {
9039
+ const obj = option;
9040
+ const label = (typeof obj.label === "string" ? obj.label : void 0) ?? (typeof obj.name === "string" ? obj.name : void 0) ?? JSON.stringify(option);
9041
+ const description = typeof obj.description === "string" ? obj.description : void 0;
9042
+ return { label, description };
9043
+ }
9044
+ return { label: String(option) };
9045
+ }
9036
9046
  var defaultStrings = {
9037
9047
  approve: "Approve",
9038
9048
  reject: "Reject",
@@ -9158,7 +9168,7 @@ var HitlCard = memo8(function HitlCard2({
9158
9168
  return;
9159
9169
  }
9160
9170
  if (hasOptions) {
9161
- const selectedAnswers = selectedIndices.map((i) => interrupt.options[i]).join(", ");
9171
+ const selectedAnswers = selectedIndices.map((i) => parseOption(interrupt.options[i]).label).join(", ");
9162
9172
  onSubmit?.({
9163
9173
  answer: selectedAnswers,
9164
9174
  selected_indices: selectedIndices
@@ -9195,6 +9205,7 @@ var HitlCard = memo8(function HitlCard2({
9195
9205
  width: "1.125rem",
9196
9206
  height: "1.125rem",
9197
9207
  margin: 0,
9208
+ marginTop: "0.125rem",
9198
9209
  flexShrink: 0
9199
9210
  };
9200
9211
  const cardStyle = {
@@ -9298,11 +9309,12 @@ var HitlCard = memo8(function HitlCard2({
9298
9309
  ] }),
9299
9310
  isUserInput && interrupt.options && interrupt.options.length > 0 && /* @__PURE__ */ jsx12("div", { className: "space-y-1.5", children: interrupt.options.map((option, index) => {
9300
9311
  const isSelected = selectedIndices.includes(index);
9312
+ const { label: optLabel, description: optDesc } = parseOption(option);
9301
9313
  const optionStyle = isSelected ? isDarkMode ? { borderColor: "rgba(96, 165, 250, 0.75)", background: "rgba(59, 130, 246, 0.24)" } : { borderColor: "rgba(37, 99, 235, 0.36)", background: "rgba(239, 246, 255, 0.98)" } : isDarkMode ? { borderColor: "rgba(113, 113, 122, 0.6)", background: "rgba(9, 9, 11, 0.84)" } : { borderColor: "rgba(113, 113, 122, 0.34)", background: "rgba(250, 250, 250, 0.96)" };
9302
9314
  return /* @__PURE__ */ jsxs6(
9303
9315
  "label",
9304
9316
  {
9305
- className: `flex cursor-pointer items-center gap-2 rounded p-2 transition-colors ${isSelected ? isDarkMode ? "border-blue-500/50 bg-blue-500/20" : "border-blue-200 bg-blue-50" : `${inputBg} border-transparent hover:border-zinc-300`} border`,
9317
+ className: `flex cursor-pointer items-start gap-2 rounded p-2 transition-colors ${isSelected ? isDarkMode ? "border-blue-500/50 bg-blue-500/20" : "border-blue-200 bg-blue-50" : `${inputBg} border-transparent hover:border-zinc-300`} border`,
9306
9318
  style: optionStyle,
9307
9319
  children: [
9308
9320
  /* @__PURE__ */ jsx12(
@@ -9315,7 +9327,10 @@ var HitlCard = memo8(function HitlCard2({
9315
9327
  style: optionControlStyle
9316
9328
  }
9317
9329
  ),
9318
- /* @__PURE__ */ jsx12("span", { className: `text-sm ${textPrimary} break-words ${isSelected ? "font-semibold" : "font-medium"}`, children: option })
9330
+ /* @__PURE__ */ jsxs6("span", { className: "min-w-0 break-words", children: [
9331
+ /* @__PURE__ */ jsx12("span", { className: `text-sm ${textPrimary} ${isSelected ? "font-semibold" : "font-medium"}`, children: optLabel }),
9332
+ optDesc && /* @__PURE__ */ jsx12("span", { className: `block text-xs ${textSecondary} mt-0.5 leading-snug`, children: optDesc })
9333
+ ] })
9319
9334
  ]
9320
9335
  },
9321
9336
  index
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yushaw/sanqian-chat",
3
- "version": "0.3.5",
3
+ "version": "0.3.6",
4
4
  "description": "Floating chat window SDK for Sanqian AI Assistant",
5
5
  "main": "./dist/main/index.js",
6
6
  "types": "./dist/main/index.d.ts",