ConversationGoalBanner.tsx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import { memo } from "react";
  2. import { TID_V4_GOAL_BANNER } from "@zcode/shared";
  3. import type { GoalState } from "@zcode/shared/zcode-protocol-v4";
  4. import { useZCodeIntl } from "@/i18n/IntlProvider.js";
  5. export interface ConversationGoalBannerProps {
  6. goal: GoalState;
  7. }
  8. /**
  9. * M4 goal 横幅:展示 sendGoalCommand/resumeGoal 的 goal 状态投影(objective/status/iteration)。
  10. * memo:goal 不变时不随 SessionPane 其他状态重渲染。
  11. */
  12. function ConversationGoalBannerImpl({ goal }: ConversationGoalBannerProps) {
  13. const { intl } = useZCodeIntl();
  14. return (
  15. <div
  16. data-testid={TID_V4_GOAL_BANNER}
  17. data-goal-status={goal.status}
  18. data-goal-objective={goal.objective}
  19. className="flex items-center gap-2 border-b border-[var(--color-border)] bg-[var(--color-surface)] px-3 py-1.5 text-ui-sm"
  20. >
  21. <span className="text-[var(--color-foreground-subtle)]">
  22. {intl.formatMessage({ id: "chat.goalBanner.label" })}
  23. </span>
  24. <span className="min-w-0 flex-1 truncate text-[var(--color-foreground)]">
  25. {goal.objective}
  26. </span>
  27. <span className="shrink-0 rounded border border-[var(--color-border)] px-1.5 py-0.5 text-[var(--color-foreground-subtle)]">
  28. {goal.status} · #{goal.iteration}
  29. </span>
  30. </div>
  31. );
  32. }
  33. export const ConversationGoalBanner = memo(ConversationGoalBannerImpl);