@design.estate/dees-catalog 23.2.0 → 23.4.0

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 (44) hide show
  1. package/dist_bundle/bundle.js +3033 -2785
  2. package/dist_bundle/bundle.js.map +1 -1
  3. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-T6MJ73SK.js → chunk-6M55MVYH.js} +3 -3
  4. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-I4IO5H5N.js → chunk-CM67HGUE.js} +2 -2
  5. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-74TRVA7N.js → chunk-QVHO2EIW.js} +3 -3
  6. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-74TRVA7N.js.map → chunk-QVHO2EIW.js.map} +1 -1
  7. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{de-OOMCZNLC.js → de-ZWMPLB5K.js} +3 -3
  8. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/de-ZWMPLB5K.js.map +1 -0
  9. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-modal-HUKGQIM3.js → dees-modal-75MIWWY2.js} +3 -3
  10. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-workspace-terminal-OISBUFI7.js → dees-workspace-terminal-6V4DLJS3.js} +4 -4
  11. package/dist_ts_web/00_commitinfo_data.js +1 -1
  12. package/dist_ts_web/contextmenu.d.ts +7 -0
  13. package/dist_ts_web/contextmenu.js +8 -0
  14. package/dist_ts_web/elements/00group-harness/dees-harness-composer/dees-harness-composer.d.ts +9 -39
  15. package/dist_ts_web/elements/00group-harness/dees-harness-composer/dees-harness-composer.js +85 -419
  16. package/dist_ts_web/elements/00group-input/dees-picker-fold/dees-picker-fold.d.ts +133 -0
  17. package/dist_ts_web/elements/00group-input/dees-picker-fold/dees-picker-fold.demo.d.ts +1 -0
  18. package/dist_ts_web/elements/00group-input/dees-picker-fold/dees-picker-fold.demo.js +71 -0
  19. package/dist_ts_web/elements/00group-input/dees-picker-fold/dees-picker-fold.js +600 -0
  20. package/dist_ts_web/elements/00group-input/dees-picker-fold/index.d.ts +1 -0
  21. package/dist_ts_web/elements/00group-input/dees-picker-fold/index.js +2 -0
  22. package/dist_ts_web/elements/00group-input/index.d.ts +1 -0
  23. package/dist_ts_web/elements/00group-input/index.js +2 -1
  24. package/dist_ts_web/i18n/de.d.ts +4 -4
  25. package/dist_ts_web/i18n/de.js +2 -2
  26. package/dist_ts_web/i18n/messages.d.ts +4 -4
  27. package/dist_ts_web/i18n/messages.js +2 -2
  28. package/package.json +5 -1
  29. package/readme.md +55 -1
  30. package/scripts/check-packed-consumer.mjs +8 -1
  31. package/ts_web/00_commitinfo_data.ts +1 -1
  32. package/ts_web/contextmenu.ts +7 -0
  33. package/ts_web/elements/00group-harness/dees-harness-composer/dees-harness-composer.ts +82 -403
  34. package/ts_web/elements/00group-input/dees-picker-fold/dees-picker-fold.demo.ts +77 -0
  35. package/ts_web/elements/00group-input/dees-picker-fold/dees-picker-fold.ts +559 -0
  36. package/ts_web/elements/00group-input/dees-picker-fold/index.ts +1 -0
  37. package/ts_web/elements/00group-input/index.ts +1 -0
  38. package/ts_web/i18n/de.ts +1 -1
  39. package/ts_web/i18n/messages.ts +1 -1
  40. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/de-OOMCZNLC.js.map +0 -1
  41. /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-T6MJ73SK.js.map → chunk-6M55MVYH.js.map} +0 -0
  42. /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-I4IO5H5N.js.map → chunk-CM67HGUE.js.map} +0 -0
  43. /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-modal-HUKGQIM3.js.map → dees-modal-75MIWWY2.js.map} +0 -0
  44. /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-workspace-terminal-OISBUFI7.js.map → dees-workspace-terminal-6V4DLJS3.js.map} +0 -0
@@ -9,7 +9,6 @@ import {
9
9
  property,
10
10
  state,
11
11
  cssManager,
12
- unsafeCSS,
13
12
  } from '@design.estate/dees-element';
14
13
  import { dcLocalize } from '../../../i18n/localize.js';
15
14
  import { themeDefaultStyles } from '../../00theme.js';
