@prettier-ai/dsh-client-ui-message-feedback 0.1.2-alpha.1

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/index.js ADDED
@@ -0,0 +1,11 @@
1
+ //#region lib/types/index.js
2
+ /**
3
+ * Message feedback surface plugin, node half. Pure UI plugin: the empty apply
4
+ * exists so the plugin appears in the host cordis.yml / Loader; the browser
5
+ * half ships via exports["./client"], discovered through the package.json
6
+ * dsh.client declaration.
7
+ */
8
+ /** Host plugin body — no host-side behavior for this surface plugin. */
9
+ function apply() {}
10
+ //#endregion
11
+ export { apply };
@@ -0,0 +1,26 @@
1
+ //#region lib/types/invariant.js
2
+ /**
3
+ * Package-owned invariant companion for `@prettier-ai/dsh-client-ui-message-feedback`.
4
+ * @module @prettier-ai/dsh-client-ui-message-feedback/invariant
5
+ */
6
+ const PACKAGE_NAME = "@prettier-ai/dsh-client-ui-message-feedback";
7
+ /** Cordis companion plugin name. */
8
+ const name = "client-ui-feedback-invariant";
9
+ /** Service required before the companion can reserve package ownership. */
10
+ const inject = ["invariants"];
11
+ /**
12
+ * No runtime invariant: the plugin owns one slot registration and one
13
+ * per-session controller map, both released by the same effect disposer. The
14
+ * lifecycle spec proves the registration is withdrawn and every controller is
15
+ * dropped when the owning fiber is disposed, so no second authority exists to
16
+ * check at runtime.
17
+ */
18
+ const install = () => {};
19
+ /**
20
+ * Register this package's invariant companion.
21
+ * @param ctx - Cordis context carrying the invariant service.
22
+ * @returns the installed registration's disposer after setup succeeds.
23
+ */
24
+ const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
25
+ //#endregion
26
+ export { apply, inject, name };
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Per-message feedback controls: a Like/Dislike pair plus an optional note.
3
+ * The buttons render inside the assistant message's IconActions row, so they
4
+ * reuse that row's chrome and sit between copy and branch. The note editor is
5
+ * a popover (portaled to `document.body`) anchored to the note trigger, not an
6
+ * inline expansion: a 260px textarea plus buttons cannot fit the row at any
7
+ * viewport, and an inline element pushed the branch action and clock out of the
8
+ * conversation column. Portaling out of the column also escapes its `overflow`
9
+ * clip, so the panel cannot be cropped or detached from the message it annotates.
10
+ * @module @prettier-ai/dsh-client-ui-message-feedback/client/MessageFeedbackActions
11
+ */
12
+ import type { MessageFeedbackActionProps } from './slots.ts';
13
+ /**
14
+ * One message's feedback controls.
15
+ * @param props - the owner's message identity, the injected verbs, and the
16
+ * shared feedback hook.
17
+ * @returns the rating buttons and the note trigger, with the note editor
18
+ * portal-open beneath the trigger while it is open.
19
+ */
20
+ export declare function MessageFeedbackActions({ messageId, ensure, rate, toggle, clearNote, useFeedback, t }: MessageFeedbackActionProps): import("react").JSX.Element;
21
+ //# sourceMappingURL=MessageFeedbackActions.d.ts.map
@@ -0,0 +1,163 @@
1
+ /**
2
+ * Browser-local object layer over one Session's durable message-feedback
3
+ * sidecar. The Host owns per-item compare-and-set: every mutation carries the
4
+ * version this controller last observed, and a `version-conflict` reply carries
5
+ * the authoritative item, so a lost race reconciles from the reply itself
6
+ * instead of refetching the whole Session.
7
+ * @module @prettier-ai/dsh-client-ui-message-feedback/client/controller
8
+ */
9
+ import type { RemoteResult } from '@prettier-ai/dsh-typert-protocol';
10
+ import type { HostObservable } from '@prettier-ai/dsh-client-ui-slots';
11
+ import type { MessageId } from '@prettier-ai/dsh-client-connection/client';
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
+ }
37
+ /** Load state of the one list read that seeds every per-message control. */
38
+ export type MessageFeedbackStatus = 'cold' | 'loading' | 'ready' | 'error';
39
+ /** Immutable view published to every per-message control in one Session. */
40
+ export interface MessageFeedbackView {
41
+ status: MessageFeedbackStatus;
42
+ /** Current item per message, keyed by the addressed message id. */
43
+ items: ReadonlyMap<MessageId, MessageFeedbackItem>;
44
+ /** Reason the last load failed, cleared by the next successful load. */
45
+ error: string | null;
46
+ }
47
+ /** Settled action shape rendered by the message-level controls. */
48
+ export type MessageFeedbackActionResult = {
49
+ ok: true;
50
+ } | {
51
+ ok: false;
52
+ error: {
53
+ code: string;
54
+ message: string;
55
+ };
56
+ };
57
+ /**
58
+ * Per-session feedback object layer. One instance backs every per-message
59
+ * control in that Session, so a single list read seeds them all.
60
+ */
61
+ export declare class MessageFeedbackController implements HostObservable<MessageFeedbackView> {
62
+ private readonly remote;
63
+ private readonly sessionId;
64
+ private view;
65
+ private readonly listeners;
66
+ private loadPromise;
67
+ private operationTail;
68
+ private disposed;
69
+ /**
70
+ * @param remote - the messageFeedback Remote namespace.
71
+ * @param sessionId - Session owning every addressed assistant message.
72
+ */
73
+ constructor(remote: MessageFeedbackRemote, sessionId: SessionId);
74
+ /** Return the cached immutable view. */
75
+ getSnapshot: () => MessageFeedbackView;
76
+ /** Subscribe to view replacement. */
77
+ subscribe: (listener: () => void) => (() => void);
78
+ /**
79
+ * Load once; a failed load stays retryable.
80
+ * @returns the settled load result, shared by concurrent callers.
81
+ */
82
+ ensure(): Promise<MessageFeedbackActionResult>;
83
+ /**
84
+ * Re-read the authoritative list, collapsing concurrent callers onto one
85
+ * in-flight read.
86
+ *
87
+ * This is the unserialized read used to seed a cold controller, where no
88
+ * mutation can be in flight yet. A reconnect must use {@link resync} instead:
89
+ * an unserialized list response can otherwise arrive after a newer mutation's
90
+ * reply and overwrite the version that mutation just committed.
91
+ * @returns the settled reload result.
92
+ */
93
+ refresh(): Promise<MessageFeedbackActionResult>;
94
+ /**
95
+ * Re-read the list behind this Session's queued mutations, so a reconnect
96
+ * cannot resurrect a version an in-flight mutation already replaced.
97
+ * @returns the settled reload result.
98
+ */
99
+ resync(): Promise<MessageFeedbackActionResult>;
100
+ /**
101
+ * Create or replace feedback for one message, comparing against the version
102
+ * this controller last observed.
103
+ *
104
+ * The note is resolved here rather than by the caller: `mutate` awaits the
105
+ * one list read first, so this body always sees the committed item, while a
106
+ * control that rendered before that read completed would still be holding
107
+ * `undefined`. Omitting `note` therefore keeps whatever is stored; only
108
+ * {@link clearNote} removes one.
109
+ * @param messageId - target assistant message.
110
+ * @param rating - desired judgment.
111
+ * @param note - replacement explanation; omitted keeps the stored note.
112
+ * @returns the settled mutation result.
113
+ */
114
+ rate(messageId: MessageId, rating: MessageFeedbackRating, note?: string): Promise<MessageFeedbackActionResult>;
115
+ /**
116
+ * Replace one message's rating with the opposite judgment, or retract it when
117
+ * the committed rating already matches. The decision reads the committed item
118
+ * inside the serialized mutation, so a click that lands before the first list
119
+ * read still toggles against the stored value rather than the empty view a
120
+ * cold control rendered.
121
+ * @param messageId - target assistant message.
122
+ * @param rating - the judgment the human asked for.
123
+ * @returns the settled mutation result.
124
+ */
125
+ toggle(messageId: MessageId, rating: MessageFeedbackRating): Promise<MessageFeedbackActionResult>;
126
+ /**
127
+ * Drop the note while keeping the rating. Absent feedback needs no call.
128
+ * @param messageId - target assistant message.
129
+ * @returns the settled mutation result.
130
+ */
131
+ clearNote(messageId: MessageId): Promise<MessageFeedbackActionResult>;
132
+ /**
133
+ * Remove feedback for one message. A message with no known item is already
134
+ * in the requested state, so no call is made.
135
+ * @param messageId - target assistant message.
136
+ * @returns the settled mutation result.
137
+ */
138
+ clear(messageId: MessageId): Promise<MessageFeedbackActionResult>;
139
+ /** Commit one put against the observed version and reconcile a conflict. */
140
+ private putCommitted;
141
+ /** Commit one delete against the observed version and reconcile a conflict. */
142
+ private deleteCommitted;
143
+ /** Drop subscribers and refuse further work when the owning fiber unloads. */
144
+ dispose(): void;
145
+ /** Fetch the whole sidecar and publish it as the seeded view. */
146
+ private load;
147
+ /**
148
+ * 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.
151
+ */
152
+ private mutate;
153
+ /**
154
+ * Replace one message's entry, keeping every other entry's identity. Only a
155
+ * `mutate` operation reaches this, and `mutate` refuses admission once the
156
+ * controller is disposed, so no disposal guard belongs here; `publish` is
157
+ * the single place that stops notifying after listeners are dropped.
158
+ */
159
+ private commit;
160
+ /** Replace the view and contain subscriber failures at the observable boundary. */
161
+ private publish;
162
+ }
163
+ //# sourceMappingURL=controller.d.ts.map
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Message feedback plugin, browser half: the Like/Dislike entry in the
3
+ * conversation.chat.assistant-actions strip. One MessageFeedbackController per
4
+ * Session backs every message control in that Session, so a single list read
5
+ * seeds the whole transcript. Mutations go through the generated
6
+ * messageFeedback Remote; the Host owns per-item compare-and-set.
7
+ * @module @prettier-ai/dsh-client-ui-message-feedback/client
8
+ */
9
+ import type { Context as ClientContext } from '@prettier-ai/cordis';
10
+ export type { MessageFeedbackActionResult, MessageFeedbackStatus, MessageFeedbackView, MessageFeedbackRemote, } from './controller.ts';
11
+ export type { MessageFeedbackActionProps, MessageFeedbackInjected } from './slots.ts';
12
+ export type { MessageFeedbackKey } from './locales.ts';
13
+ /** Required services: the slot registry, the Remote namespace, and the copy. */
14
+ export declare const inject: string[];
15
+ /**
16
+ * Client plugin body: the per-message feedback entry and its per-session
17
+ * object layer.
18
+ * @param ctx - client root context.
19
+ */
20
+ export declare function apply(ctx: ClientContext): void;
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,42 @@
1
+ /** `feedback` namespace dictionaries. */
2
+ /** Simplified Chinese dictionary (the key-set source of truth). */
3
+ export declare const zh: {
4
+ 'action.like': string;
5
+ 'action.likeActive': string;
6
+ 'action.dislike': string;
7
+ 'action.dislikeActive': string;
8
+ 'note.open': string;
9
+ 'note.dialog': string;
10
+ 'note.placeholder': string;
11
+ 'note.save': string;
12
+ 'note.cancel': string;
13
+ 'note.aria': string;
14
+ 'error.conflict': string;
15
+ 'error.load': string;
16
+ 'error.generic': string;
17
+ };
18
+ /** The feedback namespace key union. */
19
+ export type MessageFeedbackKey = keyof typeof zh;
20
+ declare module '@prettier-ai/dsh-client-ui-slots' {
21
+ interface LocaleNamespaceMap {
22
+ /** The per-message feedback controls' copy. */
23
+ feedback: MessageFeedbackKey;
24
+ }
25
+ }
26
+ /** English dictionary, checked complete against the zh key set. */
27
+ export declare const en: {
28
+ 'action.like': string;
29
+ 'action.likeActive': string;
30
+ 'action.dislike': string;
31
+ 'action.dislikeActive': string;
32
+ 'note.open': string;
33
+ 'note.dialog': string;
34
+ 'note.placeholder': string;
35
+ 'note.save': string;
36
+ 'note.cancel': string;
37
+ 'note.aria': string;
38
+ 'error.conflict': string;
39
+ 'error.load': string;
40
+ 'error.generic': string;
41
+ };
42
+ //# sourceMappingURL=locales.d.ts.map
@@ -0,0 +1,50 @@
1
+ /**
2
+ * The feedback entry's injected face. The target
3
+ * 'conversation.chat.assistant-actions' slot is declared and typed by
4
+ * ui-conversation; this package only contributes the entry, so no SlotMap
5
+ * merge lives here. Live per-message state arrives through the `feedback`
6
+ * hook (the framework standard kit binds it into `useFeedback`); inject
7
+ * carries the two mutation verbs plus the lazy loader.
8
+ * @module @prettier-ai/dsh-client-ui-message-feedback/client/slots
9
+ */
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';
12
+ import type { MessageFeedbackRating } from '@prettier-ai/dsh-message-feedback/types';
13
+ import type { MessageFeedbackActionResult, MessageFeedbackView } from './controller.ts';
14
+ /** Injected business face of one assistant-message feedback entry. */
15
+ export interface MessageFeedbackInjected {
16
+ hooks: {
17
+ /** The owning Session's feedback view, shared by every message control. */
18
+ feedback: HostObservable<MessageFeedbackView>;
19
+ };
20
+ /** Load the Session's feedback once, on first interaction. */
21
+ ensure: () => Promise<MessageFeedbackActionResult>;
22
+ /**
23
+ * Create or replace this Session's feedback for one message.
24
+ * @param messageId - target assistant message.
25
+ * @param rating - desired judgment.
26
+ * @param note - optional explanation.
27
+ */
28
+ rate: (messageId: MessageId, rating: MessageFeedbackRating, note?: string) => Promise<MessageFeedbackActionResult>;
29
+ /**
30
+ * Apply the requested judgment, retracting instead when the committed rating
31
+ * already matches. The controller decides from the committed item, so a click
32
+ * before the first list read still toggles the stored value.
33
+ * @param messageId - target assistant message.
34
+ * @param rating - the judgment the human asked for.
35
+ */
36
+ toggle: (messageId: MessageId, rating: MessageFeedbackRating) => Promise<MessageFeedbackActionResult>;
37
+ /**
38
+ * Drop the note while keeping the rating.
39
+ * @param messageId - target assistant message.
40
+ */
41
+ clearNote: (messageId: MessageId) => Promise<MessageFeedbackActionResult>;
42
+ /**
43
+ * Remove this Session's feedback for one message.
44
+ * @param messageId - target assistant message.
45
+ */
46
+ clear: (messageId: MessageId) => Promise<MessageFeedbackActionResult>;
47
+ }
48
+ /** Full props of one assistant-message feedback entry. */
49
+ export type MessageFeedbackActionProps = PropsRuntime<'conversation.chat.assistant-actions'> & InjectFace<MessageFeedbackInjected> & PropsLocale<'feedback'>;
50
+ //# sourceMappingURL=slots.d.ts.map
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Message feedback surface plugin, node half. Pure UI plugin: the empty apply
3
+ * exists so the plugin appears in the host cordis.yml / Loader; the browser
4
+ * half ships via exports["./client"], discovered through the package.json
5
+ * dsh.client declaration.
6
+ */
7
+ /** Host plugin body — no host-side behavior for this surface plugin. */
8
+ export declare function apply(): void;
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Package-owned invariant companion for `@prettier-ai/dsh-client-ui-message-feedback`.
3
+ * @module @prettier-ai/dsh-client-ui-message-feedback/invariant
4
+ */
5
+ import type { Context } from '@prettier-ai/cordis';
6
+ /** Cordis companion plugin name. */
7
+ export declare const name = "client-ui-feedback-invariant";
8
+ /** Service required before the companion can reserve package ownership. */
9
+ export declare const inject: string[];
10
+ /**
11
+ * Register this package's invariant companion.
12
+ * @param ctx - Cordis context carrying the invariant service.
13
+ * @returns the installed registration's disposer after setup succeeds.
14
+ */
15
+ export declare const apply: (ctx: Context) => Promise<() => void>;
16
+ //# sourceMappingURL=invariant.d.ts.map
package/package.json ADDED
@@ -0,0 +1,90 @@
1
+ {
2
+ "name": "@prettier-ai/dsh-client-ui-message-feedback",
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",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/deepseek-ai/deepseek-harness.git",
11
+ "directory": "packages/client/ui-message-feedback"
12
+ },
13
+ "type": "module",
14
+ "main": "lib/index.js",
15
+ "types": "lib/types/index.d.ts",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./lib/types/index.d.ts",
19
+ "default": "./lib/index.js"
20
+ },
21
+ "./invariant": {
22
+ "types": "./lib/types/invariant.d.ts",
23
+ "default": "./lib/invariant.js"
24
+ },
25
+ "./client": {
26
+ "types": "./lib/types/client/index.d.ts",
27
+ "default": "./lib/client.js"
28
+ },
29
+ "./src/*": "./src/*",
30
+ "./package.json": "./package.json"
31
+ },
32
+ "dsh": {
33
+ "client": {
34
+ "inject": [
35
+ "@prettier-ai/dsh-api-remotes",
36
+ "@prettier-ai/dsh-client-locale",
37
+ "@prettier-ai/dsh-client-ui-conversation",
38
+ "@prettier-ai/dsh-client-ui-renderer"
39
+ ],
40
+ "platform": "web"
41
+ }
42
+ },
43
+ "license": "MIT",
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"
57
+ },
58
+ "devDependencies": {
59
+ "@testing-library/react": "^16.1.0",
60
+ "@types/react": "~18.3.1",
61
+ "@types/react-dom": "~18.3.0",
62
+ "react": "^18.2.0",
63
+ "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"
79
+ },
80
+ "files": [
81
+ "lib/index.js",
82
+ "lib/invariant.js",
83
+ "lib/client.js",
84
+ "lib/types/**/*.d.ts"
85
+ ],
86
+ "scripts": {
87
+ "bundle": "tsdown",
88
+ "watch": "tsdown --watch"
89
+ }
90
+ }