@harborclient/sdk 1.3.4 → 1.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.
Files changed (58) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/components/Breadcrumb/SegmentShell.d.ts +12 -1
  3. package/dist/components/Breadcrumb/SegmentShell.d.ts.map +1 -1
  4. package/dist/components/Breadcrumb/SegmentShell.js +7 -5
  5. package/dist/components/Button/index.d.ts +2 -2
  6. package/dist/components/Button/index.d.ts.map +1 -1
  7. package/dist/components/Button/index.js +2 -1
  8. package/dist/components/CodeEditor/index.d.ts +7 -4
  9. package/dist/components/CodeEditor/index.d.ts.map +1 -1
  10. package/dist/components/CodeEditor/index.js +15 -176
  11. package/dist/components/CodeEditor/selectionActionToolbar.d.ts +162 -0
  12. package/dist/components/CodeEditor/selectionActionToolbar.d.ts.map +1 -0
  13. package/dist/components/CodeEditor/selectionActionToolbar.js +319 -0
  14. package/dist/components/CopyToChatButton/constants.d.ts +18 -0
  15. package/dist/components/CopyToChatButton/constants.d.ts.map +1 -0
  16. package/dist/components/CopyToChatButton/constants.js +19 -0
  17. package/dist/components/CopyToChatButton/index.d.ts +49 -0
  18. package/dist/components/CopyToChatButton/index.d.ts.map +1 -0
  19. package/dist/components/CopyToChatButton/index.js +43 -0
  20. package/dist/components/FloatingDialog/floatingDialogPosition.d.ts +52 -0
  21. package/dist/components/FloatingDialog/floatingDialogPosition.d.ts.map +1 -0
  22. package/dist/components/FloatingDialog/floatingDialogPosition.js +33 -0
  23. package/dist/components/FloatingDialog/index.d.ts +99 -0
  24. package/dist/components/FloatingDialog/index.d.ts.map +1 -0
  25. package/dist/components/FloatingDialog/index.js +279 -0
  26. package/dist/components/PageHeader/index.d.ts +2 -1
  27. package/dist/components/PageHeader/index.d.ts.map +1 -1
  28. package/dist/components/PageHeader/index.js +3 -2
  29. package/dist/components/SidebarItem/SidebarEnvironmentItem.d.ts +42 -4
  30. package/dist/components/SidebarItem/SidebarEnvironmentItem.d.ts.map +1 -1
  31. package/dist/components/SidebarItem/SidebarEnvironmentItem.js +34 -5
  32. package/dist/components/SidebarItem/SidebarRequestItem.d.ts +5 -1
  33. package/dist/components/SidebarItem/SidebarRequestItem.d.ts.map +1 -1
  34. package/dist/components/SidebarItem/SidebarRequestItem.js +2 -2
  35. package/dist/components/SidebarItem/SidebarWorkspaceItem.d.ts +9 -1
  36. package/dist/components/SidebarItem/SidebarWorkspaceItem.d.ts.map +1 -1
  37. package/dist/components/SidebarItem/SidebarWorkspaceItem.js +15 -2
  38. package/dist/components/TabBar/TabContextMenu.d.ts +3 -0
  39. package/dist/components/TabBar/TabContextMenu.d.ts.map +1 -1
  40. package/dist/components/TabBar/TabContextMenu.js +25 -16
  41. package/dist/components/VariableTable/index.d.ts +1 -1
  42. package/dist/components/VariableTable/index.d.ts.map +1 -1
  43. package/dist/components/VariableTable/index.js +14 -3
  44. package/dist/components/index.d.ts +4 -2
  45. package/dist/components/index.d.ts.map +1 -1
  46. package/dist/components/index.js +3 -1
  47. package/dist/runtime/createBridgedPluginContext.js +74 -0
  48. package/dist/snippets.d.ts +26 -2
  49. package/dist/styles.css +16 -0
  50. package/dist/types.d.ts +273 -1
  51. package/dist/types.d.ts.map +1 -1
  52. package/dist/ui/index.d.ts +1 -0
  53. package/dist/ui/index.d.ts.map +1 -1
  54. package/dist/ui/index.js +1 -0
  55. package/package.json +1 -1
  56. package/dist/components/SelectionActionToolbar/index.d.ts +0 -41
  57. package/dist/components/SelectionActionToolbar/index.d.ts.map +0 -1
  58. package/dist/components/SelectionActionToolbar/index.js +0 -13
package/CHANGELOG.md CHANGED
@@ -4,6 +4,24 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  ## Unreleased
6
6
 
