@prettier-ai/dsh-client-ui-message-feedback 0.1.2-alpha.1 → 0.1.2-alpha.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
@@ -58,7 +58,7 @@ window.__ModuleLoader__.load({
58
58
  * control in that Session, so a single list read seeds them all.
59
59
  */
60
60
  var MessageFeedbackController = class {
61
- remote;
61
+ ctx;
62
62
  sessionId;
63
63
  view = INITIAL_VIEW;
64
64
  listeners = /* @__PURE__ */ new Set();
@@ -66,11 +66,11 @@ window.__ModuleLoader__.load({
66
66
  operationTail = Promise.resolve();
67
67
  disposed = false;
68
68
  /**
69
- * @param remote - the messageFeedback Remote namespace.
69
+ * @param ctx - the browser plugin context carrying the messageFeedback Remote namespace.
70
70
  * @param sessionId - Session owning every addressed assistant message.
71
71
  */
72
- constructor(remote, sessionId) {
73
- this.remote = remote;
72
+ constructor(ctx, sessionId) {
73
+ this.ctx = ctx;
74
74
  this.sessionId = sessionId;
75
75
  }
76
76
  /** Return the cached immutable view. */
@@ -185,7 +185,7 @@ window.__ModuleLoader__.load({
185
185
  }
186
186
  /** Commit one put against the observed version and reconcile a conflict. */
187
187
  async putCommitted(messageId, rating, note, observed) {
188
- const carried = await this.remote.put({
188
+ const carried = await this.ctx.remote.messageFeedback.put({
189
189
  sessionId: this.sessionId,
190
190
  messageId,
191
191
  rating,
@@ -203,7 +203,7 @@ window.__ModuleLoader__.load({
203
203
  }
204
204
  /** Commit one delete against the observed version and reconcile a conflict. */
205
205
  async deleteCommitted(messageId, observed) {
206
- const carried = await this.remote.delete({
206
+ const carried = await this.ctx.remote.messageFeedback.delete({
207
207
  sessionId: this.sessionId,
208
208
  messageId,
209
209
  ifVersion: observed.version
@@ -224,55 +224,37 @@ window.__ModuleLoader__.load({
224
224
  }
225
225
  /** Fetch the whole sidecar and publish it as the seeded view. */
226
226
  async load() {
227
- try {
228
- const carried = await this.remote.list({ sessionId: this.sessionId });
229
- if (this.disposed) return OK;
230
- if (!carried.ok) {
231
- this.publish({
232
- status: "error",
233
- items: this.view.items,
234
- error: carried.error.message
235
- });
236
- return carrierFailure(carried.error);
237
- }
238
- const result = carried.value;
239
- if (!result.ok) {
240
- this.publish({
241
- status: "error",
242
- items: this.view.items,
243
- error: describe(result.error.code)
244
- });
245
- return fail(result.error.code);
246
- }
247
- const items = /* @__PURE__ */ new Map();
248
- for (const item of result.value.items) items.set(item.messageId, item);
227
+ const carried = await this.ctx.remote.messageFeedback.list({ sessionId: this.sessionId });
228
+ if (this.disposed) return OK;
229
+ if (!carried.ok) {
249
230
  this.publish({
250
- status: "ready",
251
- items,
252
- error: null
231
+ status: "error",
232
+ items: this.view.items,
233
+ error: carried.error.message
253
234
  });
254
- return OK;
255
- } catch (error) {
256
- if (this.disposed) return OK;
257
- const message = error instanceof Error ? error.message : String(error);
235
+ return carrierFailure(carried.error);
236
+ }
237
+ const result = carried.value;
238
+ if (!result.ok) {
258
239
  this.publish({
259
240
  status: "error",
260
241
  items: this.view.items,
261
- error: message
242
+ error: describe(result.error.code)
262
243
  });
263
- return {
264
- ok: false,
265
- error: {
266
- code: "transport",
267
- message
268
- }
269
- };
244
+ return fail(result.error.code);
270
245
  }
246
+ const items = /* @__PURE__ */ new Map();
247
+ for (const item of result.value.items) items.set(item.messageId, item);
248
+ this.publish({
249
+ status: "ready",
250
+ items,
251
+ error: null
252
+ });
253
+ return OK;
271
254
  }
272
255
  /**
273
256
  * Serialize one mutation behind this Session's prior mutation so queued
274
- * operations always compare against the committed version, and translate a
275
- * transport throw into the same settled shape the controls already render.
257
+ * operations always compare against the committed version.
276
258
  */
277
259
  mutate(operation, options = {}) {
278
260
  const guarded = async () => {
@@ -282,17 +264,7 @@ window.__ModuleLoader__.load({
282
264
  if (!loaded.ok) return loaded;
283
265
  if (this.disposed) return DISPOSED;
284
266
  }
285
- try {
286
- return await operation();
287
- } catch (error) {
288
- return {
289
- ok: false,
290
- error: {
291
- code: "transport",
292
- message: error instanceof Error ? error.message : String(error)
293
- }
294
- };
295
- }
267
+ return await operation();
296
268
  };
297
269
  const result = this.operationTail.then(guarded, guarded);
298
270
  this.operationTail = result.then(() => void 0);
@@ -326,7 +298,7 @@ window.__ModuleLoader__.load({
326
298
  };
327
299
  //#endregion
328
300
  //#region \0dsh-css:/home/runner/work/dsh-publisher/dsh-publisher/upstream/packages/client/ui-message-feedback/src/client/MessageFeedbackActions.module.css.mjs
329
- const css = ".-ssFWa_action{width:calc(28px + var(--dsh-content-font-delta,0px));height:calc(28px + var(--dsh-content-font-delta,0px));color:var(--dsw-alias-label-tertiary);cursor:pointer;background:0 0;border:none;border-radius:28px;justify-content:center;align-items:center;padding:6px;display:inline-flex}.-ssFWa_action svg{width:calc(16px + var(--dsh-content-font-delta,0px));height:calc(16px + var(--dsh-content-font-delta,0px))}.-ssFWa_action:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary)}.-ssFWa_action:disabled{cursor:default;opacity:.4}.-ssFWa_action[data-active]{color:var(--dsw-alias-label-primary)}.-ssFWa_noteOpen{max-width:220px;color:var(--dsw-alias-label-tertiary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(28px + var(--dsh-content-font-delta,0px));white-space:nowrap;text-overflow:ellipsis;cursor:pointer;background:0 0;border:none;border-radius:14px;padding:0 8px;overflow:hidden}.-ssFWa_noteOpen:hover,.-ssFWa_noteOpen[aria-expanded=true]{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary)}.-ssFWa_notePanel{z-index:1100;box-sizing:border-box;border:1px solid var(--dsw-alias-border-inverted);background:var(--dsw-specific-menu);width:320px;max-width:min(360px,100vw - 24px);max-height:calc(100vh - 24px);box-shadow:var(--dsw-shadow-lv3);--dsh-scrollbar-thumb:var(--dsw-alias-scrollbar-bg-l2);--dsh-scrollbar-thumb-hover:var(--dsw-alias-scrollbar-hover-l2);border-radius:12px;flex-direction:column;gap:8px;padding:8px;display:flex;position:fixed;overflow-y:auto}.-ssFWa_noteInput{box-sizing:border-box;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-1);width:100%;color:var(--dsw-alias-label-primary);font:inherit;resize:vertical;border-radius:8px;padding:6px 8px;font-size:13px}.-ssFWa_noteActions{justify-content:flex-end;gap:6px;display:flex}.-ssFWa_noteSave,.-ssFWa_noteCancel{cursor:pointer;border:none;border-radius:14px;height:28px;padding:0 10px;font-size:13px}.-ssFWa_noteSave{background:var(--dsw-alias-button-primary-fill);color:var(--dsw-alias-label-primary-foreground)}.-ssFWa_noteSave:hover:not(:disabled){background:var(--dsw-alias-button-primary-hover)}.-ssFWa_noteSave:disabled{cursor:default;opacity:.4}.-ssFWa_noteCancel{color:var(--dsw-alias-label-tertiary);background:0 0}.-ssFWa_noteCancel:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary)}.-ssFWa_failure{color:var(--dsw-alias-label-tertiary);padding-left:4px;font-size:13px;line-height:20px}";
301
+ const css = ".-ssFWa_action{width:calc(28px + var(--dsh-content-font-delta,0px));height:calc(28px + var(--dsh-content-font-delta,0px));color:var(--dsw-alias-label-tertiary);cursor:pointer;background:0 0;border:none;border-radius:28px;justify-content:center;align-items:center;padding:6px;display:inline-flex}.-ssFWa_action svg{width:calc(15px + var(--dsh-content-font-delta,0px));height:calc(15px + var(--dsh-content-font-delta,0px))}.-ssFWa_action:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary)}.-ssFWa_action:disabled{cursor:default;opacity:.4}.-ssFWa_action[data-active]{color:var(--dsw-alias-label-primary)}.-ssFWa_noteOpen{max-width:220px;color:var(--dsw-alias-label-tertiary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(28px + var(--dsh-content-font-delta,0px));white-space:nowrap;text-overflow:ellipsis;cursor:pointer;background:0 0;border:none;border-radius:14px;padding:0 8px;overflow:hidden}.-ssFWa_noteOpen:hover,.-ssFWa_noteOpen[aria-expanded=true]{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary)}.-ssFWa_notePanel{z-index:1100;box-sizing:border-box;border:1px solid var(--dsw-alias-border-inverted);background:var(--dsw-specific-menu);width:320px;max-width:min(360px,100vw - 24px);max-height:calc(100vh - 24px);box-shadow:var(--dsw-shadow-lv3);--dsh-scrollbar-thumb:var(--dsw-alias-scrollbar-bg-l2);--dsh-scrollbar-thumb-hover:var(--dsw-alias-scrollbar-hover-l2);border-radius:12px;flex-direction:column;gap:8px;padding:8px;display:flex;position:fixed;overflow-y:auto}.-ssFWa_noteInput{box-sizing:border-box;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-1);width:100%;color:var(--dsw-alias-label-primary);font:inherit;resize:vertical;border-radius:8px;padding:6px 8px;font-size:13px}.-ssFWa_noteActions{justify-content:flex-end;gap:6px;display:flex}.-ssFWa_noteSave,.-ssFWa_noteCancel{cursor:pointer;border:none;border-radius:14px;height:28px;padding:0 10px;font-size:13px}.-ssFWa_noteSave{background:var(--dsw-alias-button-primary-fill);color:var(--dsw-alias-label-primary-foreground)}.-ssFWa_noteSave:hover:not(:disabled){background:var(--dsw-alias-button-primary-hover)}.-ssFWa_noteSave:disabled{cursor:default;opacity:.4}.-ssFWa_noteCancel{color:var(--dsw-alias-label-tertiary);background:0 0}.-ssFWa_noteCancel:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary)}.-ssFWa_failure{color:var(--dsw-alias-label-tertiary);padding-left:4px;font-size:13px;line-height:20px}";
330
302
  const tagId = "@prettier-ai/dsh-client-ui-message-feedback/MessageFeedbackActions.module.css";
331
303
  if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null) {
332
304
  const tag = document.createElement("style");
@@ -684,7 +656,7 @@ window.__ModuleLoader__.load({
684
656
  const controllerFor = (sessionId) => {
685
657
  let controller = controllers.get(sessionId);
686
658
  if (controller === void 0) {
687
- controller = new MessageFeedbackController(ctx.remote.messageFeedback, sessionId);
659
+ controller = new MessageFeedbackController(ctx, sessionId);
688
660
  controllers.set(sessionId, controller);
689
661
  }
690
662
  return controller;
@@ -6,34 +6,11 @@
6
6
  * instead of refetching the whole Session.
7
7
  * @module @prettier-ai/dsh-client-ui-message-feedback/client/controller
8
8
  */
9
- import type { RemoteResult } from '@prettier-ai/dsh-typert-protocol';
9
+ import type { Context as ClientContext } from '@prettier-ai/cordis';
10
10
  import type { HostObservable } from '@prettier-ai/dsh-client-ui-slots';
11
- import type { MessageId } from '@prettier-ai/dsh-client-connection/client';
11
+ import type { MessageId } from '@prettier-ai/dsh-api-remotes/client';
12
12
  import type { SessionId } from '@prettier-ai/dsh-session/types';
13
- import type { MessageFeedbackDeleteResult, MessageFeedbackItem, MessageFeedbackListResult, MessageFeedbackPutResult, MessageFeedbackRating } from '@prettier-ai/dsh-message-feedback/types';
14
- /**
15
- * The three Remote calls this controller needs. The generated face wraps every
16
- * business result in {@link RemoteResult}: a carrier failure arrives as the
17
- * `ok: false` branch rather than a rejection, so this controller reads one
18
- * envelope and never wraps a call to recover a transport error.
19
- */
20
- export interface MessageFeedbackRemote {
21
- list: (request: {
22
- sessionId: SessionId;
23
- }) => Promise<RemoteResult<MessageFeedbackListResult>>;
24
- put: (request: {
25
- sessionId: SessionId;
26
- messageId: MessageId;
27
- rating: MessageFeedbackRating;
28
- note?: string;
29
- ifVersion: MessageFeedbackItem['version'] | null;
30
- }) => Promise<RemoteResult<MessageFeedbackPutResult>>;
31
- delete: (request: {
32
- sessionId: SessionId;
33
- messageId: MessageId;
34
- ifVersion: MessageFeedbackItem['version'];
35
- }) => Promise<RemoteResult<MessageFeedbackDeleteResult>>;
36
- }
13
+ import type { MessageFeedbackItem, MessageFeedbackRating } from '@prettier-ai/dsh-message-feedback/types';
37
14
  /** Load state of the one list read that seeds every per-message control. */
38
15
  export type MessageFeedbackStatus = 'cold' | 'loading' | 'ready' | 'error';
39
16
  /** Immutable view published to every per-message control in one Session. */
@@ -59,7 +36,7 @@ export type MessageFeedbackActionResult = {
59
36
  * control in that Session, so a single list read seeds them all.
60
37
  */
61
38
  export declare class MessageFeedbackController implements HostObservable<MessageFeedbackView> {
62
- private readonly remote;
39
+ private readonly ctx;
63
40
  private readonly sessionId;
64
41
  private view;
65
42
  private readonly listeners;
@@ -67,10 +44,10 @@ export declare class MessageFeedbackController implements HostObservable<Message
67
44
  private operationTail;
68
45
  private disposed;
69
46
  /**
70
- * @param remote - the messageFeedback Remote namespace.
47
+ * @param ctx - the browser plugin context carrying the messageFeedback Remote namespace.
71
48
  * @param sessionId - Session owning every addressed assistant message.
72
49
  */
73
- constructor(remote: MessageFeedbackRemote, sessionId: SessionId);
50
+ constructor(ctx: ClientContext, sessionId: SessionId);
74
51
  /** Return the cached immutable view. */
75
52
  getSnapshot: () => MessageFeedbackView;
76
53
  /** Subscribe to view replacement. */
@@ -146,8 +123,7 @@ export declare class MessageFeedbackController implements HostObservable<Message
146
123
  private load;
147
124
  /**
148
125
  * Serialize one mutation behind this Session's prior mutation so queued
149
- * operations always compare against the committed version, and translate a
150
- * transport throw into the same settled shape the controls already render.
126
+ * operations always compare against the committed version.
151
127
  */
152
128
  private mutate;
153
129
  /**
@@ -7,7 +7,7 @@
7
7
  * @module @prettier-ai/dsh-client-ui-message-feedback/client
8
8
  */
9
9
  import type { Context as ClientContext } from '@prettier-ai/cordis';
10
- export type { MessageFeedbackActionResult, MessageFeedbackStatus, MessageFeedbackView, MessageFeedbackRemote, } from './controller.ts';
10
+ export type { MessageFeedbackActionResult, MessageFeedbackStatus, MessageFeedbackView, } from './controller.ts';
11
11
  export type { MessageFeedbackActionProps, MessageFeedbackInjected } from './slots.ts';
12
12
  export type { MessageFeedbackKey } from './locales.ts';
13
13
  /** Required services: the slot registry, the Remote namespace, and the copy. */
@@ -8,7 +8,7 @@
8
8
  * @module @prettier-ai/dsh-client-ui-message-feedback/client/slots
9
9
  */
10
10
  import type { HostObservable, InjectFace, PropsLocale, PropsRuntime } from '@prettier-ai/dsh-client-ui-slots';
11
- import type { MessageId } from '@prettier-ai/dsh-client-connection/client';
11
+ import type { MessageId } from '@prettier-ai/dsh-api-remotes/client';
12
12
  import type { MessageFeedbackRating } from '@prettier-ai/dsh-message-feedback/types';
13
13
  import type { MessageFeedbackActionResult, MessageFeedbackView } from './controller.ts';
14
14
  /** Injected business face of one assistant-message feedback entry. */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prettier-ai/dsh-client-ui-message-feedback",
3
3
  "description": "Per-message feedback controls contributed to the assistant-message action strip, backed by the messageFeedback Host Remote",
4
- "version": "0.1.2-alpha.1",
4
+ "version": "0.1.2-alpha.3",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -42,18 +42,7 @@
42
42
  },
43
43
  "license": "MIT",
44
44
  "peerDependencies": {
45
- "@prettier-ai/dsh-api-remotes": "^0.1.2-alpha.1",
46
- "@prettier-ai/dsh-client-connection": "^0.1.2-alpha.1",
47
- "@prettier-ai/dsh-client-locale": "^0.1.2-alpha.1",
48
- "@prettier-ai/dsh-client-ui-renderer": "^0.1.2-alpha.1",
49
- "@prettier-ai/dsh-client-ui-conversation": "^0.1.2-alpha.1",
50
- "@prettier-ai/dsh-message-feedback": "^0.1.2-alpha.1",
51
- "@prettier-ai/dsh-session": "^0.1.2-alpha.1",
52
- "@prettier-ai/dsh-invariants": "^0.1.2-alpha.1",
53
- "@prettier-ai/cordis": "^4.0.1",
54
- "@prettier-ai/dsh-typert-protocol": "^0.1.2-alpha.1",
55
- "@prettier-ai/dsh-client-ui-chat": "^0.1.2-alpha.1",
56
- "@prettier-ai/dsh-client-ui-session": "^0.1.2-alpha.1"
45
+ "@prettier-ai/cordis": "^4.0.2"
57
46
  },
58
47
  "devDependencies": {
59
48
  "@testing-library/react": "^16.1.0",
@@ -61,21 +50,21 @@
61
50
  "@types/react-dom": "~18.3.0",
62
51
  "react": "^18.2.0",
63
52
  "react-dom": "^18.2.0",
64
- "@prettier-ai/dsh-api-remotes": "^0.1.2-alpha.1",
65
- "@prettier-ai/dsh-client-connection": "^0.1.2-alpha.1",
66
- "@prettier-ai/dsh-client-test-runtime": "^0.1.2-alpha.1",
67
- "@prettier-ai/dsh-client-ui-conversation": "^0.1.2-alpha.1",
68
- "@prettier-ai/dsh-client-locale": "^0.1.2-alpha.1",
69
- "@prettier-ai/dsh-client-ui-primitives": "^0.1.2-alpha.1",
70
- "@prettier-ai/dsh-client-ui-renderer": "^0.1.2-alpha.1",
71
- "@prettier-ai/dsh-client-ui-slots": "^0.1.2-alpha.1",
72
- "@prettier-ai/dsh-invariants": "^0.1.2-alpha.1",
73
- "@prettier-ai/dsh-typert-protocol": "^0.1.2-alpha.1",
74
- "@prettier-ai/cordis": "^4.0.1",
75
- "@prettier-ai/dsh-client-ui-chat": "^0.1.2-alpha.1",
76
- "@prettier-ai/dsh-message-feedback": "^0.1.2-alpha.1",
77
- "@prettier-ai/dsh-session": "^0.1.2-alpha.1",
78
- "@prettier-ai/dsh-client-ui-session": "^0.1.2-alpha.1"
53
+ "@prettier-ai/dsh-client-connection": "^0.1.2-alpha.3",
54
+ "@prettier-ai/dsh-client-locale": "^0.1.2-alpha.3",
55
+ "@prettier-ai/dsh-client-ui-primitives": "^0.1.2-alpha.3",
56
+ "@prettier-ai/dsh-client-test-runtime": "^0.1.2-alpha.3",
57
+ "@prettier-ai/dsh-api-remotes": "^0.1.2-alpha.3",
58
+ "@prettier-ai/dsh-client-ui-conversation": "^0.1.2-alpha.3",
59
+ "@prettier-ai/dsh-client-ui-renderer": "^0.1.2-alpha.3",
60
+ "@prettier-ai/dsh-invariants": "^0.1.2-alpha.3",
61
+ "@prettier-ai/dsh-client-ui-slots": "^0.1.2-alpha.3",
62
+ "@prettier-ai/dsh-message-feedback": "^0.1.2-alpha.3",
63
+ "@prettier-ai/dsh-typert-protocol": "^0.1.2-alpha.3",
64
+ "@prettier-ai/cordis": "^4.0.2",
65
+ "@prettier-ai/dsh-session": "^0.1.2-alpha.3",
66
+ "@prettier-ai/dsh-client-ui-session": "^0.1.2-alpha.3",
67
+ "@prettier-ai/dsh-client-ui-chat": "^0.1.2-alpha.3"
79
68
  },
80
69
  "files": [
81
70
  "lib/index.js",