@botiverse/hands-feedback-react

中文文档
0.5.2发布于 2026/10/27MITTypeScriptES Module构建来源已验证近 30 天下载 1.3万

Embeddable reporter-facing Hands feedback inbox components.

原始使用文档

@botiverse/hands-feedback-react

Reporter-facing Hands feedback components. The package renders a ticket inbox, conversation detail, reply composer, and new-feedback form using the Raft design system (@botiverse/raft-ui, from botiverse/raft-design). There is a single Raft look: the old elegant / brutal theme families are gone and are no longer selectable here.

import {
  FeedbackProvider,
  FeedbackWorkspace,
  type HandsFeedbackTransport,
} from "@botiverse/hands-feedback-react";
import "@botiverse/raft-ui/styles.css";
import "@botiverse/hands-feedback-react/styles.css";

// Implement this in your app. It calls your authenticated same-origin proxy;
// the complete adapter is in the integration guide linked below.
const transport: HandsFeedbackTransport =
  createMyAppFeedbackTransport("/api/feedback");

<FeedbackProvider
  transport={transport}
  // Optional. Without this override the SDK maps browser `zh*` to `zh-CN`
  // and falls back to English. Pass the host app's selected locale when set.
  locale="en"
  onUnreadChanged={({ total }) => setFeedbackBadge(total)}
>
  <FeedbackWorkspace />
</FeedbackProvider>;

The workspace owns the reporter interaction state: list filter/scroll/focus restoration, per-ticket reply drafts, IME-safe Enter handling, attachment progress/retry/cancel, recoverable cursor pages, and near-bottom conversation following. Hosts should not duplicate that state machine. They provide only the reporter-scoped transport, route notifications, and (optionally) an attachment opener.

On mobile, hosts can bind those workspace notifications to real browser URLs and enable the package's touch-only pull-to-refresh behavior:

<FeedbackWorkspace
  route={routeFromLocation(location)}
  onRouteChange={(nextRoute, options) =>
    navigate(pathForRoute(nextRoute), { replace: options?.replace })
  }
  enablePullToRefresh={isMobile}
/>

inbox, new, and ticket are the supported workspace routes. The SDK marks the create-success transition from new to ticket with replace: true, so Back does not reopen a submitted form. Pull-to-refresh is attached only to the list and conversation scroll viewports, starts only at scroll-top, ignores editable controls, and preserves existing content while authoritative data is reloaded. The generic usePullToRefresh hook is also exported for other host scroll surfaces.

All visible copy, closed error copy, dates, and accessibility labels share the SDK locale. Supported locales are en and zh-CN; an explicit provider locale takes precedence over browser language detection.

Localization is provider-driven rather than limited to the built-in bundles. messages accepts a typed partial override (missing keys fall back to the resolved locale), including parameterized validation strings. formatDate and formatFileSize let the host apply its own formatting conventions without rebuilding SDK UI. Browser negotiation selects the first supported entry in navigator.languages order, then falls back to English.

<FeedbackProvider
  transport={transport}
  locale={appLocale}
  messages={{
    newFeedback: t("feedback.new"),
    attachmentUnsupported: t("feedback.attachmentUnsupported"), // `{name}`
  }}
  formatDate={(date, { locale }) => appDateFormatter(date, locale)}
  formatFileSize={(bytes, { locale }) => appFileSizeFormatter(bytes, locale)}
>
  <FeedbackWorkspace />
</FeedbackProvider>

Host-staged attachments

A host may put one small file (for example a validated diagnostic snapshot) into the reporter's pending attachments. Prepare the File first (any async fetch/validation happens before this click), then call the handle synchronously from the click handler:

const workspace = useRef<FeedbackWorkspaceHostHandle>(null);

<button
  onClick={() => {
    // No `await` before this call: it needs the live user gesture.
    const result = workspace.current?.openNewFeedbackWithPendingFile({
      file: preparedDiagnosticFile,
    });
    if (result && !result.ok) showReason(result.reason);
  }}
>
  Report issue with diagnostic
</button>
<FeedbackWorkspace
  ref={workspace}
  onOpenPendingAttachment={({ file }) => previewInHost(file)}
