@stefan.inc/feedback-engine 1.10.1 → 1.11.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/README.md CHANGED
@@ -245,6 +245,7 @@ Choosing **ProcrastiMate** opens a popup on `https://procrastimate.stf.lol/feedb
245
245
  - `space` names another user's ProcrastiMate user id when two spaces share the same project name; leave it out to match across the signed-in user's own and edit-shared projects.
246
246
  - `app` points at another ProcrastiMate origin if you self-host or run locally.
247
247
  - Each project in the picker has a ↗ link to its page in ProcrastiMate (`/projects/<id>`), which opens in a new tab.
248
+ - The task's name starts as the screen's name, `Feedback`, and the item count, such as `Groceries Feedback: 3 changes`. Left as it is, ProcrastiMate's server summarizes the items about a second after the post and renames the task, such as `3 Groceries Feedback: bigger titles, remove the share button`. A name typed in the popup is kept.
248
249
 
249
250
  ## How capture works
250
251
 
@@ -262,7 +263,7 @@ Choosing **ProcrastiMate** opens a popup on `https://procrastimate.stf.lol/feedb
262
263
  - A minified production build shows a class's minified name in component data, such as `a(count: 2)`.
263
264
  - Element locations for untagged content exist only in development builds, unless a React app turns on `elementSources`. Components keep theirs in every build.
264
265
  - React: a capture reads fields that are internal to React, the ones React's own developer tools read. If React renames them, components found without a tag are missing, and tagged regions and elements still appear. Bundlers other than Vite and Next.js are not supported.
265
- - A shake does not trigger Feedback on phones, where a three-finger hold, `button: true`, or `countdown()` from a menu stands in for it, and the task name is not summarized by an on-device model. [spec/features.md](https://github.com/smirea/feedback-engine/blob/master/spec/features.md) lists both as planned.
266
+ - A shake does not trigger Feedback on phones, where a three-finger hold, `button: true`, or `countdown()` from a menu stands in for it. [spec/features.md](https://github.com/smirea/feedback-engine/blob/master/spec/features.md) lists it as planned.
266
267
 
267
268
  ## Drive it from a script
268
269
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stefan.inc/feedback-engine",
3
- "version": "1.10.1",
3
+ "version": "1.11.0",
4
4
  "description": "In-app feedback for Svelte and React: point at a component, write what should change, and export its name, file:line, and data for an agent.",
5
5
  "keywords": [
6
6
  "accessibility",
@@ -1,31 +1,37 @@
1
1
  import type { FeedbackItem } from './annotations.ts';
2
2
  import { title, type Capture } from './model.ts';
3
3
 
4
+ /** @deprecated ProcrastiMate's server names the task now, from `suggestion`. Removed in the next major version. */
4
5
  export const taskTitleInstructions =
5
6
  'You name tasks for a developer. Given feedback items about an app screen, reply with one lowercase phrase of at ' +
6
7
  'most 8 words that covers every item, such as "bigger titles, remove the share button". No quotes, no trailing ' +
7
8
  'period, no preamble.';
8
9
 
9
- /** A ProcrastiMate task's name: `<screen> Feedback: N changes` at first, then `N <screen> Feedback: <summary>` once a model has summarized the items. */
10
+ /**
11
+ * A ProcrastiMate task's name, `<screen> Feedback: N changes`, and the `suggestion` a post carries while the name is
12
+ * untouched, from which ProcrastiMate's server renames the task `N <screen> Feedback: <summary>`.
13
+ */
10
14
  export function taskTitle(capture: Capture, items: FeedbackItem[]) {
11
15
  const subject = [capture.screenName ?? capture.environment.find(entry => entry.name === 'App')?.value, 'Feedback']
12
16
  .filter(Boolean)
13
17
  .join(' ');
14
18
  const count = items.length;
19
+ const prompt = items
20
+ .map(
21
+ item =>
22
+ `- On ${title(capture.nodes[item.target]!)}: ${item.text
23
+ .split(/[\r\n]+/)
24
+ .filter(Boolean)
25
+ .join(' ')}`,
26
+ )
27
+ .join('\n');
15
28
  return {
16
29
  subject,
17
30
  count,
18
- prompt: items
19
- .map(
20
- item =>
21
- `- On ${title(capture.nodes[item.target]!)}: ${item.text
22
- .split(/[\r\n]+/)
23
- .filter(Boolean)
24
- .join(' ')}`,
25
- )
26
- .join('\n'),
31
+ prompt,
27
32
  placeholder: `${subject}: ${count} ${count === 1 ? 'change' : 'changes'}`,
28
- /** The model's reply on one line without the wrapping it sometimes adds. `undefined` when nothing is left, so the placeholder stays. */
33
+ suggestion: { subject, count, prompt },
34
+ /** @deprecated ProcrastiMate's server summarizes now. Removed in the next major version. */
29
35
  summarized(reply: string) {
30
36
  const line = reply.split(/[\r\n]+/).find(Boolean) ?? '';
31
37
  const summary = line.replace(/^[\s"'“”‘’`*]+|[\s"'“”‘’`*]+$/g, '').replace(/^[.\s]+|[.\s]+$/g, '');
@@ -127,6 +127,7 @@ export function runOnLightClick(event: MouseEvent | undefined, action: () => voi
127
127
  export function openProcrastimatePopup({
128
128
  config,
129
129
  title,
130
+ titleSuggestion,
130
131
  app,
131
132
  screen,
132
133
  annotations,
@@ -137,6 +138,8 @@ export function openProcrastimatePopup({
137
138
  }: {
138
139
  config: ProcrastimateConfig;
139
140
  title: string;
141
+ /** What ProcrastiMate names the task from, if the popup keeps `title`. */
142
+ titleSuggestion: { subject: string; count: number; prompt: string };
140
143
  app?: string;
141
144
  screen: Screen;
142
145
  annotations: Annotations;
@@ -213,6 +216,7 @@ export function openProcrastimatePopup({
213
216
  type: FEEDBACK_DRAFT,
214
217
  nonce,
215
218
  title,
219
+ titleSuggestion,
216
220
  app,
217
221
  project: config.project,
218
222
  projects: config.projects,
@@ -291,6 +291,7 @@
291
291
  popup = openProcrastimatePopup({
292
292
  config,
293
293
  title: names.placeholder,
294
+ titleSuggestion: names.suggestion,
294
295
  app: engine.options.app ?? (document.title.trim() || undefined),
295
296
  screen,
296
297
  annotations: session.annotations,