@ai-ecoverse/slicc-spectrum 1.10.0 → 1.12.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.
package/dist/slicc-ui.js CHANGED
@@ -7824,7 +7824,8 @@ var actionLabels = {
7824
7824
  retry: "Retry",
7825
7825
  settings: "Open settings",
7826
7826
  "change-model": "Change model",
7827
- login: "Log in"
7827
+ login: "Log in",
7828
+ "drop-turn": "Drop the last turn"
7828
7829
  };
7829
7830
  function time(at) {
7830
7831
  return new Date(at).toISOString().slice(11, 16);
@@ -7971,7 +7972,7 @@ function part(entry, handlers, showThinking) {
7971
7972
  </a>`;
7972
7973
  default:
7973
7974
  return b`<div class="error-card" role="alert">
7974
- <span>${entry.message}</span>
7975
+ <div class="error-text"><span class="lead">${entry.message}</span>${entry.detail ? b`<span class="detail">${entry.detail}</span>` : A}</div>
7975
7976
  ${entry.action ? b`<sp-button size="s" variant="secondary" treatment="outline" @click=${() => handlers.action(entry.action)}>${actionLabels[entry.action]}</sp-button>` : A}
7976
7977
  </div>`;
7977
7978
  }
@@ -8026,7 +8027,12 @@ function assistant(message, name, model, handlers, showThinking) {
8026
8027
  ${message.status === "stopped" ? b`<span class="tag">stopped</span>` : A}
8027
8028
  ${message.status === "error" ? b`<span class="tag negative">failed</span>` : A}
8028
8029
  </div>
8029
- ${parts(message.parts, handlers, showThinking, message.status === "streaming")}
8030
+ ${parts(
8031
+ message.parts,
8032
+ { ...handlers, action: (action) => handlers.action(action, message.id) },
8033
+ showThinking,
8034
+ message.status === "streaming"
8035
+ )}
8030
8036
  ${message.status === "streaming" ? b`<span class="caret" aria-hidden="true"></span>` : A}
8031
8037
  </article>`;
8032
8038
  }
@@ -8048,8 +8054,8 @@ function system(message, handlers) {
8048
8054
  return b`<div class="notice" role="note" data-id=${message.id}><strong>${message.title}</strong> ${message.text}</div>`;
8049
8055
  }
8050
8056
  return b`<div class="error-card system-error" role="alert" data-id=${message.id}>
8051
- <div><strong>${message.title}</strong><span>${message.text}</span></div>
8052
- ${message.action ? b`<sp-button size="s" variant="secondary" treatment="outline" @click=${() => handlers.action(message.action)}>${actionLabels[message.action]}</sp-button>` : A}
8057
+ <div class="error-text"><strong>${message.title}</strong><span>${message.text}</span></div>
8058
+ ${message.action ? b`<sp-button size="s" variant="secondary" treatment="outline" @click=${() => handlers.action(message.action, message.id)}>${actionLabels[message.action]}</sp-button>` : A}
8053
8059
  </div>`;
8054
8060
  }
8055
8061
  function lick(message, handlers) {
@@ -8522,8 +8528,20 @@ var messageCss = i`
8522
8528
  margin: 6px 0;
8523
8529
  font-size: var(--spectrum-font-size-75);
8524
8530
  }
8525
- .error-card div {
8531
+ .error-card .error-text {
8526
8532
  display: grid;
8533
+ gap: 2px;
8534
+ flex: 1;
8535
+ min-width: 0;
8536
+ overflow-wrap: anywhere;
8537
+ }
8538
+ .error-card .detail {
8539
+ font-size: var(--spectrum-font-size-50);
8540
+ color: var(--spectrum-neutral-subdued-content-color-default);
8541
+ }
8542
+ .error-card sp-button {
8543
+ flex: none;
8544
+ white-space: nowrap;
8527
8545
  }
8528
8546
  .marker,
8529
8547
  .day {
@@ -8695,7 +8713,7 @@ var SliccChat = class extends ThemedElement {
8695
8713
  model: null,
8696
8714
  answer: (questionId, answer) => this.model?.agent.answer(this.#id(), questionId, answer),
8697
8715
  resolve: (messageId, state) => this.model?.agent.resolveLick(this.#id(), messageId, state),
8698
- action: (action) => this.#action(action),
8716
+ action: (action, messageId) => this.#action(action, messageId),
8699
8717
  open: (path) => this.dispatchEvent(
8700
8718
  new CustomEvent("open-file", { detail: { path }, bubbles: true, composed: true })
8701
8719
  )
@@ -8737,10 +8755,19 @@ var SliccChat = class extends ThemedElement {
8737
8755
  const id = this.#id();
8738
8756
  return this.model?.agent.list().find((agent) => agent.id === id);
8739
8757
  }
8740
- #action(action) {
8758
+ async #rewind(id, messageId) {
8759
+ const restored = await this.model?.agent.rewind?.(id, messageId);
8760
+ if (!restored) return;
8761
+ this.renderRoot.querySelector("slicc-composer")?.restore(restored);
8762
+ }
8763
+ #action(action, messageId = "") {
8741
8764
  const model = this.model;
8742
8765
  if (!model) return;
8743
8766
  const id = this.#id();
8767
+ if (action === "drop-turn") {
8768
+ void this.#rewind(id, messageId);
8769
+ return;
8770
+ }
8744
8771
  if (action === "retry") {
8745
8772
  const last = model.agent.messages(id).filter((message) => message.role === "user").at(-1);
8746
8773
  if (last) void model.agent.send(id, { text: last.text, attachments: last.attachments });
@@ -9145,6 +9172,12 @@ var SliccComposer = class extends ModelElement {
9145
9172
  focus() {
9146
9173
  this.focusOn("textarea");
9147
9174
  }
9175
+ restore(message) {
9176
+ this.value = message.text;
9177
+ this.attachments = [...message.attachments ?? []];
9178
+ this.#history = -1;
9179
+ this.focus();
9180
+ }
9148
9181
  get #textarea() {
9149
9182
  return this.renderRoot.querySelector("textarea");
9150
9183
  }