refactor(AGC 工作台): 聊天发布入口 prop 改名 onRequestPublish

- 该 prop 语义早已是「打开发布面板」而非导出,onRequestExport 名不符实
- 全链路 5 个文件机械改名,按钮文案仍是「发布」,行为不变
This commit is contained in:
2026-10-07 19:27:02 +08:00
parent 74bc3d5126
commit 1990266171
5 changed files with 17 additions and 17 deletions
+1 -1
View File
@@ -1820,7 +1820,7 @@ export function App({
ensureConversationReadAllowed={ensureDirectHistoryReadAllowed}
ensureConversationWriteAllowed={ensureDirectTurnWriteAllowed}
initialTurn={initialDirectTurn}
onRequestExport={
onRequestPublish={
exportProjectPath ? () => setExportPanelOpen(true) : undefined
}
onCancelConfirmation={cancelUiCommandConfirmation}
@@ -76,7 +76,7 @@ export type DirectProjectChatViewProps = {
/** 项目对话写权限门:只在发起回合时检查;同样必填,缺省会让未传入的调用方静默跳过授权。 */
ensureConversationWriteAllowed: DirectProjectConversationWriteGate;
/** 发布入口:由工作台壳持有发布面板,聊天只提供触发按钮。 */
onRequestExport?: () => void;
onRequestPublish?: () => void;
/**
* 工作台壳入队的项目权限确认:聊天只展示并转发确认/取消,
* 策略读取、拒绝判定和确认后的动作仍由工作台壳持有。
@@ -89,7 +89,7 @@ export type DirectProjectChatViewProps = {
};
export function DirectProjectChatView({
onRequestExport,
onRequestPublish,
onConfirmConfirmation,
onCancelConfirmation,
pendingConfirmation = null,
@@ -227,7 +227,7 @@ export function DirectProjectChatView({
turnStatus={turnStatus}
activeTurnStartedAt={activeTurnStartedAt}
statusText={statusText}
{...(onRequestExport ? { onRequestExport } : {})}
{...(onRequestPublish ? { onRequestPublish } : {})}
{...(pendingConfirmation ? { pendingConfirmation } : {})}
{...(onConfirmConfirmation ? { onConfirmConfirmation } : {})}
{...(onCancelConfirmation ? { onCancelConfirmation } : {})}
@@ -52,7 +52,7 @@ export type DirectProjectChatBoxProps = {
turnStatus: DirectProjectTurnStatus;
activeTurnStartedAt: number;
statusText: string;
onRequestExport?: () => void;
onRequestPublish?: () => void;
pendingConfirmation?: PendingUiConfirmation | null;
onConfirmConfirmation?: () => void;
onCancelConfirmation?: () => void;
@@ -74,7 +74,7 @@ export function DirectProjectChatBox({
turnStatus,
activeTurnStartedAt,
statusText,
onRequestExport,
onRequestPublish,
pendingConfirmation = null,
onConfirmConfirmation,
onCancelConfirmation,
@@ -98,7 +98,7 @@ export function DirectProjectChatBox({
busy={turnStatus.displayBusy}
statusText={statusText}
onOpenSettings={() => setSettingsOpen(true)}
{...(onRequestExport ? { onRequestExport } : {})}
{...(onRequestPublish ? { onRequestPublish } : {})}
/>
<DirectProjectConversation
conversationKey={projectPath ?? ''}
@@ -14,13 +14,13 @@ export function DirectProjectChatHeader({
busy,
statusText,
onOpenSettings,
onRequestExport,
onRequestPublish,
}: {
busy: boolean;
statusText: string;
onOpenSettings: () => void;
/** 没有项目时不传;传了才渲染发布入口。 */
onRequestExport?: () => void;
onRequestPublish?: () => void;
}) {
return (
<header className="project-chat-topbar">
@@ -32,14 +32,14 @@ export function DirectProjectChatHeader({
{busy ? '陶泥儿正在处理' : statusText}
</span>
<div className="project-chat-topbar-actions">
{onRequestExport ? (
{onRequestPublish ? (
<button
type="button"
className="project-chat-publish-trigger"
aria-label="发布"
title="发布"
disabled={busy}
onClick={onRequestExport}
onClick={onRequestPublish}
>
<Rocket
size={16}
@@ -18,30 +18,30 @@ function renderHeader(
overrides: Partial<Parameters<typeof DirectProjectChatHeader>[0]> = {},
) {
const onOpenSettings = vi.fn();
const onRequestExport = vi.fn();
const onRequestPublish = vi.fn();
render(
<DirectProjectChatHeader
busy={false}
statusText="就绪"
onOpenSettings={onOpenSettings}
onRequestExport={onRequestExport}
onRequestPublish={onRequestPublish}
{...overrides}
/>,
);
return { onOpenSettings, onRequestExport };
return { onOpenSettings, onRequestPublish };
}
describe('DirectProjectChatHeader', () => {
it('传入发布回调时渲染发布入口并可触发', () => {
const { onRequestExport } = renderHeader();
const { onRequestPublish } = renderHeader();
const publishButton = screen.getByRole('button', { name: '发布' });
fireEvent.click(publishButton);
expect(onRequestExport).toHaveBeenCalledTimes(1);
expect(onRequestPublish).toHaveBeenCalledTimes(1);
});
it('没有发布回调时不渲染发布入口', () => {
renderHeader({ onRequestExport: undefined });
renderHeader({ onRequestPublish: undefined });
expect(screen.queryByRole('button', { name: '发布' })).toBeNull();
expect(screen.getByRole('button', { name: '设置' })).not.toBeNull();