/>
  • openNewFeedbackWithPendingFile({ file }) opens the new-feedback form with the file already pending in the same call. If the form is already open, it adds the file there. It is synchronous and returns a typed result.
  • attachPendingFile({ file }) is the low-level variant: it only stages into an already open form and returns composer_closed otherwise.

The contract (both methods):

  • Stage only. They never upload or submit. The reporter sees the file, can open it (via onOpenPendingAttachment, including non-image files), can remove it, and it is sent only when they press Submit.
  • User gesture required. Without transient browser user activation (navigator.userActivation.isActive) they return user_activation_required and change nothing, including the route.
  • Bytes only. Input is exactly { file: File }. No paths, URLs, callbacks, or background fetches.
  • Bounded. At most MAX_FEEDBACK_HOST_ATTACHMENTS (1) host file, MAX_FEEDBACK_HOST_ATTACHMENT_BYTES (1 MiB), types in FEEDBACK_HOST_ATTACHMENT_TYPES (the screenshot image types plus application/json and text/plain), and it counts toward the shared 3-attachment limit. The same file (name, type, size, lastModified) is rejected as duplicate.
  • Typed rejection, zero mutation. Failures return { ok: false, reason } (FeedbackHostAttachmentRejection) and do not navigate, change the pending list, show an error banner, or upload anything. busy means a submission is in flight.

Your Hands app and transport must accept the injected MIME type. The Hands public submit endpoint accepts any type. Reporter replies accept only images, which is why host files go to the new-feedback form only.

Security boundary

  • The package has no appToken, clientSecret, reporterId, or arbitrary owner prop.
  • The host transport binds a short-lived reporter-scoped session.
  • Hands is authoritative for tickets and read/unread state. unreadTotal comes from Hands responses; the component never derives or persists its own read cursor.
  • A detail request reports and clears unread only after its successful Hands response. Failed, aborted, stale, and unmounted reads do not mutate unread.
  • Webhooks are optional server-to-server integrations and are not required for inbox correctness.

Consumers using Tailwind v4 should include the compiled package as a source if their build purges library classes:

@source '../node_modules/@botiverse/raft-ui/dist';
@source '../node_modules/@botiverse/hands-feedback-react/dist';

For a source-pinned integration before an npm release, install this package's Hands monorepo subdirectory with pnpm's path: git selector, then import the explicit source exports:

pnpm add "github:botiverse/hands#<full-commit-sha>&path:packages/feedback-react"
pnpm add react react-dom @botiverse/raft-ui lucide-react
import {
  FeedbackProvider,
  FeedbackWorkspace,
} from "@botiverse/hands-feedback-react/source";
import "@botiverse/hands-feedback-react/source/styles.css";

The host bundler must support TypeScript/TSX dependencies. Published consumers should use the compiled root exports shown above.

The complete server credential, opaque reporter identity, route binding, proxy, transport, webhook, and production-checklist walkthrough is in the React Feedback Inbox guide.

版本与发布记录

@botiverse/hands-feedback-react 共发布 9 个版本,首次发布于 2026/09/29;过去 12 个月发布了 9 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.5.2latest2026/10/2712 天前
0.5.12026/10/2217 天前
0.5.02026/10/2217 天前
0.4.42026/10/1721 天前
0.4.32026/10/1227 天前
0.4.22026/10/1127 天前

关于 @botiverse/hands-feedback-react 的常见问题

@botiverse/hands-feedback-react 是什么?

Embeddable reporter-facing Hands feedback inbox components.

如何安装 @botiverse/hands-feedback-react?

在项目目录运行 npm install @botiverse/hands-feedback-react,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^19.0.0)、react-dom(^19.0.0)、lucide-react(>=0.575.0 <2.0.0)、@botiverse/raft-ui(>=0.20.0 <1.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@botiverse/hands-feedback-react 支持 TypeScript 吗?

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

@botiverse/hands-feedback-react 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@botiverse/hands-feedback-react 可以商用吗?

@botiverse/hands-feedback-react 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@botiverse/hands-feedback-react 的下载量有多少?

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

@botiverse/hands-feedback-react 还在维护吗?

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