7
+ ## 1.3.6 - 2026-07-29
8
+
9
+ - Enhance Response Editor and Summary with Close Functionality. (`e14d7c7d`)
10
+
11
+ ## 1.3.5 - 2026-07-28
12
+
13
+ - Enhance CLI and GUI workflow functionalities. (`a8b8f495`)
14
+ - Enhance workflow results management and response handling. (`6a092e2e`)
15
+ - Add delayMs property to workflow management for enhanced playback control. (`eff9c395`)
16
+ - Enhance workflow execution and metadata handling. (`1390072c`)
17
+ - Enhance workflow action management with UUID integration. (`9647b650`)
18
+ - Enhance workflow management and plugin integration. (`e55d2821`)
19
+ - Implement workflow update functionality and enhance playback controls. (`443b20ec`)
20
+ - Enhance environment variable management and UI readiness. (`abab021c`)
21
+ - Update variable schema and enhance environment management. (`34cc08f0`)
22
+ - Add workspace management features to routing and state management. (`2bb3eb22`)
23
+ - Implement workflow management features. (`a4525074`)
24
+
7
25
  ## 1.3.4 - 2026-07-28
8
26
 
9
27
  - Implement hc.ask API for one-shot AI completions. (`aed2809f`)
@@ -9,6 +9,13 @@ export type SegmentShape = 'first' | 'middle' | 'last' | 'only';
9
9
  * request-name crumb.
10
10
  */
11
11
  export type SegmentTone = 'path' | 'selection' | 'current';
12
+ /**
13
+ * Vertical and horizontal density for a segment shell.
14
+ *
15
+ * - `default` — full breadcrumb bar sizing (`min-h-[26px]`, generous padding).
16
+ * - `compact` — toolbar-height sizing for controls like Copy to chat.
17
+ */
18
+ export type SegmentDensity = 'default' | 'compact';
12
19
  /**
13
20
  * Shared shell classes and clip-path styling for one breadcrumb segment.
14
21
  */
