@e-llm-studio/feedback-flow

中文文档
0.1.65发布于 2026/10/30TypeScriptESM + CJS近 30 天下载 3080

Reusable configurable feedback rating and progressive feedback screens

原始使用文档
文档目录4 节
  1. Install
  2. Quick start
  3. Customize
  4. Lower-level composition

@e-llm-studio/feedback-flow

Reusable React components for star ratings and progressive feedback. The package includes the prompt, follow-up screens, persistence helpers, and optional feature-details lookup. Its stylesheet is imported by the package entry point.

Install

Install @e-llm-studio/feedback-flow alongside its peer dependencies: react, react-dom, and lucide-react.

Quick start

FeedbackExperience provides the complete flow. Pass a FeedbackApi to persist feedback to your backend; if api is omitted, the package uses browser-local mock storage instead. The HTTP adapter uses the API only, not localStorage.

import {
  FeedbackExperience,
  createFeedbackTheme,
  createHttpFeedbackApi,
  createHttpFeatureAvailabilityApi,
} from '@e-llm-studio/feedback-flow';

const getAuthToken = () => authStore.getState().token ?? undefined;
const feedbackApi = createHttpFeedbackApi({
  baseUrl: apiBaseUrl,
  getAuthToken,
});
const featureAvailabilityApi = createHttpFeatureAvailabilityApi({
  baseUrl: apiBaseUrl,
  getAuthToken,
});

export function FeatureFeedback() {
  return (
    <FeedbackExperience
      api={feedbackApi}
      featureId={featureId}
      featureAvailabilityApi={featureAvailabilityApi}
      featureAvailabilityModeId={modeId}
      userEmail={userEmail}
      environment="dev"
      tracking={{ mode: 'My mode', modeId, featureContext: 'my-feature' }}
      copy={{
        prompt: 'Was this feature Helpful?',
        usefulTitle: 'What worked well?',
        gapTitle: 'What should we improve?',
      }}
      theme={createFeedbackTheme({ accent: '#6025e5' })}
    />
  );
}

The example assumes authStore, apiBaseUrl, featureId, modeId, and userEmail come from your host app. Keep adapters outside the component when their configuration is stable. The feature-details adapter and mode ID are optional: the card remains visible if the feature is missing or the lookup fails. While ui_new_ttl is in the future, the card shows a New badge; expiry removes only the badge. start_date and end_date do not currently control visibility.

Each feature-card mount starts a fresh feedback form. The clock button in its modal loads earlier forms from the supplied API; today's forms can be reopened for editing, while older forms are shown read-only. FeedbackApi.listFeedback supplies that history (createHttpFeedbackApi implements it). The same-day edit restriction is enforced by this UI; the backend should enforce it too if updates can be called directly.

Feature cards use ratingCardLayout="vertical" by default, with the badge and prompt above the stars. Set ratingCardLayout="horizontal" to put the badge, prompt, and stars on one line. Give the horizontal card enough room in its host container.

For a chat response, pass a stable requestId and include its backend queryId and sessionId in metadata. A response with requestId does not call the feature-availability API.

Customize

  • copy overrides built-in questions, labels, hints, placeholders, and options. usefulMinimumWords defaults to five.
  • theme, styles, and classNames control colors and presentation. slots adds content to the rating, time, gap, or success screen.
  • tracking adds host context to saved metadata; use custom for additional fields. onSubmit runs after a successful save.
  • createFeedbackScreenshotUploader and createFeedbackScreenshotUrlResolver can be supplied to createHttpFeedbackApi when the host supports attachments.
  • captureScreenshot lets a host capture the current tab. It should return an image File, Blob, or PNG/JPEG/WebP data URL; return null if cancelled. Without it, the library uses the browser's screen-sharing picker.

For an extension, capture in its background/service worker and pass the result through extension messaging. The library hides its modal before calling the adapter:

<FeedbackExperience
  // ...other props
  captureScreenshot={async () => {
    const result = await chrome.runtime.sendMessage({ type: 'ECG_CAPTURE_FEEDBACK_TAB' });
    if (result.error) throw new Error(result.error);
    return result.dataUrl ?? null;
  }}
/>

The extension must implement that message handler using chrome.tabs.captureVisibleTab and have the required tab/host permission. If the React UI runs in a regular web page rather than an extension context, bridge the request through a content script instead of calling chrome.runtime from the page.

These options customize the existing flow; adding new fields or changing its branching requires custom host UI or a library change.

Lower-level composition

For response/query feedback, pass queryId directly instead of featureId:

<FeedbackExperience
  queryId={queryId}
  requestId={requestId}
  sessionId={sessionId}
  userEmail={userEmail}
  environment="dev"
  api={feedbackApi}
/>

requestId and sessionId are optional correlation identifiers. Feature feedback uses featureId; query feedback uses queryId. Use metadata for extra application fields and tracking for mode/feature context. Lower-level callers can use useFeedbackFlow({ queryId, requestId, sessionId, userEmail, environment }) or useFeedbackFlow({ featureId, userEmail, environment }). The older positional hook signature is retained for existing consumers.

Pass the deployment environment through metadata={{ environment: "stage" }} or tracking={{ environment: "stage" }}. Saves default to dev when no environment is supplied. The cw-core integration reads config.VITE_CURRENT_ENV; the remote feature wrapper also accepts an environment prop.

Ratings below 4 do not create a feedback form or upload attachments until the user completes the gaps step. Selecting a low rating or dismissing that step alone does not save it.

For independent prompt/modal placement, use useFeedbackFlow, FeedbackPrompt, and FeedbackModal with the same flow controller and an anchorRef. Use useFeedbackPersistence with a FeedbackApi to load and save feedback, and wire its save handlers to the modal. FeedbackExperience handles this wiring for the standard layout.

The package exports createFeedbackCopy, createFeedbackTheme, createFeedbackMetadata, and the related types for deeper customization. mockFeedbackApi and createMockFeatureAvailabilityApi are available for demos and tests; they are not required when the host supplies real adapters.

版本与发布记录

@e-llm-studio/feedback-flow 共发布 33 个版本,首次发布于 2026/10/09;过去 12 个月发布了 33 个版本。

版本发布日期距今
0.1.65latest2026/10/3013 天前
0.1.642026/10/2816 天前
0.1.632026/10/2816 天前
0.1.622026/10/2816 天前
0.1.602026/10/2717 天前
0.1.592026/10/2617 天前

关于 @e-llm-studio/feedback-flow 的常见问题

@e-llm-studio/feedback-flow 是什么?

Reusable configurable feedback rating and progressive feedback screens

如何安装 @e-llm-studio/feedback-flow?

在项目目录运行 npm install @e-llm-studio/feedback-flow,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(>=18.0.0 <20.0.0)、react-dom(>=18.0.0 <20.0.0)、lucide-react(>=0.474.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@e-llm-studio/feedback-flow 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@e-llm-studio/feedback-flow 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@e-llm-studio/feedback-flow 可以商用吗?

@e-llm-studio/feedback-flow 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@e-llm-studio/feedback-flow 的下载量有多少?

根据 npm 官方下载统计,@e-llm-studio/feedback-flow 在 2026/10/13 – 2026/11/11 这 30 天内被下载 3,080 次,日均约 103 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@e-llm-studio/feedback-flow 还在维护吗?

最新版本 0.1.65 发布于 2026/10/30(13 天前);至今共发布 33 个版本,其中过去 12 个月发布了 33 个;首次发布于 2026/10/09。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。