@@ -46,9 +45,12 @@ import {
46
45
  import '../../00group-button/dees-button/dees-button.js';
47
46
  import type { DeesButton } from '../../00group-button/dees-button/dees-button.js';
48
47
  import { DeesContextmenu, type TContextMenuItem } from '../../00group-overlay/dees-contextmenu/dees-contextmenu.js';
49
- import '../../00group-overlay/dees-popover/dees-popover.js';
50
- import type { DeesPopover } from '../../00group-overlay/dees-popover/dees-popover.js';
51
- import { DeesInputDropdown } from '../../00group-input/dees-input-dropdown/dees-input-dropdown.js';
48
+ import '../../00group-input/dees-picker-fold/dees-picker-fold.js';
49
+ import type {
50
+ DeesPickerFold,
51
+ IPickerFoldChangeDetail,
52
+ IPickerFoldPicker,
53
+ } from '../../00group-input/dees-picker-fold/dees-picker-fold.js';
52
54
  import type { TMultitoggleOption } from '../../00group-input/dees-input-multitoggle/dees-input-multitoggle.js';
53
55
  import '../../00group-utility/dees-icon/dees-icon.js';
54
56
 
@@ -58,15 +60,6 @@ declare global {
58
60
  }
59
61
  }
60
62
 
61
- /**
62
- * The pickers' smallest widths in px: the row lays them out from these, and decides from them
63
- * whether they fit beside the other controls or fold into the settings button.
64
- */
65
- const pickerMinWidths = { account: 120, model: 150, effort: 110 } as const;
66
-
67
- /** A picker, by what it chooses. */
68
- type TPickerKey = keyof typeof pickerMinWidths;
69
-
70
63
  const toDropdownOptions = (values: string[]): IDropdownOption[] =>
71
64
  values.map((value) => ({ option: value, key: value }));
72
65
 