@@ -26,6 +33,10 @@ interface Props {
26
33
  * When true, the segment grows to fill remaining horizontal space.
27
34
  */
28
35
  grow?: boolean;
36
+ /**
37
+ * Vertical and horizontal density. Defaults to full breadcrumb bar sizing.
38
+ */
39
+ density?: SegmentDensity;
29
40
  /**
30
41
  * Additional classes merged onto the segment shell.
31
42
  */
@@ -42,6 +53,6 @@ interface Props {
42
53
  * full) edge can be pill-capped like the URL bar; middle and last keep a single
43
54
  * clip-path layer for chevron interlocking.
44
55
  */
45
- export declare function SegmentShell({ shape, tone, grow, className, children }: Props): JSX.Element;
56
+ export declare function SegmentShell({ shape, tone, grow, density, className, children }: Props): JSX.Element;
46
57
  export {};
47
58
  //# sourceMappingURL=SegmentShell.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SegmentShell.d.ts","sourceRoot":"","sources":["../../../src/components/Breadcrumb/SegmentShell.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAM5C;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;AAEhE;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,WAAW,GAAG,SAAS,CAAC;AAsB3D;;GAEG;AACH,UAAU,KAAK;IACb;;OAEG;IACH,KAAK,EAAE,YAAY,CAAC;IAEpB;;;OAGG;IACH,IAAI,CAAC,EAAE,WAAW,CAAC;IAEnB;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IAEf;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,EAC3B,KAAK,EACL,IAAa,EACb,IAAY,EACZ,SAAS,EACT,QAAQ,EACT,EAAE,KAAK,GAAG,GAAG,CAAC,OAAO,CAsDrB"}
1
+ {"version":3,"file":"SegmentShell.d.ts","sourceRoot":"","sources":["../../../src/components/Breadcrumb/SegmentShell.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAM5C;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;AAEhE;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,WAAW,GAAG,SAAS,CAAC;AAE3D;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,SAAS,CAAC;AAsBnD;;GAEG;AACH,UAAU,KAAK;IACb;;OAEG;IACH,KAAK,EAAE,YAAY,CAAC;IAEpB;;;OAGG;IACH,IAAI,CAAC,EAAE,WAAW,CAAC;IAEnB;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IAEf;;OAEG;IACH,OAAO,CAAC,EAAE,cAAc,CAAC;IAEzB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,EAC3B,KAAK,EACL,IAAa,EACb,IAAY,EACZ,OAAmB,EACnB,SAAS,EACT,QAAQ,EACT,EAAE,KAAK,GAAG,GAAG,CAAC,OAAO,CAkErB"}
@@ -28,23 +28,25 @@ function clipPathForShape(shape) {
28
28
  * full) edge can be pill-capped like the URL bar; middle and last keep a single
29
29
  * clip-path layer for chevron interlocking.
30
30
  */
31
- export function SegmentShell({ shape, tone = 'path', grow = false, className, children }) {
31
+ export function SegmentShell({ shape, tone = 'path', grow = false, density = 'default', className, children }) {
32
32
  const hasChevron = shape !== 'only';
33
33
  const clipPath = clipPathForShape(shape);
34
34
  const needsLeadingInset = shape !== 'first' && shape !== 'only';
35
+ const isCompact = density === 'compact';
35
36
  const toneClass = tone === 'current'
36
37
  ? 'bg-breadcrumb-current'
37
38
  : tone === 'selection'
38
39
  ? 'bg-selection'
39
40
  : 'bg-breadcrumb-segment';
40
41
  const usesPillCap = shape === 'first' || shape === 'only';
41
- const layoutClass = cn('hc-breadcrumb-segment relative flex min-h-[26px] min-w-0 items-center py-2', grow ? 'min-w-[6rem] flex-1' : 'max-w-[45%] shrink-0', hasChevron && shape !== 'last' && '-mr-[6px]', !needsLeadingInset && 'pl-5', 'pr-5', className);
42
- const content = _jsx("div", { className: "relative w-full min-w-0 truncate", children: children });
42
+ const leadingInsetPx = CHEVRON_PX + (isCompact ? 10 : 16);
43
+ const layoutClass = cn('hc-breadcrumb-segment relative flex min-w-0 items-center', isCompact ? 'min-h-0 py-1' : 'min-h-[26px] py-2', grow ? 'min-w-[6rem] flex-1' : isCompact ? 'shrink-0' : 'max-w-[45%] shrink-0', hasChevron && shape !== 'last' && '-mr-[6px]', !needsLeadingInset && (isCompact ? 'pl-2.5' : 'pl-5'), isCompact ? 'pr-3' : 'pr-5', className);
44
+ const content = (_jsx("div", { className: cn('relative min-w-0', isCompact ? 'flex items-center gap-1.5' : 'w-full truncate'), children: children }));
43
45
  if (usesPillCap) {
44
- return (_jsxs("div", { className: cn(layoutClass, 'overflow-hidden', shape === 'only' ? 'rounded-full!' : 'rounded-lg!'), style: needsLeadingInset ? { paddingLeft: `${CHEVRON_PX + 16}px` } : undefined, children: [_jsx("div", { "aria-hidden": true, className: cn('pointer-events-none absolute inset-0', toneClass), style: clipPath !== 'none' ? { clipPath } : undefined }), content] }));
46
+ return (_jsxs("div", { className: cn(layoutClass, 'overflow-hidden', shape === 'only' ? 'rounded-full!' : 'rounded-lg!'), style: needsLeadingInset ? { paddingLeft: `${leadingInsetPx}px` } : undefined, children: [_jsx("div", { "aria-hidden": true, className: cn('pointer-events-none absolute inset-0', toneClass), style: clipPath !== 'none' ? { clipPath } : undefined }), content] }));
45
47
  }
46
48
  return (_jsx("div", { className: cn(layoutClass, toneClass), style: {
47
49
  ...(clipPath !== 'none' ? { clipPath } : {}),
48
- ...(needsLeadingInset ? { paddingLeft: `${CHEVRON_PX + 16}px` } : {})
50
+ ...(needsLeadingInset ? { paddingLeft: `${leadingInsetPx}px` } : {})
49
51
  }, children: content }));
50
52
  }
@@ -2,7 +2,7 @@ import type { ComponentPropsWithoutRef, JSX, RefObject } from 'react';
2
2
  /**
3
3
  * Visual style for a macOS-style button.
4
4
  */
5
- export type ButtonVariant = 'primary' | 'secondary' | 'primaryDanger' | 'secondaryDanger' | 'toolbar' | 'icon' | 'iconDanger';
5
+ export type ButtonVariant = 'primary' | 'secondary' | 'primaryDanger' | 'primarySuccess' | 'secondaryDanger' | 'toolbar' | 'icon' | 'iconDanger';
6
6
  type IconButtonVariant = 'icon' | 'iconDanger';
7
7
  type AccessibleName = {
8
8
  'aria-label': string;
@@ -28,7 +28,7 @@ export type ButtonProps = (BaseProps & {
28
28
  });
29
29
  /**
30
30
  * macOS-style button with shared variant presets for primary actions, secondary
31
- * actions, toolbar controls, and icon-only controls.
31
+ * actions, danger/success emphasis, toolbar controls, and icon-only controls.
32
32
  *
33
33
  * Defaults to `type="button"` so clicks do not accidentally submit a parent form.
34
34
  * Pass `type="submit"` explicitly when submit behavior is intended.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Button/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGtE;;GAEG;AACH,MAAM,MAAM,aAAa,GACrB,SAAS,GACT,WAAW,GACX,eAAe,GACf,iBAAiB,GACjB,SAAS,GACT,MAAM,GACN,YAAY,CAAC;AAEjB,KAAK,iBAAiB,GAAG,MAAM,GAAG,YAAY,CAAC;AAE/C,KAAK,cAAc,GACf;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,iBAAiB,CAAC,EAAE,SAAS,CAAA;CAAE,GACvD;IAAE,iBAAiB,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,SAAS,CAAA;CAAE,CAAC;AAE5D,KAAK,SAAS,GAAG,IAAI,CACnB,wBAAwB,CAAC,QAAQ,CAAC,EAClC,YAAY,GAAG,iBAAiB,GAAG,KAAK,CACzC,GAAG;IACF;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC;CAChD,CAAC;AAEF,MAAM,MAAM,WAAW,GACnB,CAAC,SAAS,GAAG;IAAE,OAAO,EAAE,iBAAiB,CAAA;CAAE,GAAG,cAAc,CAAC,GAC7D,CAAC,S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iB,CAAC,CAAA;CAAE,CAAC,CAAC;AAuC1E;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAAC,EACrB,OAAmB,EACnB,SAAS,EACT,IAAe,EACf,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,WAAW,GAAG,GAAG,CAAC,OAAO,CAS3B"}
@@ -5,6 +5,7 @@ const VARIANT_CLASSES = {
5
5
  primary: cn(BUTTON_BASE, 'min-h-[32px] justify-center border border-transparent bg-accent px-3 py-1 text-[15px] font-medium text-white shadow-sm hover:brightness-110 disabled:cursor-not-allowed disabled:opacity-50'),
6
6
  secondary: cn(BUTTON_BASE, 'min-h-[32px] justify-center border border-separator bg-control px-3 py-1 text-[15px] text-text shadow-sm hover:bg-selection disabled:cursor-not-allowed disabled:opacity-50'),
7
7
  primaryDanger: cn(BUTTON_BASE, 'min-h-[32px] justify-center border border-transparent bg-danger px-3 py-1 text-[15px] font-medium text-white shadow-sm hover:brightness-110 disabled:cursor-not-allowed disabled:opacity-50'),
8
+ primarySuccess: cn(BUTTON_BASE, 'min-h-[32px] justify-center border border-transparent bg-success px-3 py-1 text-[15px] font-medium text-white shadow-sm hover:brightness-110 disabled:cursor-not-allowed disabled:opacity-50'),
8
9
  secondaryDanger: cn(BUTTON_BASE, 'min-h-[32px] justify-center border border-separator bg-control px-3 py-1 text-[15px] text-danger shadow-sm hover:bg-danger/15 disabled:cursor-not-allowed disabled:opacity-50'),
9
10
  toolbar: cn(BUTTON_BASE, 'min-h-[32px] border-none bg-transparent px-2 py-1 text-[15px] hover:bg-selection'),
10
11
  icon: cn(BUTTON_BASE, 'size-[30px] shrink-0 justify-center border-none bg-transparent text-muted hover:bg-selection hover:text-text'),
@@ -12,7 +13,7 @@ const VARIANT_CLASSES = {
12
13
  };
13
14
  /**
14
15
  * macOS-style button with shared variant presets for primary actions, secondary
15
- * actions, toolbar controls, and icon-only controls.
16
+ * actions, danger/success emphasis, toolbar controls, and icon-only controls.
16
17
  *
17
18
  * Defaults to `type="button"` so clicks do not accidentally submit a parent form.
18
19
  * Pass `type="submit"` explicitly when submit behavior is intended.
@@ -118,12 +118,15 @@ export interface CodeEditorTextSelection {
118
118
  export interface CodeEditorSelectionAction {
119
119
  /**
120
120
  * Stable action id for host routing.
121
+ *
122
+ * When `id` is `copy-to-chat`, the toolbar renders {@link CopyToChatButton} and
123
+ * ignores `label`, `icon`, and `shortcutHint`.
121
124
  */
122
125
  id: string;
123
126
  /**
124
- * Visible button label.
127
+ * Visible button label for non–copy-to-chat actions.
125
128
  */
126
- label: string;
129
+ label?: string;
127
130
  /**
128
131
  * Accessible name for the action button.
129
132
  */
@@ -133,11 +136,11 @@ export interface CodeEditorSelectionAction {
133
136
  */
134
137
  onSelect: (selection: CodeEditorTextSelection) => void;
135
138
  /**
136
- * Optional leading icon shown before the action label.
139
+ * Optional leading icon shown before the action label for non–copy-to-chat actions.
137
140
  */
138
141
  icon?: IconDefinition;
139
142
  /**
140
- * Optional shortcut hint shown after the label (for example `Ctrl+L`).
143
+ * Optional shortcut hint shown after the label for non–copy-to-chat actions.
141
144
  */
142
145
  shortcutHint?: string;
143
146
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/CodeEditor/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAmC,MAAM,0BAA0B,CAAC;AAkBlG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAWxE,OAAO,KAAK,EAAE,wBAAwB,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAWjF,OAAO,EAAE,KAAK,oBAAoB,EAA+B,MAAM,sBAAsB,CAAC;AAM9F,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AACxD,YAAY,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,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orFontSize } from '../../ui/codeEditorSettings.js';
15
15
  import { VARIABLE_NAME_CHARS, getVariableTooltipContent } from '../../variables/index.js';
16
16
  import { Button } from '../Button/index.js';
17
+ import { CopyToChatButton } from '../CopyToChatButton/index.js';
17
18
  import { FaIcon } from '../FaIcon/index.js';
18
19
  import { buildVariableTooltipDom } from '../VariableTooltip/dom.js';
19
20
  import { VariableTooltipValue } from '../VariableTooltip/index.js';
@@ -21,6 +22,7 @@ import { portalToBody } from '../portalToBody.js';
21
22
  import { useCodeEditorConfig } from './config.js';
22
23
  import { createBuiltInSyntaxHighlighting, createEditorTheme } from './editorChrome.js';
23
24
  import { createHostDiagnosticsLinter } from './hostDiagnostics.js';
25
+ import { createSelectionActionToolbarExtensions } from './selectionActionToolbar.js';
24
26
  import { createSlashCommandHighlighter } from './slashCommandHighlighter.js';
25
27
  import { createSyntaxHighlightedPlaceholder } from './syntaxHighlightedPlaceholder.js';
26
28
  import { createJavascriptSyntaxLinter, createJsonSyntaxLinter } from './syntaxLinters.js';
@@ -40,8 +42,6 @@ function clampSelection(docLength, selection) {
40
42
  }
41
43
  /** Debounce interval for {@link Props.onViewStateChange} notifications. */
42
44
  const VIEW_STATE_DEBOUNCE_MS = 300;
43
- /** Delay before showing the selection action toolbar after selection settles. */
44
- const SELECTION_TOOLBAR_SHOW_DELAY_MS = 450;
45
45
  /** Extra viewport gap between the selection top edge and the portaled toolbar. */
46
46
  const SELECTION_TOOLBAR_OFFSET_PX = 16;
47
47
  const variableMatcher = new MatchDecorator({
@@ -260,176 +260,6 @@ function variableTooltipEscapeHandler(isOpen, onDismiss, getValidationDescribedB
260
260
  }
261
261
  });
262
262
  }
263
- /**
264
- * Computes viewport anchor coordinates for the selection action toolbar.
265
- *
266
- * @param view - CodeMirror editor view.
267
- * @param selectionFrom - Start offset (inclusive) of the selection.
268
- * @param selectionTo - End offset (exclusive) of the selection.
269
- * @returns Toolbar anchor position, or null when coords are unavailable.
270
- */
271
- function computeSelectionActionToolbarCoords(view, selectionFrom, selectionTo) {
272
- const startCoords = view.coordsAtPos(selectionFrom);
273
- if (!startCoords) {
274
- return null;
275
- }
276
- const endCoords = view.coordsAtPos(selectionTo);
277
- const startCenter = startCoords.left + (startCoords.right - startCoords.left) / 2;
278
- const endCenter = endCoords
279
- ? endCoords.left + (endCoords.right - endCoords.left) / 2
280
- : startCenter;
281
- return {
282
- top: startCoords.top,
283
- left: (startCenter + endCenter) / 2
284
- };
285
- }
286
- /**
287
- * Builds update and pointer handlers that debounce toolbar display until selection settles.
288
- */
289
- function createSelectionActionToolbarExtensions(onToolbarChange, isEnabled, isOpen, onDismiss) {
290
- const controller = {
291
- showTimer: undefined,
292
- isPointerSelecting: false,
293
- isToolbarOpen: false,
294
- pendingState: null
295
- };
296
- /**
297
- * Clears a scheduled toolbar reveal without changing open state.
298
- */
299
- const clearShowTimer = () => {
300
- if (controller.showTimer) {
301
- clearTimeout(controller.showTimer);
302
- controller.showTimer = undefined;
303
- }
304
- };
305
- /**
306
- * Notifies React of toolbar visibility while keeping controller state in sync.
307
- */
308
- const notifyToolbarChange = (state) => {
309
- controller.isToolbarOpen = state != null;
310
- if (state == null) {
311
- controller.pendingState = null;
312
- }
313
- onToolbarChange(state);
314
- };
315
- /**
316
- * Hides the toolbar immediately and cancels any pending reveal.
317
- */
318
- const dismissToolbar = () => {
319
- clearShowTimer();
320
- if (controller.isToolbarOpen || controller.pendingState != null) {
321
- notifyToolbarChange(null);
322
- }
323
- };
324
- /**
325
- * Schedules toolbar display after the configured settle delay.
326
- */
327
- const scheduleShow = (state) => {
328
- controller.pendingState = state;
329
- clearShowTimer();
330
- if (controller.isPointerSelecting) {
331
- return;
332
- }
333
- controller.showTimer = setTimeout(() => {
334
- controller.showTimer = undefined;
335
- if (controller.isPointerSelecting) {
336
- return;
337
- }
338
- notifyToolbarChange(state);
339
- }, SELECTION_TOOLBAR_SHOW_DELAY_MS);
340
- };
341
- /**
342
- * Repositions or reveals the toolbar without waiting when it is already open.
343
- */
344
- const showImmediately = (state) => {
345
- clearShowTimer();
346
- notifyToolbarChange(state);
347
- };
348
- const updateListener = EditorView.updateListener.of((update) => {
349
- if (!isEnabled()) {
350
- dismissToolbar();
351
- return;
352
- }
353
- if (!update.selectionSet && !update.docChanged && !update.viewportChanged) {
354
- return;
355
- }
356
- const { from, to } = update.state.selection.main;
357
- if (from === to) {
358
- dismissToolbar();
359
- return;
360
- }
361
- const selectionFrom = Math.min(from, to);
362
- const selectionTo = Math.max(from, to);
363
- const text = update.state.sliceDoc(selectionFrom, selectionTo);
364
- if (!text.trim()) {
365
- dismissToolbar();
366
- return;
367
- }
368
- const coords = computeSelectionActionToolbarCoords(update.view, selectionFrom, selectionTo);
369
- if (!coords) {
370
- dismissToolbar();
371
- return;
372
- }
373
- const nextState = {
374
- top: coords.top,
375
- left: coords.left,
376
- text,
377
- from: selectionFrom,
378
- to: selectionTo
379
- };
380
- if (isOpen() && !update.selectionSet && update.viewportChanged) {
381
- showImmediately(nextState);
382
- return;
383
- }
384
- if (isOpen() && update.selectionSet) {
385
- scheduleShow(nextState);
386
- return;
387
- }
388
- scheduleShow(nextState);
389
- });
390
- const pointerGuard = EditorView.domEventHandlers({
391
- /**
392
- * Suppresses toolbar reveal while the user is drag-selecting with the primary button.
393
- */
394
- pointerdown(event) {
395
- if (event.button === 0) {
396
- controller.isPointerSelecting = true;
397
- clearShowTimer();
398
- }
399
- return false;
400
- },
401
- /**
402
- * Resumes debounced reveal after drag-select completes.
403
- */
404
- pointerup() {
405
- controller.isPointerSelecting = false;
406
- if (controller.pendingState != null && !isOpen()) {
407
- scheduleShow(controller.pendingState);
408
- }
409
- return false;
410
- }
411
- });
412
- const dismissHandler = EditorView.domEventHandlers({
413
- keydown(event) {
414
- if (event.key === 'Escape' && isOpen()) {
415
- event.preventDefault();
416
- dismissToolbar();
417
- onDismiss();
418
- return true;
419
- }
420
- return false;
421
- }
422
- });
423
- const cleanupPlugin = ViewPlugin.fromClass(class {
424
- /**
425
- * Clears any pending toolbar reveal when the editor extension is destroyed.
426
- */
427
- destroy() {
428
- clearShowTimer();
429
- }
430
- });
431
- return [updateListener, pointerGuard, dismissHandler, cleanupPlugin];
432
- }
433
263
  /**
434
264
  * Registers keyboard shortcuts for selection toolbar actions.
435
265
  *
@@ -1157,16 +987,25 @@ export function CodeEditor({ value, onChange, language = 'text', readOnly = fals
1157
987
  const selectionActionToolbarNode = selectionActionToolbar && hasSelectionActions ? (_jsx("div", { ref: selectionToolbarElementRef, role: "toolbar", "aria-label": "Selection actions", className: "hc-code-editor-selection-toolbar app-no-drag pointer-events-auto fixed z-50 flex -translate-x-1/2 -translate-y-full items-center gap-1 bg-transparent p-0 text-[14px] text-text", style: {
1158
988
  top: selectionActionToolbar.top - SELECTION_TOOLBAR_OFFSET_PX,
1159
989
  left: selectionActionToolbar.left
1160
- }, children: activeSelectionActions.map((action) => (_jsxs("button", { type: "button", className: "hc-code-editor-selection-action inline-flex cursor-pointer items-center gap-1.5 rounded-md border border-separator bg-control px-2 py-1 text-[14px] text-text shadow-sm hover:bg-surface focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-accent", "aria-label": action.ariaLabel, onMouseDown: (event) => {
1161
- event.preventDefault();
1162
- }, onClick: () => {
990
+ }, children: activeSelectionActions.map((action) => {
991
+ /**
992
+ * Runs the selection action and dismisses the floating toolbar.
993
+ */
994
+ const handleSelect = () => {
1163
995
  action.onSelect({
1164
996
  text: selectionActionToolbar.text,
1165
997
  from: selectionActionToolbar.from,
1166
998
  to: selectionActionToolbar.to
1167
999
  });
1168
1000
  setSelectionActionToolbar(null);
1169
- }, children: [action.icon ? _jsx(FaIcon, { icon: action.icon, className: "h-3.5 w-3.5" }) : null, _jsx("span", { children: action.label }), action.shortcutHint ? (_jsx("span", { className: "text-[14px] text-muted", children: action.shortcutHint })) : null] }, action.id))) })) : null;
1001
+ };
1002
+ if (action.id === 'copy-to-chat') {
1003
+ return (_jsx(CopyToChatButton, { appearance: "labeled", "aria-label": action.ariaLabel, onSelect: handleSelect }, action.id));
1004
+ }
1005
+ return (_jsxs("button", { type: "button", className: "hc-code-editor-selection-action inline-flex cursor-pointer items-center gap-1.5 rounded-md border border-separator bg-control px-2 py-1 text-[14px] text-text shadow-sm hover:bg-surface focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-accent", "aria-label": action.ariaLabel, onMouseDown: (event) => {
1006
+ event.preventDefault();
1007
+ }, onClick: handleSelect, children: [action.icon ? _jsx(FaIcon, { icon: action.icon, className: "h-3.5 w-3.5" }) : null, action.label != null ? _jsx("span", { children: action.label }) : null, action.shortcutHint ? (_jsx("span", { className: "text-[14px] text-muted", children: action.shortcutHint })) : null] }, action.id));
1008
+ }) })) : null;
1170
1009
  return (_jsxs("div", { ref: wrapperRef, ...props, className: wrapperClassName, style: wrapperStyle, children: [createElement(CodeMirrorImport, {
1171
1010
  value,
1172
1011
  onChange: readOnly ? undefined : stableOnChange,
@@ -0,0 +1,162 @@
1
+ import type { Extension } from '@codemirror/state';
2
+ /** Delay before showing the selection action toolbar after selection settles. */
3
+ export declare const SELECTION_TOOLBAR_SHOW_DELAY_MS = 450;
4
+ /**
5
+ * Snapshot of a non-empty text selection used to position and drive the toolbar.
6
+ */
7
+ export interface SelectionActionToolbarState {
8
+ /**
9
+ * Viewport Y of the selection start (toolbar anchors above this).
10
+ */
11
+ top: number;
12
+ /**
13
+ * Viewport X midpoint between selection start and end.
14
+ */
15
+ left: number;
16
+ /**
17
+ * Selected document text.
18
+ */
19
+ text: string;
20
+ /**
21
+ * Start offset (inclusive) in the document.
22
+ */
23
+ from: number;
24
+ /**
25
+ * End offset (exclusive) in the document.
26
+ */
27
+ to: number;
28
+ }
29
+ /**
30
+ * Shared debounce and pointer-drag state for the selection action toolbar.
31
+ */
32
+ export interface SelectionActionToolbarController {
33
+ showTimer: ReturnType<typeof setTimeout> | undefined;
34
+ isPointerSelecting: boolean;
35
+ isToolbarOpen: boolean;
36
+ pendingState: SelectionActionToolbarState | null;
37
+ /**
38
+ * Last non-empty selection seen during a pointer drag. Survives gutter-induced
39
+ * collapse so the toolbar can still appear after RTL drag-select into the gutter.
40
+ */
41
+ lastNonEmptySelection: SelectionActionToolbarState | null;
42
+ /**
43
+ * When true, ignore collapsed-selection dismissals that race pointerup
44
+ * (CodeMirror may collapse into the gutter in the same event turn).
45
+ */
46
+ suppressCollapseDismiss: boolean;
47
+ }
48
+ /**
49
+ * Rect returned by {@link EditorView.coordsAtPos} (or a test double).
50
+ */
51
+ export interface SelectionToolbarCoords {
52
+ top: number;
53
+ left: number;
54
+ right: number;
55
+ bottom: number;
56
+ }
57
+ /**
58
+ * Minimal view surface used by toolbar helpers so unit tests can supply doubles
59
+ * without constructing a full CodeMirror {@link EditorView}.
60
+ */
61
+ export interface SelectionToolbarViewLike {
62
+ /**
63
+ * Resolves viewport coordinates for a document offset.
64
+ *
65
+ * @param pos - Document offset.
66
+ * @returns Screen rect, or null when the position is not measurable.
67
+ */
68
+ coordsAtPos: (pos: number) => SelectionToolbarCoords | null;
69
+ /**
70
+ * Document selection and slice accessors.
71
+ */
72
+ state: {
73
+ selection: {
74
+ main: {
75
+ from: number;
76
+ to: number;
77
+ };
78
+ };
79
+ sliceDoc: (from: number, to: number) => string;
80
+ };
81
+ }
82
+ /**
83
+ * Minimal view-update surface used by {@link applySelectionActionToolbarUpdate}.
84
+ */
85
+ export interface SelectionToolbarUpdateLike {
86
+ selectionSet: boolean;
87
+ docChanged: boolean;
88
+ viewportChanged: boolean;
89
+ view: SelectionToolbarViewLike;
90
+ state: SelectionToolbarViewLike['state'];
91
+ }
92
+ /**
93
+ * Computes viewport anchor coordinates for the selection action toolbar.
94
+ *
95
+ * @param view - CodeMirror editor view (or test double).
96
+ * @param selectionFrom - Start offset (inclusive) of the selection.
97
+ * @param selectionTo - End offset (exclusive) of the selection.
98
+ * @returns Toolbar anchor position, or null when coords are unavailable.
99
+ */
100
+ export declare function computeSelectionActionToolbarCoords(view: Pick<SelectionToolbarViewLike, 'coordsAtPos'>, selectionFrom: number, selectionTo: number): {
101
+ top: number;
102
+ left: number;
103
+ } | null;
104
+ /**
105
+ * Builds a toolbar snapshot from the current editor selection when it is usable.
106
+ *
107
+ * @param view - CodeMirror editor view (or test double).
108
+ * @returns Toolbar state, or null when the selection is empty, whitespace-only, or coords fail.
109
+ */
110
+ export declare function buildSelectionActionToolbarState(view: SelectionToolbarViewLike): SelectionActionToolbarState | null;
111
+ /**
112
+ * Creates a fresh controller used by the selection toolbar extensions and unit tests.
113
+ *
114
+ * @returns Mutable controller state for pointer-drag and debounce bookkeeping.
115
+ */
116
+ export declare function createSelectionActionToolbarController(): SelectionActionToolbarController;
117
+ /**
118
+ * Applies a view update to the selection toolbar controller.
119
+ *
120
+ * Encodes the RTL-gutter fix: collapsed selections during a pointer drag (or
121
+ * immediately after pointerup) do not dismiss a previously captured selection.
122
+ *
123
+ * @param controller - Shared toolbar controller.
124
+ * @param update - CodeMirror view update.
125
+ * @param options - Enable/open callbacks and notify/dismiss helpers.
126
+ * @returns Whether the toolbar should remain open after this update (for tests).
127
+ */
128
+ export declare function applySelectionActionToolbarUpdate(controller: SelectionActionToolbarController, update: SelectionToolbarUpdateLike, options: {
129
+ isEnabled: () => boolean;
130
+ isOpen: () => boolean;
131
+ notifyToolbarChange: (state: SelectionActionToolbarState | null) => void;
132
+ clearShowTimer: () => void;
133
+ scheduleShow: (state: SelectionActionToolbarState) => void;
134
+ showImmediately: (state: SelectionActionToolbarState) => void;
135
+ dismissToolbar: () => void;
136
+ }): void;
137
+ /**
138
+ * Finalizes the toolbar after a primary-button pointer drag ends.
139
+ *
140
+ * Prefers the live selection; falls back to {@link SelectionActionToolbarController.lastNonEmptySelection}
141
+ * so RTL releases into the gutter still reveal Copy to chat.
142
+ *
143
+ * @param controller - Shared toolbar controller.
144
+ * @param view - CodeMirror editor view at pointerup.
145
+ * @param options - Open check and show helpers.
146
+ */
147
+ export declare function finalizeSelectionActionToolbarOnPointerUp(controller: SelectionActionToolbarController, view: SelectionToolbarViewLike, options: {
148
+ isOpen: () => boolean;
149
+ scheduleShow: (state: SelectionActionToolbarState) => void;
150
+ showImmediately: (state: SelectionActionToolbarState) => void;
151
+ }): void;
152
+ /**
153
+ * Builds update and pointer handlers that debounce toolbar display until selection settles.
154
+ *
155
+ * @param onToolbarChange - React setter for toolbar visibility and position.
156
+ * @param isEnabled - Whether selection actions are currently configured.
157
+ * @param isOpen - Whether the toolbar is currently visible in React state.
158
+ * @param onDismiss - Extra host cleanup when Escape dismisses the toolbar.
159
+ * @returns CodeMirror extensions that drive the floating selection toolbar.
160
+ */
161
+ export declare function createSelectionActionToolbarExtensions(onToolbarChange: (state: SelectionActionToolbarState | null) => void, isEnabled: () => boolean, isOpen: () => boolean, onDismiss: () => void): Extension[];
162
+ //# sourceMappingURL=selectionActionToolbar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selectionActionToolbar.d.ts","sourceRoot":"","sources":["../../../src/components/CodeEditor/selectionActionToolbar.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAGnD,iFAAiF;AACjF,eAAO,MAAM,+BAA+B,MAAM,CAAC;AAEnD;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;CACZ;AAED;;GAEG;AACH,MAAM,WAAW,gCAAgC;IAC/C,SAAS,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,GAAG,SAAS,CAAC;IACrD,kBAAkB,EAAE,OAAO,CAAC;IAC5B,aAAa,EAAE,OAAO,CAAC;IACvB,YAAY,EAAE,2BAA2B,GAAG,IAAI,CAAC;IACjD;;;OAGG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