@@ -431,43 +424,6 @@ export class DeesHarnessComposer extends DeesElement {
431
424
  /** Image attachments' data URLs, by attachment. */
432
425
  private readonly attachmentImageUrls = new WeakMap<IHarnessAttachment, string>();
433
426
 
434
- /**
435
- * The pickers do not fit on the row at their smallest widths beside the other controls, so one
436
- * settings button stands in for them and opens them in a popover (`fitPickers`).
437
- */
438
- @state()
439
- private accessor pickersFolded: boolean = false;
440
-
441
- /** The settings popover shows. */
442
- @state()
443
- private accessor settingsOpen: boolean = false;
444
-
445
- /** Watches what decides whether the pickers fit; set while the composer is in the page. */
446
- private controlsObserver: ResizeObserver | undefined;
447
-
448
- /** The controls the observer already watches. */
449
- private observedControls = new WeakSet<Element>();
450
-
451
- /** Where the focus was when the pickers folded or unfolded, so it lands on their stand-in. */
452
- private pickerFocusBeforeFold: TPickerKey | 'settings' | undefined;
453
-
454
- constructor() {
455
- super();
456
- this.registerStartupFunction(async (signal) => {
457
- await this.updateComplete;
458
- if (signal.aborted) return;
459
- this.controlsObserver = new ResizeObserver(() => this.fitPickers());
460
- this.observeControls();
461
- signal.addEventListener('abort', () => {
462
- this.controlsObserver?.disconnect();
463
- this.controlsObserver = undefined;
464
- this.observedControls = new WeakSet();
465
- }, { once: true });
466
- // A web font that arrives later sets the controls wider or narrower.
467
- document.fonts.addEventListener('loadingdone', () => this.fitPickers(), { signal });
468
- });
469
- }
470
-
471
427
  /** The prompt's and the command menu's scrollbars, shown while one scrolls. */
472
428
  private readonly scrollbars = new OverlayScrollbarController(
473
429
  this,
@@ -887,7 +843,7 @@ export class DeesHarnessComposer extends DeesElement {
887
843
 
888
844
  /*
889
845
  * One row: the pickers shrink to their smallest widths first, then fold into the settings
890
- * button (fitPickers). Only when even that row is too wide, on a phone while a turn runs,
846
+ * button (dees-picker-fold). Only when even that row is too wide, on a phone while a turn runs,
891
847
  * do the trailing actions wrap together onto a line of their own, still at the trailing edge.
892
848
  */
893
849
  .controlsRow {
@@ -898,26 +854,16 @@ export class DeesHarnessComposer extends DeesElement {
898
854
  gap: var(--dees-spacing-sm);
899
855
  }
900
856
 
901
- /*
902
- * As wide as the row and never taller: the pickers are fitted to its width. The row itself is
903
- * not observed, since a fold changes its height while the observer delivers.
904
- */
905
- .controlsSizer {
906
- position: absolute;
907
- inset-inline: 0;
908
- top: 0;
909
- height: 0;
910
- pointer-events: none;
911
- }
912
-
913
857
  .modeSwitch { flex: 0 0 auto; }
914
858
 
859
+ /*
860
+ * The pickers sit in the card on the faintest fill, and so does the settings button they fold
861
+ * into; a hover or focus draws their box.
862
+ */
915
863
  .modelControls {
916
- display: flex;
917
- gap: var(--dees-spacing-xs);
918
- /* takes the row's free space; its pickers stop at their own widths */
919
- flex: 1 1 auto;
920
- min-width: 0;
864
+ --dees-input-control-height: var(--dees-control-height-md);
865
+ --dees-input-control-bg: var(--dees-color-fill-tertiary);
866
+ --dees-input-control-border: transparent;
921
867
  }
922
868
 
923
869
  .actions {
@@ -940,110 +886,6 @@ export class DeesHarnessComposer extends DeesElement {
940
886
  corner-shape: round;
941
887
  }
942
888
 
943
- /* The pickers sit in the card on the faintest fill; a hover or focus draws their box. */
944
- .modelControls dees-input-dropdown {
945
- margin: 0;
946
- --dees-input-control-height: var(--dees-control-height-md);
947
- --dees-input-control-bg: var(--dees-color-fill-tertiary);
948
- --dees-input-control-border: transparent;
949
- }
950
-
951
- /*
952
- * The pickers size from these widths, never from their labels (inline-size containment): a
953
- * long label truncates instead of asking the row for room, so the row wraps only when the
954
- * pickers at their minimum widths and the actions do not fit.
955
- */
956
- .modelControls > .accountSelect {
957
- flex: 1 1 ${unsafeCSS(pickerMinWidths.account)}px;
958
- min-width: ${unsafeCSS(pickerMinWidths.account)}px;
959
- max-width: 180px;
960
- contain: inline-size;
961
- }
962
-
963
- /* Model identifiers are provider-qualified ("anthropic/claude-opus-5"),
964
- so the control grows into the free space instead of truncating,
965
- while still shrinking on narrow hosts. */
966
- .modelControls > .modelSelect {
967
- flex: 1 1 ${unsafeCSS(pickerMinWidths.model)}px;
968
- min-width: ${unsafeCSS(pickerMinWidths.model)}px;
969
- max-width: 280px;
970
- contain: inline-size;
971
- }
972
-
973
- .modelControls > .effortSelect {
974
- flex: 0 0 ${unsafeCSS(pickerMinWidths.effort)}px;
975
- width: ${unsafeCSS(pickerMinWidths.effort)}px;
976
- }
977
-
978
- /*
979
- * Folded, one button stands in for the pickers. It rests like them on the faintest fill,
980
- * says the model, and takes the room the row has left up to the model picker's widest; on a
981
- * tight row its words give way first, down to its two icons.
982
- */
983
- .settingsButton {
984
- flex: 1 1 0;
985
- max-width: 280px;
986
- display: inline-flex;
987
- align-items: center;
988
- gap: var(--dees-spacing-xs);
989
- height: var(--dees-control-height-md);
990
- padding: 0 var(--dees-spacing-sm);
991
- border: 0;
992
- border-radius: var(--dees-radius-lg);
993
- corner-shape: var(--dees-corner-shape);
994
- background: var(--dees-color-fill-tertiary);
995
- color: var(--dees-color-text-primary);
996
- cursor: pointer;
997
- font-family: inherit;
998
- font-size: var(--dees-font-control-size);
999
- transition: background var(--dees-transition-fast) var(--dees-ease-standard);
1000
- }
1001
-
1002
- .settingsButton dees-icon {
1003
- flex: 0 0 auto;
1004
- color: var(--dees-color-text-secondary);
1005
- }
1006
-
1007
- /* No width of its own, so the button's smallest width is its icons and padding. */
1008
- .settingsLabel {
1009
- flex: 1 1 auto;
1010
- width: 0;
1011
- min-width: 0;
1012
- overflow: hidden;
1013
- text-align: start;
1014
- text-overflow: ellipsis;
1015
- white-space: nowrap;
1016
- }
1017
-
1018
- .settingsButton:hover:not(:disabled) {
1019
- background: var(--dees-color-fill-secondary);
1020
- }
1021
-
1022
- .settingsButton:focus-visible {
1023
- outline: var(--dees-line-width-focus-ring) solid var(--dees-color-focus-ring);
1024
- outline-offset: 2px;
1025
- }
1026
-
1027
- .settingsButton:disabled {
1028
- cursor: default;
1029
- opacity: 0.5;
1030
- }
1031
-
1032
- @media (prefers-reduced-motion: reduce) {
1033
- .settingsButton { transition: none; }
1034
- }
1035
-
1036
- /* The popover's pickers, one under another with their names, at the panel's padding. */
1037
- .settingsPickers {
1038
- display: grid;
1039
- gap: var(--dees-spacing-md);
1040
- padding: var(--dees-spacing-lg);
1041
- }
1042
-
1043
- .settingsPickers dees-input-dropdown {
1044
- margin: 0;
1045
- }
1046
-
1047
889
  .accountNote {
1048
890
  display: flex;
1049
891
  align-items: flex-start;
@@ -1101,19 +943,9 @@ export class DeesHarnessComposer extends DeesElement {
1101
943
  public async openModelSelector(): Promise<boolean> {
1102
944
  await this.updateComplete;
1103
945
  if (this.interactionLocked || !this.modelOptions.length || !this.showModelControls) return false;
1104
- if (this.pickersFolded && !this.settingsOpen) {
1105
- // Folded, the model picker is in the settings popover: open it first, where its list can anchor.
1106
- this.settingsOpen = true;
1107
- await this.updateComplete;
1108
- await this.settingsPopover?.updateComplete;
1109
- await new Promise<void>((resolve) => requestAnimationFrame(() => resolve()));
1110
- if (!this.settingsOpen) return false;
1111
- }
1112
- const dropdown = this.shadowRoot?.querySelector<DeesInputDropdown>('.modelSelect');
1113
- if (!(dropdown instanceof DeesInputDropdown) || dropdown.disabled) return false;
1114
- dropdown.focus();
1115
- if (!dropdown.isOpened) await dropdown.toggleSelectionBox();
1116
- return true;
946
+ // Folded, the picker opens the settings popover first, where the model's list can anchor.
947
+ const pickers = this.shadowRoot?.querySelector<DeesPickerFold>('dees-picker-fold.modelControls');
948
+ return pickers ? pickers.openPicker('model') : false;
1117
949
  }
1118
950
 
1119
951
  public clear(): void {
@@ -1130,11 +962,6 @@ export class DeesHarnessComposer extends DeesElement {
1130
962
  if (changedProperties.has('value') || changedProperties.has('commands')) this.activeMenuIndex = -1;
1131
963
  if (changedProperties.has('historyKey')) this.resetHistoryNavigation();
1132
964
  if (changedProperties.has('modeOptions')) this.modeToggleOptions = toModeToggleOptions(this.modeOptions);
1133
- if (changedProperties.has('pickersFolded') && changedProperties.get('pickersFolded') !== undefined) {
1134
- this.pickerFocusBeforeFold = this.focusedPicker;
1135
- // Unfolded, the pickers are back on the row: the popover that held them has nothing to show.
1136
- if (!this.pickersFolded) this.settingsOpen = false;
1137
- }
1138
965
  }
1139
966
 
1140
967
  public updated(changedProperties: Map<PropertyKey, unknown>): void {
@@ -1150,16 +977,6 @@ export class DeesHarnessComposer extends DeesElement {
1150
977
  this.syncTextareaCommandAria();
1151
978
  if (this.actionMenu && !this.menuActions.length) void this.actionMenu.destroy();
1152
979
  if (this.setupMenu && !this.setupItems.length) void this.setupMenu.destroy();
1153
- this.observeControls();
1154
- // Which pickers show changes what the row needs without a size the observer sees.
1155
- if (['accountOptions', 'modelOptions', 'effortOptions', 'showModelControls'].some((key) => changedProperties.has(key))) {
1156
- queueMicrotask(() => this.fitPickers());
1157
- }
1158
- const popover = this.settingsPopover;
1159
- const settingsButton = this.shadowRoot?.querySelector<HTMLElement>('.settingsButton') ?? null;
1160
- if (popover && popover.anchor !== settingsButton) popover.anchor = settingsButton;
1161
- if (this.pickerFocusBeforeFold) this.refocusAfterFold(this.pickerFocusBeforeFold);
1162
- this.pickerFocusBeforeFold = undefined;
1163
980
  }
1164
981
 
1165
982
  public async disconnectedCallback(): Promise<void> {
@@ -1215,7 +1032,6 @@ export class DeesHarnessComposer extends DeesElement {
1215
1032
  ></textarea>
1216
1033
  </div>
1217
1034
  <div class="controlsRow">
1218
- <div class="controlsSizer" aria-hidden="true"></div>
1219
1035
  ${this.attachmentsEnabled ? html`<dees-button
1220
1036
  class="attachButton"
1221
1037
  size="sm"
@@ -1242,11 +1058,7 @@ export class DeesHarnessComposer extends DeesElement {
1242
1058
  }}></dees-input-multitoggle>
1243
1059
  `
1244
1060
  : ''}
1245
- ${this.pickerMinWidths.length
1246
- ? this.pickersFolded
1247
- ? this.renderSettingsButton()
1248
- : html`<div class="modelControls">${this.renderPickers(false)}</div>`
1249
- : ''}
1061
+ ${this.renderPickers()}
1250
1062
  <div class="actions">
1251
1063
  ${this.busy && this.queuedCount > 0
1252
1064
  ? html`<span class="queuedStatus" aria-live="polite">${this.t('composer.queued', { count: this.queuedCount })}</span>`
@@ -1329,19 +1141,6 @@ export class DeesHarnessComposer extends DeesElement {
1329
1141
  : ''}
1330
1142
  </div>
1331
1143
  ${this.renderSetupStrip()}
1332
- ${this.pickerMinWidths.length ? html`
1333
- <!--
1334
- Rendered, closed, whenever there are pickers: a fold only moves them in. A popover made
1335
- by a fold would start observing its content while the fold's own observer delivers.
1336
- -->
1337
- <dees-popover
1338
- class="settingsPopover"
1339
- .label=${this.t('composer.modelSettings')}
1340
- .open=${this.pickersFolded && this.settingsOpen}
1341
- .dismissOnTab=${false}
1342
- @dees-popover-close=${this.closeSettings}
1343
- ><div class="settingsPickers">${this.pickersFolded ? this.renderPickers(true) : ''}</div></dees-popover>
1344
- ` : ''}
1345
1144
  </div>
1346
1145
  `;
1347
1146
  }
@@ -1425,97 +1224,75 @@ export class DeesHarnessComposer extends DeesElement {
1425
1224
  }
1426
1225
 
1427
1226
  /**
1428
- * The account, model and effort pickers: on the row, or one under another with their names in
1429
- * the settings popover while they are folded. Either way they are the same controls, with the
1430
- * same search, the same disabled accounts' reasons and the same events.
1227
+ * The account, model and effort pickers: on the row, or, where they do not fit beside the other
1228
+ * controls, folded into one settings button that opens them, one under another with their names,
1229
+ * in a popover. Either way they are the same dropdowns, with the same search, the same disabled
1230
+ * accounts' reasons and the same events. They size from their smallest widths, never from their
1231
+ * labels.
1431
1232
  */
1432
- private renderPickers(stackedArg: boolean): TemplateResult {
1433
- return html`
1434
- ${this.accountOptions.length
1435
- ? html`
1436
- <dees-input-dropdown
1437
- class="accountSelect"
1438
- .label=${stackedArg ? this.t('composer.account') : undefined}
1439
- placeholder=${this.t('composer.chooseAccount')}
1440
- .options=${toLabeledDropdownOptions(this.accountOptions)}
1441
- .selectedOption=${this.usableAccountOption
1442
- ? toLabeledDropdownOptions([this.usableAccountOption])[0]
1443
- : null}
1444
- .disabled=${this.interactionLocked}
1445
- @selectedOption=${(event: CustomEvent<IDropdownOption>) => {
1446
- if (this.interactionLocked) return;
1447
- this.account = event.detail?.key ?? this.account;
1448
- this.emit('harness-account-change', { account: this.account });
1449
- }}
1450
- ></dees-input-dropdown>
1451
- `
1452
- : ''}
1453
- ${this.modelOptions.length
1454
- ? html`
1455
- <dees-input-dropdown
1456
- class="modelSelect"
1457
- .label=${stackedArg ? this.t('composer.model') : undefined}
1458
- placeholder=${this.t('composer.chooseModel')}
1459
- .options=${toDropdownOptions(this.modelOptions)}
1460
- .selectedOption=${this.model ? { option: this.model, key: this.model } : null}
1461
- .disabled=${this.interactionLocked}
1462
- @selectedOption=${(event: CustomEvent<IDropdownOption>) => {
1463
- if (this.interactionLocked) return;
1464
- this.model = event.detail?.key ?? this.model;
1465
- this.emitModelChange();
1466
- }}
1467
- ></dees-input-dropdown>
1468
- `
1469
- : ''}
1470
- ${this.effortOptions.length
1471
- ? html`
1472
- <dees-input-dropdown
1473
- class="effortSelect"
1474
- .label=${stackedArg ? this.t('composer.effort') : undefined}
1475
- placeholder=${this.t('composer.chooseEffort')}
1476
- .options=${toDropdownOptions(this.effortOptions)}
1477
- .selectedOption=${this.reasoningEffort
1478
- ? { option: this.reasoningEffort, key: this.reasoningEffort }
1479
- : null}
1480
- .disabled=${this.interactionLocked}
1481
- @selectedOption=${(event: CustomEvent<IDropdownOption>) => {
1482
- if (this.interactionLocked) return;
1483
- this.reasoningEffort = event.detail?.key ?? this.reasoningEffort;
1484
- this.emitModelChange();
1485
- }}
1486
- ></dees-input-dropdown>
1487
- `
1488
- : ''}
1489
- `;
1233
+ private renderPickers(): TemplateResult | string {
1234
+ const pickers = this.pickers;
1235
+ if (!pickers.length) return '';
1236
+ return html`<dees-picker-fold
1237
+ class="modelControls"
1238
+ primary="model"
1239
+ .label=${this.t('composer.modelSettings')}
1240
+ .summary=${this.settingsSummary}
1241
+ .pickers=${pickers}
1242
+ .disabled=${this.interactionLocked}
1243
+ @picker-change=${this.handlePickerChange}
1244
+ ></dees-picker-fold>`;
1490
1245
  }
1491
1246
 
1492
- /** The button that stands in for the folded pickers: it says the model and opens them. */
1493
- private renderSettingsButton(): TemplateResult {
1494
- const summary = this.settingsSummary;
1495
- return html`
1496
- <button
1497
- class="settingsButton"
1498
- type="button"
1499
- aria-label=${this.t('composer.modelSettingsNamed', { value: summary })}
1500
- title=${this.settingsDetails}
1501
- .ariaHasPopup=${'dialog'}
1502
- ?disabled=${this.interactionLocked}
1503
- @click=${() => {
1504
- if (this.settingsOpen) this.closeSettings();
1505
- else this.settingsOpen = true;
1506
- }}
1507
- >
1508
- <dees-icon icon="lucide:SlidersHorizontal" iconSize="14" aria-hidden="true"></dees-icon>
1509
- <span class="settingsLabel">${summary}</span>
1510
- <dees-icon icon="lucide:ChevronDown" iconSize="14" aria-hidden="true"></dees-icon>
1511
- </button>
1512
- `;
1247
+ /** The pickers that show, in the row's order. */
1248
+ private get pickers(): IPickerFoldPicker[] {
1249
+ if (!this.showModelControls) return [];
1250
+ return [
1251
+ ...(this.accountOptions.length ? [{
1252
+ key: 'account',
1253
+ label: this.t('composer.account'),
1254
+ placeholder: this.t('composer.chooseAccount'),
1255
+ options: toLabeledDropdownOptions(this.accountOptions),
1256
+ selectedOption: this.usableAccountOption ? toLabeledDropdownOptions([this.usableAccountOption])[0] : null,
1257
+ minWidth: 120,
1258
+ maxWidth: 180,
1259
+ }] : []),
1260
+ // Model identifiers are provider-qualified ("anthropic/claude-opus-5"), so the picker grows
1261
+ // into the free space instead of truncating, while still shrinking on narrow hosts.
1262
+ ...(this.modelOptions.length ? [{
1263
+ key: 'model',
1264
+ label: this.t('composer.model'),
1265
+ placeholder: this.t('composer.chooseModel'),
1266
+ options: toDropdownOptions(this.modelOptions),
1267
+ selectedOption: this.model ? { option: this.model, key: this.model } : null,
1268
+ minWidth: 150,
1269
+ maxWidth: 280,
1270
+ }] : []),
1271
+ ...(this.effortOptions.length ? [{
1272
+ key: 'effort',
1273
+ label: this.t('composer.effort'),
1274
+ placeholder: this.t('composer.chooseEffort'),
1275
+ options: toDropdownOptions(this.effortOptions),
1276
+ selectedOption: this.reasoningEffort ? { option: this.reasoningEffort, key: this.reasoningEffort } : null,
1277
+ minWidth: 110,
1278
+ maxWidth: 110,
1279
+ }] : []),
1280
+ ];
1513
1281
  }
1514
1282
 
1515
- /** The settings popover closed: the pickers it held may fit on the row again. */
1516
- private closeSettings = (): void => {
1517
- this.settingsOpen = false;
1518
- queueMicrotask(() => this.fitPickers());
1283
+ private handlePickerChange = (eventArg: CustomEvent<IPickerFoldChangeDetail>): void => {
1284
+ if (this.interactionLocked) return;
1285
+ const { key, option } = eventArg.detail;
1286
+ if (key === 'account') {
1287
+ this.account = option.key ?? this.account;
1288
+ this.emit('harness-account-change', { account: this.account });
1289
+ } else if (key === 'model') {
1290
+ this.model = option.key ?? this.model;
1291
+ this.emitModelChange();
1292
+ } else if (key === 'effort') {
1293
+ this.reasoningEffort = option.key ?? this.reasoningEffort;
1294
+ this.emitModelChange();
1295
+ }
1519
1296
  };
1520
1297
 
1521
1298
  /** What the settings button says: the first choice still to make, else the model. */
@@ -1526,104 +1303,6 @@ export class DeesHarnessComposer extends DeesElement {
1526
1303
  return this.reasoningEffort || this.t('composer.chooseEffort');
1527
1304
  }
1528
1305
 
1529
- /** Every choice the pickers hold, for the settings button's tooltip. */
1530
- private get settingsDetails(): string {
1531
- return [
1532
- this.accountOptions.length ? this.usableAccountOption?.label ?? this.t('composer.chooseAccount') : '',
1533
- this.modelOptions.length ? this.model || this.t('composer.chooseModel') : '',
1534
- this.effortOptions.length ? this.reasoningEffort || this.t('composer.chooseEffort') : '',
1535
- ].filter(Boolean).join(' · ');
1536
- }
1537
-
1538
- private get settingsPopover(): DeesPopover | null {
1539
- return this.shadowRoot?.querySelector<DeesPopover>('dees-popover.settingsPopover') ?? null;
1540
- }
1541
-
1542
- /** The smallest widths of the pickers that show, in the row's order. */
1543
- private get pickerMinWidths(): number[] {
1544
- if (!this.showModelControls) return [];
1545
- return [
1546
- ...(this.accountOptions.length ? [pickerMinWidths.account] : []),
1547
- ...(this.modelOptions.length ? [pickerMinWidths.model] : []),
1548
- ...(this.effortOptions.length ? [pickerMinWidths.effort] : []),
1549
- ];
1550
- }
1551
-
1552
- /** Watches the row's width, through its sizer, and each control beside the pickers. */
1553
- private observeControls(): void {
1554
- const observer = this.controlsObserver;
1555
- const row = this.shadowRoot?.querySelector('.controlsRow');
1556
- if (!observer || !row) return;
1557
- const controls = row.querySelectorAll(
1558
- ':scope > .controlsSizer, :scope > .attachButton, :scope > .modeSwitch, :scope > .actions > *',
1559
- );
1560
- for (const control of controls) {
1561
- if (this.observedControls.has(control)) continue;
1562
- this.observedControls.add(control);
1563
- observer.observe(control);
1564
- }
1565
- }
1566
-
1567
- /**
1568
- * Folds the pickers into the settings button when they do not fit on the row at their smallest
1569
- * widths beside the attach button, the mode switch and the actions at theirs. Nothing it reads
1570
- * changes with the answer, so the row never flips back and forth.
1571
- */
1572
- private fitPickers(): void {
1573
- const row = this.shadowRoot?.querySelector<HTMLElement>('.controlsRow');
1574
- const pickerWidths = this.pickerMinWidths;
1575
- if (!row || !pickerWidths.length) {
1576
- this.pickersFolded = false;
1577
- return;
1578
- }
1579
- const available = row.clientWidth;
1580
- // Not laid out (hidden, or not yet in the page): nothing to fit.
1581
- if (!available) return;
1582
- // An open popover keeps its pickers until it closes, so nothing moves under the reader; closing
1583
- // it here, in the observer's delivery, would also resize what the popover's own observers watch.
1584
- if (this.pickersFolded && this.settingsOpen) return;
1585
- const gapOf = (elementArg: Element): number => parseFloat(getComputedStyle(elementArg).columnGap) || 0;
1586
- // A shrunk control still asks for its whole width.
1587
- const widthOf = (elementArg: Element): number => Math.max(elementArg.getBoundingClientRect().width, elementArg.scrollWidth);
1588
- const pickerGap = parseFloat(getComputedStyle(this).getPropertyValue('--dees-spacing-xs')) || 0;
1589
- const widths = [
1590
- ...Array.from(row.querySelectorAll(':scope > .attachButton, :scope > .modeSwitch'), widthOf),
1591
- pickerWidths.reduce((sum, width) => sum + width, 0) + (pickerWidths.length - 1) * pickerGap,
1592
- ];
1593
- const actions = row.querySelector(':scope > .actions');
1594
- if (actions?.children.length) {
1595
- const actionWidths = Array.from(actions.children, widthOf);
1596
- widths.push(actionWidths.reduce((sum, width) => sum + width, 0) + (actionWidths.length - 1) * gapOf(actions));
1597
- }
1598
- const needed = widths.reduce((sum, width) => sum + width, 0) + (widths.length - 1) * gapOf(row);
1599
- this.pickersFolded = needed > available + 0.5;
1600
- }
1601
-
1602
- /** The picker, or the settings button, the focus is on. */
1603
- private get focusedPicker(): TPickerKey | 'settings' | undefined {
1604
- const active = this.shadowRoot?.activeElement;
1605
- if (!active) return undefined;
1606
- if (active.classList.contains('settingsButton')) return 'settings';
1607
- if (active.classList.contains('accountSelect')) return 'account';
1608
- if (active.classList.contains('modelSelect')) return 'model';
1609
- if (active.classList.contains('effortSelect')) return 'effort';
1610
- return undefined;
1611
- }
1612
-
1613
- /** A fold took the focused control away: the focus goes to what stands in for it. */
1614
- private refocusAfterFold(fromArg: TPickerKey | 'settings'): void {
1615
- const root = this.shadowRoot;
1616
- if (this.pickersFolded) {
1617
- root?.querySelector<HTMLElement>('.settingsButton')?.focus();
1618
- return;
1619
- }
1620
- // The settings button, or a picker in its popover, went away: the row's picker takes the focus.
1621
- const key = fromArg === 'settings' ? 'model' : fromArg;
1622
- const picker = root?.querySelector<HTMLElement>(`.modelControls > .${key}Select`)
1623
- ?? root?.querySelector<HTMLElement>('.modelControls > dees-input-dropdown');
1624
- picker?.focus();
1625
- }
1626
-
1627
1306
  private handlePromptFieldClick(event: MouseEvent): void {
1628
1307
  // Context text is part of the field; preserve native interactions in slotted controls.
1629
1308
  for (const target of event.composedPath()) {
@@ -0,0 +1,77 @@
1
+ import { html } from '@design.estate/dees-element';
2
+ import { demoPage, demoSection, demoOutput, showDemoResult } from '../../../demos/templates.js';
3
+ import type { IDropdownOption } from '../dees-input-dropdown/dees-input-dropdown-popup.js';
4
+ import type { DeesPickerFold, IPickerFoldChangeDetail, IPickerFoldPicker } from './dees-picker-fold.js';
5
+
6
+ const accounts: IDropdownOption[] = [
7
+ { key: 'personal', option: 'Personal · alex@example.com' },
8
+ { key: 'work', option: 'Work · alex@example.org', disabled: true, description: 'Needs a new sign-in.' },
9
+ ];
10
+ const models: IDropdownOption[] = [
11
+ { key: 'openai/gpt-5.6-sol', option: 'openai/gpt-5.6-sol' },
12
+ { key: 'anthropic/claude-opus-5', option: 'anthropic/claude-opus-5' },
13
+ { key: '', option: "The harness's own default" },
14
+ ];
15
+ const efforts: IDropdownOption[] = [
16
+ { key: '', option: 'Model default' },
17
+ { key: 'high', option: 'High' },
18
+ { key: 'max', option: 'Max' },
19
+ ];
20
+
21
+ type TChoice = Record<string, string>;
22
+
23
+ const pickersFor = (choiceArg: TChoice, withAccountArg: boolean): IPickerFoldPicker[] => [
24
+ ...(withAccountArg ? [{
25
+ key: 'account', label: 'Account', options: accounts, placeholder: 'Choose an account', minWidth: 120, maxWidth: 180,
26
+ selectedOption: accounts.find((option) => option.key === choiceArg.account && !option.disabled) ?? null,
27
+ }] : []),
28
+ {
29
+ key: 'model', label: 'Model', options: models, placeholder: 'Choose a model', minWidth: 150, maxWidth: 280,
30
+ selectedOption: models.find((option) => option.key === choiceArg.model) ?? null,
31
+ },
32
+ {
33
+ key: 'effort', label: 'Reasoning effort', options: efforts, minWidth: 150, maxWidth: 150, enableSearch: false,
34
+ selectedOption: efforts.find((option) => option.key === choiceArg.effort) ?? null,
35
+ },
36
+ ];
37
+
38
+ /** The demo's host: it keeps the choice and passes the pickers again, as a controlled host does. */
39
+ const choose = (eventArg: CustomEvent<IPickerFoldChangeDetail>): void => {
40
+ const fold = eventArg.currentTarget as DeesPickerFold;
41
+ const choice: TChoice = Object.fromEntries(fold.pickers.map((picker) => [picker.key, picker.selectedOption?.key ?? '']));
42
+ choice[eventArg.detail.key] = eventArg.detail.option.key;
43
+ fold.pickers = pickersFor(choice, fold.pickers.some((picker) => picker.key === 'account'));
44
+ if (fold.warning && eventArg.detail.key === 'model') fold.warning = '';
45
+ showDemoResult(fold, choice);
46
+ };
47
+
48
+ export const demoFunc = () => demoPage('Folded pickers', 'Dropdowns on a row that fold into one button where they do not fit, and open in a speech bubble.', html`
49
+ ${demoSection('On a row', 'Drag the frame\'s corner: where the pickers do not fit beside the row\'s other items at their smallest widths, one button stands in for them.', html`
50
+ <div style="resize: horizontal; overflow: auto; width: 720px; max-width: 100%; min-width: 240px; padding: 8px; border: 1px dashed var(--dees-color-border-default); border-radius: var(--dees-radius-lg);">
51
+ <div class="dees-demo-row" style="flex-wrap: nowrap; gap: 8px;">
52
+ <dees-button type="ghost" size="sm" icon="lucide:Paperclip" title="Attach"></dees-button>
53
+ <dees-picker-fold label="Model settings" primary="model"
54
+ .pickers=${pickersFor({ account: 'personal', model: 'openai/gpt-5.6-sol', effort: 'high' }, true)}
55
+ @picker-change=${choose}></dees-picker-fold>
56
+ <dees-button type="accent" size="sm" shape="pill" style="margin-inline-start: auto;">Send</dees-button>
57
+ </div>
58
+ </div>
59
+ ${demoOutput('Choose an account, a model or an effort.')}
60
+ `)}
61
+ ${demoSection('Always folded', 'A settings row too narrow for two dropdowns keeps them folded: the button says model · effort, and only the model gives way. A saved choice no longer offered takes the warning tone.', html`
62
+ <div style="display: grid; gap: 12px; max-width: 520px;">
63
+ ${[
64
+ { name: 'Flex', choice: { model: 'openai/gpt-5.6-sol', effort: 'max' }, warning: '' },
65
+ { name: 'Claude Code', choice: { model: '', effort: '' }, warning: '' },
66
+ { name: 'OpenCode', choice: { model: '', effort: '' }, warning: 'The saved default openai/gpt-5.1 is no longer offered.' },
67
+ ].map((row) => html`
68
+ <div style="display: flex; align-items: center; gap: 16px;">
69
+ <span style="flex: 1 1 auto; min-width: 0;">${row.name}</span>
70
+ <dees-picker-fold fold="always" style="max-width: 280px;" label=${`Default model for ${row.name}`} primary="model"
71
+ .warning=${row.warning} .pickers=${pickersFor(row.choice, false)} @picker-change=${choose}></dees-picker-fold>
72
+ </div>
73
+ `)}
74
+ </div>
75
+ ${demoOutput('Open a row\'s button and choose.')}
76
+ `)}
77
+ `);