feat: add bounded diagnostics and improve UX feedback
Ask and Execute guidance, Runtime state, live announcements, loading states, retry paths, settings focus, and update failures now provide consistent and accessible feedback across the desktop experience. Add bounded redacted Desktop and Agent diagnostic logs, a read-only Agent diagnostics command, and an explicit opt-in for attaching a small Desktop diagnostic summary to in-app feedback. Diagnostics stay local by default and the existing feedback v1 service contract remains compatible. Release note: 新增可选桌面诊断反馈与 Agent 诊断导出,并统一 Ask/Execute 状态、错误恢复和无障碍反馈;诊断默认保留在本地,仅在用户明确勾选时附加桌面摘要。
This commit is contained in:
+140
-12
@@ -1358,6 +1358,19 @@ describe('App', () => {
|
||||
await screen.findByRole('heading', {
|
||||
name: '今天想一起完成什么?'
|
||||
})
|
||||
const runtimeStatus = document.querySelector<HTMLElement>(
|
||||
'.runtime-status'
|
||||
)
|
||||
expect(runtimeStatus).not.toBeNull()
|
||||
expect(
|
||||
within(runtimeStatus!).getByText('就绪')
|
||||
).toBeInTheDocument()
|
||||
expect(runtimeStatus).toHaveAttribute(
|
||||
'aria-describedby',
|
||||
'topbar-runtime-detail'
|
||||
)
|
||||
expect(screen.getByText('Ready', { selector: '.sr-only' }))
|
||||
.toHaveAttribute('id', 'topbar-runtime-detail')
|
||||
expect(
|
||||
screen.getByText(
|
||||
/你好,我是 GoodBuddy。你可以直接向我提问、添加本地文件/u
|
||||
@@ -2049,6 +2062,25 @@ describe('App', () => {
|
||||
within(conversationList).queryByText('其他项目里的 Alpha')
|
||||
).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
fireEvent.change(search, { target: { value: 'missing topic' } })
|
||||
expect(
|
||||
await within(conversationList).findByText('没有匹配的对话')
|
||||
).toBeInTheDocument()
|
||||
expect(
|
||||
within(conversationList).getByText(
|
||||
'请修改搜索关键词,或清除搜索后查看全部会话。'
|
||||
)
|
||||
).toBeInTheDocument()
|
||||
fireEvent.click(
|
||||
within(conversationList).getByRole('button', {
|
||||
name: '清除搜索'
|
||||
})
|
||||
)
|
||||
expect(search).toHaveValue('')
|
||||
expect(
|
||||
await within(conversationList).findByText('标题里的 Alpha')
|
||||
).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('keeps Settings open when the interface language changes', async () => {
|
||||
@@ -2235,7 +2267,7 @@ describe('App', () => {
|
||||
}
|
||||
})
|
||||
|
||||
it('does not disturb startup when updates are current or offline', async () => {
|
||||
it('keeps current-version checks quiet and reports startup check failures', async () => {
|
||||
const currentResult = {
|
||||
updateAvailable: false,
|
||||
currentVersion: '0.8.4',
|
||||
@@ -2252,7 +2284,11 @@ describe('App', () => {
|
||||
const check = vi
|
||||
.fn()
|
||||
.mockResolvedValueOnce(currentResult)
|
||||
.mockRejectedValueOnce(new Error('offline'))
|
||||
.mockRejectedValueOnce(
|
||||
new Error(
|
||||
"Error invoking remote method 'application:update:check': TypeError: fetch failed"
|
||||
)
|
||||
)
|
||||
api.updates = {
|
||||
getSettings: vi.fn(async () => ({
|
||||
checkUpdatesOnStartup: true,
|
||||
@@ -2289,13 +2325,39 @@ describe('App', () => {
|
||||
render(<App />)
|
||||
await waitFor(() => expect(check).toHaveBeenCalledTimes(2))
|
||||
expect(
|
||||
screen.queryByText(/发现 GoodBuddy|版本检查失败/u)
|
||||
).not.toBeInTheDocument()
|
||||
await screen.findByRole('alert')
|
||||
).toHaveTextContent(
|
||||
'启动更新检查失败(GitHub):无法连接更新源,请检查网络或代理后重试'
|
||||
)
|
||||
} finally {
|
||||
delete api.updates
|
||||
}
|
||||
})
|
||||
|
||||
it('shows a recoverable recent-conversation load failure', async () => {
|
||||
vi.mocked(api.projects.list)
|
||||
.mockRejectedValueOnce(new Error('database busy'))
|
||||
.mockResolvedValueOnce([project])
|
||||
|
||||
render(<App />)
|
||||
|
||||
const loadError = await screen.findByRole('alert')
|
||||
expect(loadError).toHaveTextContent('最近会话加载失败')
|
||||
expect(loadError).toHaveTextContent('database busy')
|
||||
fireEvent.click(
|
||||
within(loadError).getByRole('button', {
|
||||
name: '重新读取会话'
|
||||
})
|
||||
)
|
||||
await waitFor(() =>
|
||||
expect(api.projects.list).toHaveBeenCalledTimes(2)
|
||||
)
|
||||
await waitFor(() =>
|
||||
expect(screen.queryByText('最近会话加载失败'))
|
||||
.not.toBeInTheDocument()
|
||||
)
|
||||
})
|
||||
|
||||
it('keeps rendering when an older preload has no browser bridge', async () => {
|
||||
Object.defineProperty(window, 'goodbuddy', {
|
||||
configurable: true,
|
||||
@@ -4134,9 +4196,10 @@ describe('App', () => {
|
||||
fireEvent.change(await screen.findByLabelText('默认工作区目录'), {
|
||||
target: { value: 'C:\\Unsaved from App' }
|
||||
})
|
||||
fireEvent.click(
|
||||
screen.getByRole('button', { name: '知识库' })
|
||||
)
|
||||
const knowledgeNavigation = screen.getByRole('button', {
|
||||
name: '知识库'
|
||||
})
|
||||
fireEvent.click(knowledgeNavigation)
|
||||
|
||||
expect(
|
||||
screen.getByRole('heading', { name: '设置中心' })
|
||||
@@ -4150,6 +4213,43 @@ describe('App', () => {
|
||||
expect(
|
||||
await screen.findByRole('heading', { name: '知识库' })
|
||||
).toBeVisible()
|
||||
await waitFor(() => expect(knowledgeNavigation).toHaveFocus())
|
||||
})
|
||||
|
||||
it('restores focus outside Settings after closing the page', async () => {
|
||||
render(<App />)
|
||||
|
||||
await screen.findByLabelText('向 GoodBuddy 提问')
|
||||
const settingsTrigger = screen.getByRole('button', {
|
||||
name: /本地工作区/u
|
||||
})
|
||||
fireEvent.click(settingsTrigger)
|
||||
await screen.findByRole('heading', { name: '设置中心' })
|
||||
|
||||
fireEvent.click(
|
||||
screen.getByRole('button', { name: '关闭设置' })
|
||||
)
|
||||
|
||||
await waitFor(() => expect(settingsTrigger).toHaveFocus())
|
||||
})
|
||||
|
||||
it('focuses the Composer after closing automatically opened Settings', async () => {
|
||||
vi.mocked(api.agent.getStatus).mockResolvedValueOnce({
|
||||
id: 'setup',
|
||||
label: '未配置',
|
||||
available: false,
|
||||
supportsToolExecution: false,
|
||||
detail: '尚未配置 Runtime'
|
||||
})
|
||||
render(<App />)
|
||||
|
||||
await screen.findByRole('heading', { name: '设置中心' })
|
||||
const composer = screen.getByLabelText('向 GoodBuddy 提问')
|
||||
fireEvent.click(
|
||||
screen.getByRole('button', { name: '关闭设置' })
|
||||
)
|
||||
|
||||
await waitFor(() => expect(composer).toHaveFocus())
|
||||
})
|
||||
|
||||
it('updates and removes the composer shortcut hint immediately after saving Settings', async () => {
|
||||
@@ -5043,6 +5143,32 @@ describe('App', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('associates attachment errors with the Composer controls', async () => {
|
||||
vi.mocked(api.context.selectFiles).mockRejectedValueOnce(
|
||||
new Error('文件解析失败,请重新选择')
|
||||
)
|
||||
render(<App />)
|
||||
|
||||
const addButton = await screen.findByLabelText('添加附件')
|
||||
const input = screen.getByLabelText('向 GoodBuddy 提问')
|
||||
fireEvent.click(addButton)
|
||||
|
||||
const error = await screen.findByRole('alert', {
|
||||
name: '文件解析失败,请重新选择'
|
||||
})
|
||||
expect(error).toHaveAttribute('id', 'composer-context-error')
|
||||
expect(input).toHaveAttribute('aria-invalid', 'true')
|
||||
expect(input).toHaveAttribute(
|
||||
'aria-describedby',
|
||||
'composer-context-error'
|
||||
)
|
||||
expect(addButton).toHaveAttribute('aria-invalid', 'true')
|
||||
expect(addButton).toHaveAttribute(
|
||||
'aria-describedby',
|
||||
'composer-context-error'
|
||||
)
|
||||
})
|
||||
|
||||
it('sends and renders five selected images together', async () => {
|
||||
const imageAttachments = Array.from({ length: 5 }, (_, index) => ({
|
||||
id: `00000000-0000-4000-8000-00000000031${index}`,
|
||||
@@ -5279,11 +5405,13 @@ describe('App', () => {
|
||||
newConversationListener?.()
|
||||
})
|
||||
|
||||
expect(
|
||||
screen.getAllByRole('button', {
|
||||
name: /^更多会话操作/u
|
||||
})
|
||||
).toHaveLength(2)
|
||||
await waitFor(() =>
|
||||
expect(
|
||||
screen.getAllByRole('button', {
|
||||
name: /^更多会话操作/u
|
||||
})
|
||||
).toHaveLength(2)
|
||||
)
|
||||
})
|
||||
|
||||
it('opens a workspace Markdown file in the right-side preview', async () => {
|
||||
|
||||
+207
-31
@@ -222,7 +222,10 @@ import {
|
||||
type KeepAliveCacheEntry
|
||||
} from './keep-alive-cache'
|
||||
import { activateModalFocus, trapTabFocus } from './dialog-focus'
|
||||
import { displayErrorMessage } from './error-message'
|
||||
import {
|
||||
displayErrorMessage,
|
||||
displayNetworkAwareErrorMessage
|
||||
} from './error-message'
|
||||
import { getProjectDisplayText } from './project-display'
|
||||
|
||||
const knowledgeWorkspaceRoute = createPreloadableComponent(
|
||||
@@ -2304,6 +2307,12 @@ function App(): React.JSX.Element {
|
||||
Record<string, BrowserLiveState>
|
||||
>({})
|
||||
const [view, setViewState] = useState<WorkspaceView>('chat')
|
||||
const settingsEntryFocusRef = useRef<HTMLElement | undefined>(
|
||||
undefined
|
||||
)
|
||||
const settingsExitFocusRef = useRef<HTMLElement | undefined>(
|
||||
undefined
|
||||
)
|
||||
const settingsLeaveRequesterRef = useRef<
|
||||
SettingsLeaveRequester | undefined
|
||||
>(undefined)
|
||||
@@ -2319,6 +2328,7 @@ function App(): React.JSX.Element {
|
||||
)
|
||||
const commitView = useCallback(
|
||||
(next: WorkspaceView): void => {
|
||||
const previous = viewRef.current
|
||||
const now = Date.now()
|
||||
const runningConversationIds = new Set(
|
||||
[...activeRuns.current.values()].map((run) => run.conversationId)
|
||||
@@ -2355,6 +2365,25 @@ function App(): React.JSX.Element {
|
||||
})
|
||||
)
|
||||
setViewState(next)
|
||||
if (previous === 'settings' && next !== 'settings') {
|
||||
const preferred = settingsExitFocusRef.current
|
||||
const returnTarget = settingsEntryFocusRef.current
|
||||
settingsExitFocusRef.current = undefined
|
||||
settingsEntryFocusRef.current = undefined
|
||||
requestAnimationFrame(() => {
|
||||
const target =
|
||||
preferred?.isConnected
|
||||
? preferred
|
||||
: returnTarget?.isConnected
|
||||
? returnTarget
|
||||
: next === 'chat'
|
||||
? inputRef.current
|
||||
: document.querySelector<HTMLElement>(
|
||||
`.primary-nav [aria-current="page"]`
|
||||
)
|
||||
target?.focus()
|
||||
})
|
||||
}
|
||||
},
|
||||
[]
|
||||
)
|
||||
@@ -2364,6 +2393,19 @@ function App(): React.JSX.Element {
|
||||
typeof update === 'function'
|
||||
? update(viewRef.current)
|
||||
: update
|
||||
if (
|
||||
viewRef.current !== 'settings' &&
|
||||
next === 'settings' &&
|
||||
!settingsEntryFocusRef.current?.isConnected
|
||||
) {
|
||||
const activeElement = document.activeElement
|
||||
settingsEntryFocusRef.current =
|
||||
activeElement instanceof HTMLElement &&
|
||||
activeElement !== document.body &&
|
||||
activeElement.isConnected
|
||||
? activeElement
|
||||
: undefined
|
||||
}
|
||||
if (viewRef.current === 'settings' && next !== 'settings') {
|
||||
const requestLeave = settingsLeaveRequesterRef.current
|
||||
if (requestLeave) {
|
||||
@@ -2442,6 +2484,9 @@ function App(): React.JSX.Element {
|
||||
const deferredSearchQuery = useDeferredValue(searchQuery)
|
||||
const [searchConversationSnapshot, setSearchConversationSnapshot] =
|
||||
useState(conversations)
|
||||
const [conversationLoadError, setConversationLoadError] =
|
||||
useState<string>()
|
||||
const [conversationLoadRetry, setConversationLoadRetry] = useState(0)
|
||||
const [conversationActionsId, setConversationActionsId] = useState('')
|
||||
const [confirmingConversationId, setConfirmingConversationId] =
|
||||
useState('')
|
||||
@@ -2629,7 +2674,15 @@ function App(): React.JSX.Element {
|
||||
requestAnimationFrame(() => sidebarToggleRef.current?.focus())
|
||||
}, [])
|
||||
const navigateFromSidebar = useCallback(
|
||||
(nextView: WorkspaceView): void => {
|
||||
(nextView: WorkspaceView, trigger: HTMLElement): void => {
|
||||
if (viewRef.current !== 'settings' && nextView === 'settings') {
|
||||
settingsEntryFocusRef.current = trigger
|
||||
} else if (
|
||||
viewRef.current === 'settings' &&
|
||||
nextView !== 'settings'
|
||||
) {
|
||||
settingsExitFocusRef.current = trigger
|
||||
}
|
||||
setView(nextView)
|
||||
if (narrowWindow) {
|
||||
closeNarrowSidebar()
|
||||
@@ -2849,6 +2902,7 @@ function App(): React.JSX.Element {
|
||||
return
|
||||
}
|
||||
startupUpdateCheckStartedRef.current = true
|
||||
let updateCheckSource: 'github' | 'mirror' | undefined
|
||||
void updates
|
||||
.getSettings()
|
||||
.then(async (settings) => {
|
||||
@@ -2865,6 +2919,7 @@ function App(): React.JSX.Element {
|
||||
if (!settings.checkUpdatesOnStartup) {
|
||||
return
|
||||
}
|
||||
updateCheckSource = settings.updateSource
|
||||
const result = await updates.check()
|
||||
if (result.updateAvailable) {
|
||||
notify({
|
||||
@@ -2877,7 +2932,27 @@ function App(): React.JSX.Element {
|
||||
})
|
||||
}
|
||||
})
|
||||
.catch(() => undefined)
|
||||
.catch((reason: unknown) => {
|
||||
if (!updateCheckSource) {
|
||||
return
|
||||
}
|
||||
notify({
|
||||
tone: 'error',
|
||||
message: i18n.t('notices.startupUpdateCheckFailed', {
|
||||
ns: 'app',
|
||||
source: i18n.t(
|
||||
`notices.updateSources.${updateCheckSource}`,
|
||||
{ ns: 'app' }
|
||||
),
|
||||
error: displayNetworkAwareErrorMessage(
|
||||
reason,
|
||||
i18n.t('notices.updateCheckFailed', { ns: 'app' }),
|
||||
i18n.t('notices.updateCheckNetwork', { ns: 'app' })
|
||||
)
|
||||
}),
|
||||
dedupeKey: 'startup-update-check'
|
||||
})
|
||||
})
|
||||
}, [i18n, setView])
|
||||
|
||||
useEffect(() => {
|
||||
@@ -4588,7 +4663,9 @@ function App(): React.JSX.Element {
|
||||
status:
|
||||
event.type === 'error' && !representedToolError
|
||||
? event.message
|
||||
: undefined,
|
||||
: event.type === 'done'
|
||||
? tRef.current('chat.status.taskCompleted')
|
||||
: undefined,
|
||||
contextCompression:
|
||||
event.type === 'error' &&
|
||||
message.contextCompression?.state === 'compressing'
|
||||
@@ -5346,19 +5423,18 @@ function App(): React.JSX.Element {
|
||||
)
|
||||
void initialization.catch((reason: unknown) => {
|
||||
if (active) {
|
||||
notify({
|
||||
tone: 'error',
|
||||
message:
|
||||
reason instanceof Error
|
||||
? reason.message
|
||||
: tRef.current('notices.projectReadFailed')
|
||||
})
|
||||
setConversationLoadError(
|
||||
displayErrorMessage(
|
||||
reason,
|
||||
tRef.current('notices.projectReadFailed')
|
||||
)
|
||||
)
|
||||
}
|
||||
})
|
||||
return () => {
|
||||
active = false
|
||||
}
|
||||
}, [notify, setActiveId])
|
||||
}, [conversationLoadRetry, setActiveId])
|
||||
|
||||
useEffect(() => {
|
||||
if (!activeProjectId) {
|
||||
@@ -7958,6 +8034,23 @@ function App(): React.JSX.Element {
|
||||
|
||||
const mainSidebarOpen = narrowWindow && sidebarOpen
|
||||
const backgroundIsolated = mainSidebarOpen
|
||||
const runtimeState =
|
||||
runtimeSwitching ||
|
||||
!runtime ||
|
||||
runtimeStatusKey !== activeRuntimeSelectionKey
|
||||
? 'connecting'
|
||||
: runtime.available
|
||||
? 'ready'
|
||||
: 'unavailable'
|
||||
const runtimeDetailId = 'topbar-runtime-detail'
|
||||
const runtimeDetail =
|
||||
runtimeState === 'connecting'
|
||||
? t('runtime.connecting')
|
||||
: runtime?.detail ||
|
||||
(runtimeState === 'unavailable'
|
||||
? t('runtime.unavailable')
|
||||
: t('runtime.state.ready'))
|
||||
const composerContextErrorId = 'composer-context-error'
|
||||
|
||||
return (
|
||||
<div className="app-shell">
|
||||
@@ -8037,7 +8130,9 @@ function App(): React.JSX.Element {
|
||||
className={
|
||||
view === 'chat' ? 'nav-item nav-item--active' : 'nav-item'
|
||||
}
|
||||
onClick={() => navigateFromSidebar('chat')}
|
||||
onClick={(event) =>
|
||||
navigateFromSidebar('chat', event.currentTarget)
|
||||
}
|
||||
type="button"
|
||||
>
|
||||
<MessageSquare aria-hidden="true" size={17} />
|
||||
@@ -8052,7 +8147,9 @@ function App(): React.JSX.Element {
|
||||
: 'nav-item'
|
||||
}
|
||||
onFocus={() => preloadWorkspaceRouteOnIntent('magic-notes')}
|
||||
onClick={() => navigateFromSidebar('magic-notes')}
|
||||
onClick={(event) =>
|
||||
navigateFromSidebar('magic-notes', event.currentTarget)
|
||||
}
|
||||
onPointerEnter={() =>
|
||||
preloadWorkspaceRouteOnIntent('magic-notes')
|
||||
}
|
||||
@@ -8083,7 +8180,9 @@ function App(): React.JSX.Element {
|
||||
: 'nav-item'
|
||||
}
|
||||
onFocus={() => preloadWorkspaceRouteOnIntent('knowledge')}
|
||||
onClick={() => navigateFromSidebar('knowledge')}
|
||||
onClick={(event) =>
|
||||
navigateFromSidebar('knowledge', event.currentTarget)
|
||||
}
|
||||
onPointerEnter={() =>
|
||||
preloadWorkspaceRouteOnIntent('knowledge')
|
||||
}
|
||||
@@ -8099,7 +8198,9 @@ function App(): React.JSX.Element {
|
||||
? 'nav-item nav-item--active'
|
||||
: 'nav-item'
|
||||
}
|
||||
onClick={() => navigateFromSidebar('heartbeat')}
|
||||
onClick={(event) =>
|
||||
navigateFromSidebar('heartbeat', event.currentTarget)
|
||||
}
|
||||
type="button"
|
||||
>
|
||||
<HeartPulse aria-hidden="true" size={17} />
|
||||
@@ -8123,7 +8224,9 @@ function App(): React.JSX.Element {
|
||||
: 'nav-item'
|
||||
}
|
||||
onFocus={() => preloadWorkspaceRouteOnIntent('activity')}
|
||||
onClick={() => navigateFromSidebar('activity')}
|
||||
onClick={(event) =>
|
||||
navigateFromSidebar('activity', event.currentTarget)
|
||||
}
|
||||
onPointerEnter={() =>
|
||||
preloadWorkspaceRouteOnIntent('activity')
|
||||
}
|
||||
@@ -8136,7 +8239,8 @@ function App(): React.JSX.Element {
|
||||
|
||||
<div className="conversation-list">
|
||||
<p className="section-label">{t('sidebar.recent')}</p>
|
||||
{filteredConversations.map((conversation) => {
|
||||
{!conversationLoadError &&
|
||||
filteredConversations.map((conversation) => {
|
||||
const conversationTasks =
|
||||
tasksByConversation.get(conversation.id) ?? []
|
||||
const tasksExpanded =
|
||||
@@ -8577,14 +8681,55 @@ function App(): React.JSX.Element {
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
{filteredConversations.length === 0 && (
|
||||
<p className="conversation-empty">
|
||||
{activeProject?.kind === 'channel' &&
|
||||
!deferredSearchQuery.trim()
|
||||
? t('conversation.noRemote')
|
||||
: t('conversation.noMatches')}
|
||||
</p>
|
||||
)}
|
||||
{conversationLoadError ? (
|
||||
<div className="conversation-empty" role="alert">
|
||||
<strong>{t('conversation.loadFailed')}</strong>
|
||||
<span>{conversationLoadError}</span>
|
||||
<button
|
||||
className="secondary-button"
|
||||
onClick={() => {
|
||||
setConversationLoadError(undefined)
|
||||
setConversationLoadRetry((current) => current + 1)
|
||||
}}
|
||||
type="button"
|
||||
>
|
||||
<RefreshCw aria-hidden="true" size={13} />
|
||||
{t('conversation.retryLoad')}
|
||||
</button>
|
||||
</div>
|
||||
) : filteredConversations.length === 0 ? (
|
||||
deferredSearchQuery.trim() ? (
|
||||
<div className="conversation-empty">
|
||||
<strong>{t('conversation.noMatches')}</strong>
|
||||
<span>{t('conversation.noMatchesDescription')}</span>
|
||||
<button
|
||||
className="secondary-button"
|
||||
onClick={() => setSearchQuery('')}
|
||||
type="button"
|
||||
>
|
||||
{t('conversation.clearSearch')}
|
||||
</button>
|
||||
</div>
|
||||
) : activeProject?.kind === 'channel' ? (
|
||||
<div className="conversation-empty">
|
||||
<strong>{t('conversation.noRemote')}</strong>
|
||||
<span>{t('chat.remote.waiting')}</span>
|
||||
</div>
|
||||
) : (
|
||||
<div className="conversation-empty">
|
||||
<strong>{t('conversation.empty')}</strong>
|
||||
<span>{t('conversation.emptyDescription')}</span>
|
||||
<button
|
||||
className="secondary-button"
|
||||
onClick={newConversation}
|
||||
type="button"
|
||||
>
|
||||
<MessageSquarePlus aria-hidden="true" size={13} />
|
||||
{t('sidebar.newConversation')}
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
<div className="sidebar-footer">
|
||||
@@ -8592,7 +8737,9 @@ function App(): React.JSX.Element {
|
||||
className="user-card"
|
||||
type="button"
|
||||
onFocus={() => preloadWorkspaceRouteOnIntent('settings')}
|
||||
onClick={() => navigateFromSidebar('settings')}
|
||||
onClick={(event) =>
|
||||
navigateFromSidebar('settings', event.currentTarget)
|
||||
}
|
||||
onPointerEnter={() =>
|
||||
preloadWorkspaceRouteOnIntent('settings')
|
||||
}
|
||||
@@ -8684,23 +8831,30 @@ function App(): React.JSX.Element {
|
||||
)}
|
||||
<div className="topbar__actions">
|
||||
<span
|
||||
aria-describedby={runtimeDetailId}
|
||||
className={
|
||||
runtime?.available
|
||||
runtimeState === 'ready'
|
||||
? 'runtime-status runtime-status--online'
|
||||
: 'runtime-status'
|
||||
}
|
||||
title={runtime?.detail}
|
||||
title={runtimeDetail}
|
||||
>
|
||||
<span className="runtime-status__dot" />
|
||||
<span className="runtime-status__label">
|
||||
{runtime?.label ?? t('runtime.detecting')}
|
||||
</span>
|
||||
<span className="runtime-status__state">
|
||||
{t(`runtime.state.${runtimeState}`)}
|
||||
</span>
|
||||
{runtime?.capability === 'image-generation' && (
|
||||
<span className="runtime-capability-badge">
|
||||
{t('runtime.imageGeneration')}
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
<span className="sr-only" id={runtimeDetailId}>
|
||||
{runtimeDetail}
|
||||
</span>
|
||||
<button
|
||||
aria-label={
|
||||
resolvedAppearanceTheme === 'dark'
|
||||
@@ -8886,6 +9040,10 @@ function App(): React.JSX.Element {
|
||||
{(attachments.length > 0 || selectingContextFiles) && (
|
||||
<div
|
||||
aria-busy={selectingContextFiles}
|
||||
aria-describedby={
|
||||
contextError ? composerContextErrorId : undefined
|
||||
}
|
||||
aria-invalid={contextError ? true : undefined}
|
||||
className="context-list"
|
||||
>
|
||||
{attachments.map((attachment) => (
|
||||
@@ -8979,6 +9137,10 @@ function App(): React.JSX.Element {
|
||||
)}
|
||||
<div className="composer__input">
|
||||
<textarea
|
||||
aria-describedby={
|
||||
contextError ? composerContextErrorId : undefined
|
||||
}
|
||||
aria-invalid={contextError ? true : undefined}
|
||||
aria-label={t('composer.inputLabel')}
|
||||
placeholder={`${
|
||||
runtime?.capability === 'image-generation'
|
||||
@@ -9050,11 +9212,15 @@ function App(): React.JSX.Element {
|
||||
role="group"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
aria-label={t('composer.addAttachment')}
|
||||
aria-describedby={
|
||||
contextError ? composerContextErrorId : undefined
|
||||
}
|
||||
aria-invalid={contextError ? true : undefined}
|
||||
disabled={selectingContextFiles}
|
||||
onClick={() => void selectContextFiles()}
|
||||
title={t('composer.addAttachment')}
|
||||
type="button"
|
||||
>
|
||||
<Paperclip aria-hidden="true" size={18} />
|
||||
</button>
|
||||
@@ -9527,6 +9693,11 @@ function App(): React.JSX.Element {
|
||||
</button>
|
||||
)}
|
||||
<button
|
||||
aria-describedby={
|
||||
runtimeState !== 'ready'
|
||||
? runtimeDetailId
|
||||
: undefined
|
||||
}
|
||||
className="send-button"
|
||||
type="button"
|
||||
aria-label={
|
||||
@@ -9773,7 +9944,12 @@ function App(): React.JSX.Element {
|
||||
</div>
|
||||
)}
|
||||
{contextError && (
|
||||
<span className="composer-meta__error">
|
||||
<span
|
||||
aria-label={contextError}
|
||||
className="composer-meta__error"
|
||||
id={composerContextErrorId}
|
||||
role="alert"
|
||||
>
|
||||
{contextError}
|
||||
</span>
|
||||
)}
|
||||
|
||||
@@ -352,4 +352,143 @@ describe('ChatTimeline', () => {
|
||||
expect.stringContaining('父 Agent 最终回复')
|
||||
])
|
||||
})
|
||||
|
||||
it('uses one live source per event without announcing historical tool rows', () => {
|
||||
const messages: Message[] = [
|
||||
{
|
||||
id: 'working',
|
||||
role: 'assistant',
|
||||
content: 'streamed reply body',
|
||||
createdAt: 1_775_000_000_000,
|
||||
state: 'streaming',
|
||||
status: 'Preparing tools'
|
||||
},
|
||||
{
|
||||
id: 'approval',
|
||||
role: 'assistant',
|
||||
content: '',
|
||||
createdAt: 1_775_000_000_001,
|
||||
state: 'complete',
|
||||
approval: {
|
||||
id: 'approval-1',
|
||||
title: 'Write workspace file',
|
||||
description: 'Update release.md',
|
||||
toolName: 'write_file'
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'failed',
|
||||
role: 'assistant',
|
||||
content: 'bounded failure context',
|
||||
createdAt: 1_775_000_000_002,
|
||||
state: 'error',
|
||||
status: 'Runtime connection failed'
|
||||
},
|
||||
{
|
||||
id: 'tool-history',
|
||||
role: 'assistant',
|
||||
content: '',
|
||||
createdAt: 1_775_000_000_003,
|
||||
state: 'complete',
|
||||
tools: [
|
||||
{
|
||||
callId: 'tool-1',
|
||||
name: 'read_file',
|
||||
summary: 'Read the file',
|
||||
state: 'completed'
|
||||
}
|
||||
],
|
||||
subagents: [
|
||||
{
|
||||
childTaskId: 'subagent-1',
|
||||
expertId: 'expert-1',
|
||||
expertName: 'reviewer',
|
||||
routingMode: 'manual',
|
||||
state: 'completed'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 'retrieval',
|
||||
role: 'assistant',
|
||||
content: '',
|
||||
createdAt: 1_775_000_000_004,
|
||||
state: 'complete',
|
||||
status: 'Knowledge search complete',
|
||||
knowledgeRetrieval: {
|
||||
mode: 'always',
|
||||
state: 'succeeded',
|
||||
libraryCount: 1,
|
||||
resultCount: 2,
|
||||
durationMs: 20,
|
||||
usedChannels: ['fts'],
|
||||
warnings: []
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'compression',
|
||||
role: 'assistant',
|
||||
content: '',
|
||||
createdAt: 1_775_000_000_005,
|
||||
state: 'complete',
|
||||
status: 'Context compression complete',
|
||||
contextCompression: {
|
||||
state: 'completed',
|
||||
estimatedBeforeTokens: 20_000,
|
||||
estimatedAfterTokens: 8_000
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
const { container } = render(
|
||||
<ChatTimeline
|
||||
artifactById={new Map()}
|
||||
conversationId="conversation-1"
|
||||
hiddenMessageCount={0}
|
||||
isUnusedConversation={false}
|
||||
locale="en-US"
|
||||
messageStartIndex={0}
|
||||
messages={messages}
|
||||
{...callbacks}
|
||||
retryContent=""
|
||||
totalMessageCount={messages.length}
|
||||
/>
|
||||
)
|
||||
|
||||
expect(
|
||||
screen.getByRole('status', { name: 'Preparing tools' })
|
||||
).toBeInTheDocument()
|
||||
expect(
|
||||
screen.getByRole('status', {
|
||||
name: '等待审批:write_file'
|
||||
})
|
||||
).toBeInTheDocument()
|
||||
expect(
|
||||
screen.getByRole('alert', {
|
||||
name: 'Runtime connection failed'
|
||||
})
|
||||
).toBeInTheDocument()
|
||||
expect(
|
||||
screen.getByText('streamed reply body')
|
||||
).not.toHaveAttribute('aria-live')
|
||||
expect(screen.getByLabelText('已完成', { selector: 'small' }))
|
||||
.not.toHaveAttribute('aria-live')
|
||||
expect(
|
||||
screen.getByLabelText('已完成', {
|
||||
selector: '.subagent-status-card__status'
|
||||
})
|
||||
).not.toHaveAttribute('aria-live')
|
||||
expect(
|
||||
screen.getByLabelText('Knowledge search complete')
|
||||
).not.toHaveAttribute('aria-live')
|
||||
expect(
|
||||
screen.getByLabelText('Context compression complete')
|
||||
).not.toHaveAttribute('aria-live')
|
||||
expect(
|
||||
container.querySelectorAll('.approval-card [aria-live="polite"]')
|
||||
).toHaveLength(1)
|
||||
expect(
|
||||
container.querySelectorAll('.message-retrieval-status[aria-live]')
|
||||
).toHaveLength(1)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -213,7 +213,11 @@ function ToolExecutionList({
|
||||
<strong>{tool.name}</strong>
|
||||
<span>{tool.summary}</span>
|
||||
</span>
|
||||
<small>{t(`chat.tools.states.${tool.state}`)}</small>
|
||||
<small
|
||||
aria-label={t(`chat.tools.states.${tool.state}`)}
|
||||
>
|
||||
{t(`chat.tools.states.${tool.state}`)}
|
||||
</small>
|
||||
</summary>
|
||||
<div className="tool-execution__details">
|
||||
{tool.input && (
|
||||
@@ -292,6 +296,7 @@ const SubagentStatusCard = memo(function SubagentStatusCard({
|
||||
</small>
|
||||
</span>
|
||||
<span
|
||||
aria-label={t(`chat.subagents.states.${subagent.state}`)}
|
||||
className={`subagent-status-card__status subagent-status-card__status--${subagent.state}`}
|
||||
>
|
||||
<StateIcon aria-hidden="true" size={14} />
|
||||
@@ -678,8 +683,17 @@ function ChatMessageRowView({
|
||||
})}
|
||||
{message.knowledgeRetrieval && (
|
||||
<section
|
||||
aria-live="polite"
|
||||
aria-live={
|
||||
message.knowledgeRetrieval.state === 'failed'
|
||||
? 'assertive'
|
||||
: 'polite'
|
||||
}
|
||||
className={`message-retrieval-status message-retrieval-status--${message.knowledgeRetrieval.state}`}
|
||||
role={
|
||||
message.knowledgeRetrieval.state === 'failed'
|
||||
? 'alert'
|
||||
: 'status'
|
||||
}
|
||||
>
|
||||
<Library aria-hidden="true" size={14} />
|
||||
<div>
|
||||
@@ -804,6 +818,19 @@ function ChatMessageRowView({
|
||||
)}
|
||||
{message.approval && (
|
||||
<div className="approval-card">
|
||||
<span
|
||||
aria-atomic="true"
|
||||
aria-label={t('chat.approval.waiting', {
|
||||
tool: message.approval.toolName ?? message.approval.title
|
||||
})}
|
||||
aria-live="polite"
|
||||
className="sr-only"
|
||||
role="status"
|
||||
>
|
||||
{t('chat.approval.waiting', {
|
||||
tool: message.approval.toolName ?? message.approval.title
|
||||
})}
|
||||
</span>
|
||||
<ShieldCheck size={18} />
|
||||
<div>
|
||||
<strong>{message.approval.title}</strong>
|
||||
@@ -895,11 +922,27 @@ function ChatMessageRowView({
|
||||
)}
|
||||
{message.status && (
|
||||
<div
|
||||
aria-atomic="true"
|
||||
aria-label={message.status}
|
||||
aria-live={
|
||||
message.knowledgeRetrieval || compressionMarkers.length > 0
|
||||
? undefined
|
||||
: message.state === 'error'
|
||||
? 'assertive'
|
||||
: 'polite'
|
||||
}
|
||||
className={
|
||||
message.state === 'error'
|
||||
? 'message__status message__status--error'
|
||||
: 'message__status'
|
||||
}
|
||||
role={
|
||||
message.knowledgeRetrieval || compressionMarkers.length > 0
|
||||
? undefined
|
||||
: message.state === 'error'
|
||||
? 'alert'
|
||||
: 'status'
|
||||
}
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
@@ -930,10 +973,12 @@ function ChatMessageRowView({
|
||||
{message.role === 'assistant' &&
|
||||
compressionMarkers.map((compression, index) => (
|
||||
<div
|
||||
aria-live="polite"
|
||||
aria-live={
|
||||
compression.state === 'failed' ? 'assertive' : 'polite'
|
||||
}
|
||||
className={`context-compression-event context-compression-event--${compression.state}`}
|
||||
key={`${compression.scope ?? 'conversation'}:${index}`}
|
||||
role="status"
|
||||
role={compression.state === 'failed' ? 'alert' : 'status'}
|
||||
>
|
||||
<span className="context-compression-event__line" />
|
||||
<span className="context-compression-event__label">
|
||||
|
||||
@@ -91,6 +91,11 @@ describe('FeedbackDialog', () => {
|
||||
value: '打开平台功能后,魔法笔记页签没有显示。'
|
||||
}
|
||||
})
|
||||
const diagnostics = screen.getByRole('checkbox', {
|
||||
name: '附加最近桌面诊断记录'
|
||||
})
|
||||
expect(diagnostics).not.toBeChecked()
|
||||
fireEvent.click(diagnostics)
|
||||
const submitButton = screen.getByRole('button', {
|
||||
name: '提交反馈'
|
||||
})
|
||||
@@ -120,6 +125,53 @@ describe('FeedbackDialog', () => {
|
||||
expect(submit.mock.calls[1]![0].clientRequestId).toBe(
|
||||
firstRequestId
|
||||
)
|
||||
expect(submit.mock.calls[0]![0].includeDiagnostics).toBe(true)
|
||||
expect(submit.mock.calls[1]![0].includeDiagnostics).toBe(true)
|
||||
})
|
||||
|
||||
it('keeps an over-budget diagnostics draft and shows a field error', () => {
|
||||
installApi(
|
||||
vi.fn<DesktopApi['feedback']['submit']>(async () => ({
|
||||
ok: true,
|
||||
reference: 'GOODBUDDY-000016',
|
||||
duplicate: false
|
||||
}))
|
||||
)
|
||||
render(
|
||||
<FeedbackDialog
|
||||
appInfo={{
|
||||
name: 'GoodBuddy',
|
||||
version: '0.11.0',
|
||||
platform: 'win32',
|
||||
arch: 'x64',
|
||||
shortcut: 'Ctrl+Shift+Space'
|
||||
}}
|
||||
onClose={vi.fn()}
|
||||
/>
|
||||
)
|
||||
const description = 'x'.repeat(3_399)
|
||||
fireEvent.change(screen.getByLabelText('标题'), {
|
||||
target: { value: 'Diagnostics budget' }
|
||||
})
|
||||
fireEvent.change(screen.getByLabelText('详细描述'), {
|
||||
target: { value: description }
|
||||
})
|
||||
fireEvent.click(
|
||||
screen.getByRole('checkbox', {
|
||||
name: '附加最近桌面诊断记录'
|
||||
})
|
||||
)
|
||||
expect(screen.getByLabelText('详细描述')).toHaveValue(
|
||||
description
|
||||
)
|
||||
expect(
|
||||
screen.getByText(
|
||||
'附加桌面诊断时,详细描述不能超过 3398 个字符;草稿已保留,请缩短后重试。'
|
||||
)
|
||||
).toBeInTheDocument()
|
||||
expect(
|
||||
screen.getByRole('button', { name: '提交反馈' })
|
||||
).toBeDisabled()
|
||||
})
|
||||
|
||||
it('validates fields, traps focus, and closes with Escape', () => {
|
||||
|
||||
@@ -61,6 +61,7 @@ export function FeedbackDialog({
|
||||
: 'zh-CN'
|
||||
const titleId = useId()
|
||||
const descriptionId = useId()
|
||||
const diagnosticsDescriptionId = useId()
|
||||
const dialogRef = useRef<HTMLDivElement>(null)
|
||||
const categoryRef = useRef<HTMLSelectElement>(null)
|
||||
const titleRef = useRef<HTMLInputElement>(null)
|
||||
@@ -73,6 +74,8 @@ export function FeedbackDialog({
|
||||
const [category, setCategory] = useState<FeedbackCategory>('bug')
|
||||
const [title, setTitle] = useState('')
|
||||
const [description, setDescription] = useState('')
|
||||
const [includeDiagnostics, setIncludeDiagnostics] =
|
||||
useState(false)
|
||||
const [contactEmail, setContactEmail] = useState('')
|
||||
const [screenshot, setScreenshot] = useState<ScreenshotDraft>()
|
||||
const [screenshotProcessing, setScreenshotProcessing] =
|
||||
@@ -214,6 +217,19 @@ export function FeedbackDialog({
|
||||
'feedback.validation.descriptionMinimum'
|
||||
)
|
||||
}
|
||||
const maximumDescriptionCharacters = includeDiagnostics
|
||||
? feedbackLimits.maximumDescriptionCharactersWithDiagnostics
|
||||
: feedbackLimits.maximumDescriptionCharacters
|
||||
if (
|
||||
description.trim().length > maximumDescriptionCharacters
|
||||
) {
|
||||
errors.description = t(
|
||||
includeDiagnostics
|
||||
? 'feedback.validation.descriptionMaximumWithDiagnostics'
|
||||
: 'feedback.validation.descriptionMaximum',
|
||||
{ maximum: maximumDescriptionCharacters }
|
||||
)
|
||||
}
|
||||
if (
|
||||
contactEmail.trim() &&
|
||||
!feedbackContactEmailSchema.safeParse(contactEmail.trim())
|
||||
@@ -228,6 +244,10 @@ export function FeedbackDialog({
|
||||
title.trim().length > 0 &&
|
||||
description.trim().length >=
|
||||
feedbackLimits.minimumDescriptionCharacters &&
|
||||
description.trim().length <=
|
||||
(includeDiagnostics
|
||||
? feedbackLimits.maximumDescriptionCharactersWithDiagnostics
|
||||
: feedbackLimits.maximumDescriptionCharacters) &&
|
||||
(!contactEmail.trim() ||
|
||||
feedbackContactEmailSchema.safeParse(contactEmail.trim())
|
||||
.success) &&
|
||||
@@ -260,6 +280,7 @@ export function FeedbackDialog({
|
||||
category,
|
||||
title,
|
||||
description,
|
||||
includeDiagnostics,
|
||||
...(contactEmail.trim()
|
||||
? { contactEmail: contactEmail.trim() }
|
||||
: {}),
|
||||
@@ -451,16 +472,27 @@ export function FeedbackDialog({
|
||||
aria-label={t('feedback.fields.description')}
|
||||
aria-invalid={Boolean(fieldErrors.description)}
|
||||
disabled={submitting}
|
||||
maxLength={
|
||||
feedbackLimits.maximumDescriptionCharacters
|
||||
}
|
||||
onBlur={() =>
|
||||
setFieldErrors((current) => ({
|
||||
...current,
|
||||
description:
|
||||
description.trim().length >=
|
||||
feedbackLimits.minimumDescriptionCharacters
|
||||
? undefined
|
||||
feedbackLimits.minimumDescriptionCharacters
|
||||
? description.trim().length <=
|
||||
(includeDiagnostics
|
||||
? feedbackLimits.maximumDescriptionCharactersWithDiagnostics
|
||||
: feedbackLimits.maximumDescriptionCharacters)
|
||||
? undefined
|
||||
: t(
|
||||
includeDiagnostics
|
||||
? 'feedback.validation.descriptionMaximumWithDiagnostics'
|
||||
: 'feedback.validation.descriptionMaximum',
|
||||
{
|
||||
maximum: includeDiagnostics
|
||||
? feedbackLimits.maximumDescriptionCharactersWithDiagnostics
|
||||
: feedbackLimits.maximumDescriptionCharacters
|
||||
}
|
||||
)
|
||||
: t(
|
||||
'feedback.validation.descriptionMinimum'
|
||||
)
|
||||
@@ -485,7 +517,9 @@ export function FeedbackDialog({
|
||||
{t('feedback.fields.characterCount', {
|
||||
count: description.length,
|
||||
maximum:
|
||||
feedbackLimits.maximumDescriptionCharacters
|
||||
includeDiagnostics
|
||||
? feedbackLimits.maximumDescriptionCharactersWithDiagnostics
|
||||
: feedbackLimits.maximumDescriptionCharacters
|
||||
})}
|
||||
</small>
|
||||
{fieldErrors.description && (
|
||||
@@ -495,6 +529,48 @@ export function FeedbackDialog({
|
||||
)}
|
||||
</label>
|
||||
|
||||
<label className="feedback-diagnostics-option">
|
||||
<input
|
||||
aria-label={t('feedback.diagnostics.label')}
|
||||
checked={includeDiagnostics}
|
||||
disabled={submitting}
|
||||
onChange={(event) => {
|
||||
const selected = event.target.checked
|
||||
setIncludeDiagnostics(selected)
|
||||
const maximum = selected
|
||||
? feedbackLimits.maximumDescriptionCharactersWithDiagnostics
|
||||
: feedbackLimits.maximumDescriptionCharacters
|
||||
setFieldErrors((current) => ({
|
||||
...current,
|
||||
description:
|
||||
description.trim().length <
|
||||
feedbackLimits.minimumDescriptionCharacters
|
||||
? t(
|
||||
'feedback.validation.descriptionMinimum'
|
||||
)
|
||||
: description.trim().length > maximum
|
||||
? t(
|
||||
selected
|
||||
? 'feedback.validation.descriptionMaximumWithDiagnostics'
|
||||
: 'feedback.validation.descriptionMaximum',
|
||||
{ maximum }
|
||||
)
|
||||
: undefined
|
||||
}))
|
||||
}}
|
||||
type="checkbox"
|
||||
aria-describedby={diagnosticsDescriptionId}
|
||||
/>
|
||||
<span>
|
||||
<strong>
|
||||
{t('feedback.diagnostics.label')}
|
||||
</strong>
|
||||
<small id={diagnosticsDescriptionId}>
|
||||
{t('feedback.diagnostics.description')}
|
||||
</small>
|
||||
</span>
|
||||
</label>
|
||||
|
||||
<label className="field">
|
||||
<span>{t('feedback.fields.contactEmail')}</span>
|
||||
<input
|
||||
|
||||
@@ -542,6 +542,10 @@ describe('HeartbeatCenter', () => {
|
||||
)
|
||||
|
||||
expect(screen.getByText('正在加载智能心跳')).toBeInTheDocument()
|
||||
expect(screen.getByRole('status')).toHaveAttribute(
|
||||
'aria-busy',
|
||||
'true'
|
||||
)
|
||||
expect(
|
||||
screen.queryByRole('button', { name: '配置智能心跳' })
|
||||
).not.toBeInTheDocument()
|
||||
|
||||
@@ -433,6 +433,7 @@ export function HeartbeatCenter({
|
||||
icon={<RefreshCw size={24} />}
|
||||
level="page"
|
||||
title={t('center.loading.title')}
|
||||
variant="loading"
|
||||
/>
|
||||
) : loadError && !hasHeartbeatData ? (
|
||||
<EmptyState
|
||||
|
||||
@@ -1887,6 +1887,10 @@ describe('KnowledgeWorkspace', () => {
|
||||
)
|
||||
|
||||
expect(screen.getByText('正在加载知识库')).toBeInTheDocument()
|
||||
expect(screen.getByRole('status')).toHaveAttribute(
|
||||
'aria-busy',
|
||||
'true'
|
||||
)
|
||||
expect(
|
||||
screen.queryByText('建立第一个知识库')
|
||||
).not.toBeInTheDocument()
|
||||
|
||||
@@ -4404,6 +4404,7 @@ export function KnowledgeWorkspace({
|
||||
icon={<LoaderCircle size={28} />}
|
||||
level="page"
|
||||
title={t('loading.title')}
|
||||
variant="loading"
|
||||
/>
|
||||
) : loadError && libraries.length === 0 ? (
|
||||
<EmptyState
|
||||
|
||||
@@ -3,12 +3,15 @@ import {
|
||||
fireEvent,
|
||||
render,
|
||||
screen,
|
||||
within,
|
||||
waitFor
|
||||
} from '@testing-library/react'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import type { WorkspaceFilePreview } from '../../shared/assistant-contracts'
|
||||
import {
|
||||
RightAssistantSidebar,
|
||||
type AssistantSidebarTab,
|
||||
type PendingSidebarApproval,
|
||||
type SidebarArtifact
|
||||
} from './RightAssistantSidebar'
|
||||
|
||||
@@ -23,20 +26,44 @@ beforeEach(() => {
|
||||
|
||||
function renderSidebar({
|
||||
tab = 'tasks',
|
||||
approvals = [],
|
||||
artifacts = [],
|
||||
onListWorkspaceDirectory = vi.fn(async (path: string) => ({
|
||||
path,
|
||||
entries: [],
|
||||
truncated: false
|
||||
})),
|
||||
onLoadArtifact = vi.fn(async () => undefined),
|
||||
onLoadWorkspaceFile = vi.fn(),
|
||||
workspaceProjectId,
|
||||
restoreFocusRef
|
||||
}: {
|
||||
tab?: AssistantSidebarTab
|
||||
approvals?: PendingSidebarApproval[]
|
||||
artifacts?: SidebarArtifact[]
|
||||
onListWorkspaceDirectory?: (
|
||||
path: string
|
||||
) => Promise<{
|
||||
path: string
|
||||
entries: {
|
||||
name: string
|
||||
path: string
|
||||
type: 'file' | 'directory'
|
||||
}[]
|
||||
truncated: boolean
|
||||
}>
|
||||
onLoadArtifact?: (artifactId: string) => Promise<void>
|
||||
onLoadWorkspaceFile?: (
|
||||
path: string
|
||||
) => Promise<WorkspaceFilePreview>
|
||||
workspaceProjectId?: string
|
||||
restoreFocusRef?: { current: HTMLElement | null }
|
||||
} = {}): HTMLElement {
|
||||
render(
|
||||
<div>
|
||||
<main className="workspace" />
|
||||
<RightAssistantSidebar
|
||||
approvals={[]}
|
||||
approvals={approvals}
|
||||
artifacts={artifacts}
|
||||
schedules={[]}
|
||||
tasks={[]}
|
||||
@@ -44,13 +71,9 @@ function renderSidebar({
|
||||
projectNames={new Map()}
|
||||
onCreateCustomTask={vi.fn()}
|
||||
onImportArtifacts={vi.fn(async () => undefined)}
|
||||
onListWorkspaceDirectory={vi.fn(async (path: string) => ({
|
||||
path,
|
||||
entries: [],
|
||||
truncated: false
|
||||
}))}
|
||||
onListWorkspaceDirectory={onListWorkspaceDirectory}
|
||||
onLoadArtifact={onLoadArtifact}
|
||||
onLoadWorkspaceFile={vi.fn()}
|
||||
onLoadWorkspaceFile={onLoadWorkspaceFile}
|
||||
onOpenWorkspaceEntry={vi.fn(async () => undefined)}
|
||||
onInteractBrowser={vi.fn(async () => undefined)}
|
||||
onRefreshChanges={vi.fn(async () => undefined)}
|
||||
@@ -64,6 +87,7 @@ function renderSidebar({
|
||||
open
|
||||
restoreFocusRef={restoreFocusRef}
|
||||
tab={tab}
|
||||
workspaceProjectId={workspaceProjectId}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
@@ -265,6 +289,91 @@ describe('RightAssistantSidebar resizing', () => {
|
||||
expect(screen.queryByText('最近任务')).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('labels approval counts and cards without duplicate live regions', () => {
|
||||
renderSidebar({
|
||||
approvals: [
|
||||
{
|
||||
conversationId: 'conversation-1',
|
||||
messageId: 'message-1',
|
||||
approvalId: 'approval-1',
|
||||
title: '写入工作区',
|
||||
description: '更新 release.md',
|
||||
toolName: 'write_file'
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
expect(
|
||||
screen.getByLabelText('等待审批: 1')
|
||||
).not.toHaveAttribute('aria-live')
|
||||
expect(
|
||||
screen.getByLabelText('等待审批: write_file')
|
||||
).not.toHaveAttribute('aria-live')
|
||||
expect(
|
||||
screen.queryByRole('status', { name: /等待审批/u })
|
||||
).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('keeps a failed workspace preview in place and retries it', async () => {
|
||||
let rejectPreview: ((reason: unknown) => void) | undefined
|
||||
const onLoadWorkspaceFile = vi
|
||||
.fn()
|
||||
.mockImplementationOnce(
|
||||
() =>
|
||||
new Promise((_resolve, reject) => {
|
||||
rejectPreview = reject
|
||||
})
|
||||
)
|
||||
.mockResolvedValueOnce({
|
||||
path: 'README.md',
|
||||
name: 'README.md',
|
||||
content: 'Recovered preview',
|
||||
mimeType: 'text/plain',
|
||||
size: 17
|
||||
})
|
||||
renderSidebar({
|
||||
tab: 'workspace',
|
||||
workspaceProjectId: 'project-1',
|
||||
onListWorkspaceDirectory: vi.fn(async (path: string) => ({
|
||||
path,
|
||||
entries: [
|
||||
{
|
||||
name: 'README.md',
|
||||
path: 'README.md',
|
||||
type: 'file' as const
|
||||
}
|
||||
],
|
||||
truncated: false
|
||||
})),
|
||||
onLoadWorkspaceFile
|
||||
})
|
||||
|
||||
fireEvent.click(
|
||||
await screen.findByRole('button', { name: 'README.md' })
|
||||
)
|
||||
const loading = screen.getByRole('status', {
|
||||
name: '正在读取文件…'
|
||||
})
|
||||
expect(loading).toHaveAttribute('aria-live', 'polite')
|
||||
expect(loading.closest('section')).toHaveAttribute(
|
||||
'aria-busy',
|
||||
'true'
|
||||
)
|
||||
|
||||
rejectPreview?.(new Error('临时网络错误'))
|
||||
const error = await screen.findByRole('alert')
|
||||
expect(error).toHaveTextContent('临时网络错误')
|
||||
expect(screen.getByText('README.md')).toBeInTheDocument()
|
||||
fireEvent.click(
|
||||
within(error).getByRole('button', { name: '刷新' })
|
||||
)
|
||||
|
||||
expect(await screen.findByText('Recovered preview'))
|
||||
.toBeInTheDocument()
|
||||
expect(onLoadWorkspaceFile).toHaveBeenCalledTimes(2)
|
||||
expect(onLoadWorkspaceFile).toHaveBeenNthCalledWith(2, 'README.md')
|
||||
})
|
||||
|
||||
it('previews a result without switching to a separate tab', () => {
|
||||
const onLoadArtifact = vi.fn(async () => undefined)
|
||||
renderSidebar({
|
||||
|
||||
@@ -601,7 +601,10 @@ export function RightAssistantSidebar({
|
||||
>
|
||||
{item.label}
|
||||
{item.id === 'tasks' && approvals.length > 0 && (
|
||||
<span className="assistant-sidebar__badge">
|
||||
<span
|
||||
aria-label={`${t('sidebar.tasks.approvalsTitle')}: ${approvals.length}`}
|
||||
className="assistant-sidebar__badge"
|
||||
>
|
||||
{approvals.length}
|
||||
</span>
|
||||
)}
|
||||
@@ -633,6 +636,9 @@ export function RightAssistantSidebar({
|
||||
) : (
|
||||
approvals.map((approval) => (
|
||||
<article
|
||||
aria-label={`${t('sidebar.tasks.approvalsTitle')}: ${
|
||||
approval.toolName ?? approval.title
|
||||
}`}
|
||||
className="assistant-sidebar__approval"
|
||||
key={approval.approvalId}
|
||||
>
|
||||
@@ -808,7 +814,10 @@ export function RightAssistantSidebar({
|
||||
|
||||
{tab === 'workspace' && (
|
||||
currentWorkspacePreview ? (
|
||||
<section className="assistant-sidebar__preview">
|
||||
<section
|
||||
aria-busy={currentWorkspacePreview.state === 'loading'}
|
||||
className="assistant-sidebar__preview"
|
||||
>
|
||||
<header>
|
||||
<button
|
||||
aria-label={t('sidebar.workspace.back')}
|
||||
@@ -838,13 +847,28 @@ export function RightAssistantSidebar({
|
||||
</span>
|
||||
</header>
|
||||
{currentWorkspacePreview.state === 'loading' ? (
|
||||
<p className="assistant-sidebar__empty">
|
||||
<p
|
||||
aria-label={t('sidebar.workspace.reading')}
|
||||
aria-live="polite"
|
||||
className="assistant-sidebar__empty"
|
||||
role="status"
|
||||
>
|
||||
{t('sidebar.workspace.reading')}
|
||||
</p>
|
||||
) : currentWorkspacePreview.state === 'error' ? (
|
||||
<p className="assistant-sidebar__empty" role="alert">
|
||||
{currentWorkspacePreview.error}
|
||||
</p>
|
||||
<div className="assistant-sidebar__empty" role="alert">
|
||||
<p>{currentWorkspacePreview.error}</p>
|
||||
<button
|
||||
className="secondary-button"
|
||||
onClick={() =>
|
||||
openWorkspaceFile(currentWorkspacePreview.path)
|
||||
}
|
||||
type="button"
|
||||
>
|
||||
<RefreshCw aria-hidden="true" size={13} />
|
||||
{t('sidebar.workspace.refresh')}
|
||||
</button>
|
||||
</div>
|
||||
) : (
|
||||
<div className="markdown-body markdown-content">
|
||||
{currentWorkspacePreview.file.mimeType ===
|
||||
@@ -1070,9 +1094,15 @@ export function RightAssistantSidebar({
|
||||
) : (
|
||||
<>
|
||||
<div
|
||||
aria-live="polite"
|
||||
aria-live={
|
||||
browserState.status === 'failed'
|
||||
? 'assertive'
|
||||
: 'polite'
|
||||
}
|
||||
className={`assistant-sidebar__browser-status assistant-sidebar__browser-status--${browserState.status}`}
|
||||
role="status"
|
||||
role={
|
||||
browserState.status === 'failed' ? 'alert' : 'status'
|
||||
}
|
||||
>
|
||||
{browserState.status === 'creating'
|
||||
? t('sidebar.browser.statuses.creating')
|
||||
|
||||
@@ -2322,15 +2322,29 @@ describe('SettingsPanel runtime files', () => {
|
||||
expect(
|
||||
screen.getByRole('tab', { name: '外观' })
|
||||
).toHaveAttribute('aria-selected', 'true')
|
||||
fireEvent.click(screen.getByRole('button', { name: '关闭设置' }))
|
||||
const content = screen.getByRole('tabpanel')
|
||||
content.scrollTop = 320
|
||||
const closeButton = screen.getByRole('button', {
|
||||
name: '关闭设置'
|
||||
})
|
||||
fireEvent.click(closeButton)
|
||||
expect(onClose).not.toHaveBeenCalled()
|
||||
expect(
|
||||
screen.getByRole('alert')
|
||||
).toHaveTextContent('当前设置有未保存更改')
|
||||
expect(
|
||||
screen.getByRole('button', { name: '继续编辑' })
|
||||
).toHaveFocus()
|
||||
expect(content).toHaveProperty('scrollTop', 0)
|
||||
|
||||
fireEvent.click(
|
||||
screen.getByRole('button', { name: '继续编辑' })
|
||||
)
|
||||
await waitFor(() =>
|
||||
expect(
|
||||
screen.getByRole('button', { name: '关闭设置' })
|
||||
).toHaveFocus()
|
||||
)
|
||||
fireEvent.click(runtimeTab)
|
||||
expect(await screen.findByLabelText('默认工作区目录')).toHaveValue(
|
||||
'C:\\Unsaved workspace'
|
||||
@@ -2343,6 +2357,7 @@ describe('SettingsPanel runtime files', () => {
|
||||
screen.getByRole('button', { name: '放弃更改并关闭' })
|
||||
)
|
||||
expect(onClose).toHaveBeenCalledOnce()
|
||||
expect(closeButton).not.toHaveFocus()
|
||||
})
|
||||
|
||||
it('routes external leave requests through the existing dirty confirmation', async () => {
|
||||
@@ -2420,6 +2435,7 @@ describe('SettingsPanel runtime files', () => {
|
||||
screen.getByRole('button', { name: '放弃更改并切换' })
|
||||
)
|
||||
expect(appearanceTab).toHaveAttribute('aria-selected', 'true')
|
||||
await waitFor(() => expect(appearanceTab).toHaveFocus())
|
||||
|
||||
fireEvent.click(
|
||||
screen.getByRole('tab', { name: '主机与远程执行' })
|
||||
|
||||
@@ -764,6 +764,8 @@ export function SettingsPanel({
|
||||
>()
|
||||
const runtimeCustomizationRef =
|
||||
useRef<RuntimeCustomizationSectionHandle>(null)
|
||||
const keepEditingRef = useRef<HTMLButtonElement>(null)
|
||||
const leaveTriggerRef = useRef<HTMLElement | undefined>(undefined)
|
||||
const handleRuntimeCustomizationDirtyChange = useCallback(
|
||||
(dirty: boolean): void => {
|
||||
setRuntimeCustomizationDirty(dirty)
|
||||
@@ -976,12 +978,18 @@ export function SettingsPanel({
|
||||
}, [hasUnsavedDrafts, open])
|
||||
|
||||
const requestTabChange = (
|
||||
category: SettingsCategoryId
|
||||
category: SettingsCategoryId,
|
||||
trigger?: HTMLElement
|
||||
): boolean => {
|
||||
if (category === activeTab) {
|
||||
return true
|
||||
}
|
||||
if (navigationWouldLoseDraft) {
|
||||
leaveTriggerRef.current =
|
||||
trigger ??
|
||||
(document.activeElement instanceof HTMLElement
|
||||
? document.activeElement
|
||||
: undefined)
|
||||
setPendingLeave({ kind: 'navigate', category })
|
||||
return false
|
||||
}
|
||||
@@ -1018,7 +1026,7 @@ export function SettingsPanel({
|
||||
}
|
||||
event.preventDefault()
|
||||
const nextTab = settingsTabs[nextIndex]!
|
||||
if (!requestTabChange(nextTab)) {
|
||||
if (!requestTabChange(nextTab, event.currentTarget)) {
|
||||
return
|
||||
}
|
||||
event.currentTarget.parentElement
|
||||
@@ -1174,8 +1182,13 @@ export function SettingsPanel({
|
||||
return normalizedContextCompression
|
||||
}
|
||||
|
||||
const close = (): void => {
|
||||
const close = (trigger?: HTMLElement): void => {
|
||||
if (hasUnsavedDrafts) {
|
||||
leaveTriggerRef.current =
|
||||
trigger ??
|
||||
(document.activeElement instanceof HTMLElement
|
||||
? document.activeElement
|
||||
: undefined)
|
||||
setPendingLeave({ kind: 'close' })
|
||||
return
|
||||
}
|
||||
@@ -1240,6 +1253,11 @@ export function SettingsPanel({
|
||||
setError(undefined)
|
||||
if (leave?.kind === 'navigate') {
|
||||
setActiveTab(leave.category)
|
||||
requestAnimationFrame(() =>
|
||||
document
|
||||
.getElementById(`settings-tab-${leave.category}`)
|
||||
?.focus()
|
||||
)
|
||||
return
|
||||
}
|
||||
if (leave?.kind === 'external') {
|
||||
@@ -1252,9 +1270,34 @@ export function SettingsPanel({
|
||||
}
|
||||
}
|
||||
|
||||
const keepEditing = (): void => {
|
||||
const trigger = leaveTriggerRef.current
|
||||
setPendingLeave(undefined)
|
||||
setError(undefined)
|
||||
requestAnimationFrame(() => {
|
||||
if (trigger?.isConnected) {
|
||||
trigger.focus()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
useLayoutEffect(() => {
|
||||
if (!pendingLeave) {
|
||||
return
|
||||
}
|
||||
if (settingsBodyRef.current) {
|
||||
settingsBodyRef.current.scrollTop = 0
|
||||
}
|
||||
keepEditingRef.current?.focus()
|
||||
}, [pendingLeave])
|
||||
|
||||
useLayoutEffect(() => {
|
||||
const requestLeave: SettingsLeaveRequester = (proceed) => {
|
||||
if (hasUnsavedDrafts) {
|
||||
leaveTriggerRef.current =
|
||||
document.activeElement instanceof HTMLElement
|
||||
? document.activeElement
|
||||
: undefined
|
||||
setPendingLeave({ kind: 'external', proceed })
|
||||
return
|
||||
}
|
||||
@@ -1902,7 +1945,7 @@ export function SettingsPanel({
|
||||
<button
|
||||
aria-label={t('center.close')}
|
||||
className="icon-button"
|
||||
onClick={close}
|
||||
onClick={(event) => close(event.currentTarget)}
|
||||
type="button"
|
||||
>
|
||||
<X aria-hidden="true" size={19} />
|
||||
@@ -1931,8 +1974,8 @@ export function SettingsPanel({
|
||||
aria-selected={activeTab === category.id}
|
||||
id={`settings-tab-${category.id}`}
|
||||
key={category.id}
|
||||
onClick={() => {
|
||||
requestTabChange(category.id)
|
||||
onClick={(event) => {
|
||||
requestTabChange(category.id, event.currentTarget)
|
||||
}}
|
||||
onKeyDown={(event) =>
|
||||
handleTabKeyDown(event, category.id)
|
||||
@@ -1973,10 +2016,8 @@ export function SettingsPanel({
|
||||
<div className="update-settings__actions">
|
||||
<button
|
||||
className="secondary-button"
|
||||
onClick={() => {
|
||||
setPendingLeave(undefined)
|
||||
setError(undefined)
|
||||
}}
|
||||
onClick={keepEditing}
|
||||
ref={keepEditingRef}
|
||||
type="button"
|
||||
>
|
||||
{t('unsaved.keepEditing')}
|
||||
@@ -3895,7 +3936,9 @@ export function SettingsPanel({
|
||||
magicNotesEnabled={magicNotesEnabled}
|
||||
/>
|
||||
)}
|
||||
{activeTab === 'about' && <UpdateSettingsSection />}
|
||||
{activeTab === 'about' && (
|
||||
<UpdateSettingsSection onNotify={onNotify} />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -345,6 +345,36 @@ describe('SshHostsSettingsSection', () => {
|
||||
expect(getSnapshot).toHaveBeenCalledOnce()
|
||||
})
|
||||
|
||||
it('separates a failed Host read from an empty list and retries it', async () => {
|
||||
getSnapshot
|
||||
.mockRejectedValueOnce(new Error('Host database unavailable'))
|
||||
.mockResolvedValueOnce(emptySnapshot)
|
||||
render(<SshHostsSettingsSection />)
|
||||
|
||||
expect(
|
||||
await screen.findByText('SSH 主机加载失败')
|
||||
).toBeInTheDocument()
|
||||
expect(screen.getByText('Host database unavailable')).toBeInTheDocument()
|
||||
expect(
|
||||
screen.queryByText('尚未配置 SSH 主机')
|
||||
).not.toBeInTheDocument()
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: '重试' }))
|
||||
|
||||
expect(await screen.findByText('尚未配置 SSH 主机'))
|
||||
.toBeInTheDocument()
|
||||
expect(getSnapshot).toHaveBeenCalledTimes(2)
|
||||
})
|
||||
|
||||
it('uses the shared live busy state while Hosts load', () => {
|
||||
getSnapshot.mockReturnValue(new Promise(() => {}))
|
||||
render(<SshHostsSettingsSection />)
|
||||
|
||||
const status = screen.getByRole('status')
|
||||
expect(status).toHaveAttribute('aria-live', 'polite')
|
||||
expect(status).toHaveAttribute('aria-busy', 'true')
|
||||
})
|
||||
|
||||
it('keeps failed authentication editable and retries without saving a failed host', async () => {
|
||||
getSnapshot
|
||||
.mockResolvedValueOnce(emptySnapshot)
|
||||
|
||||
@@ -107,6 +107,7 @@ export function SshHostsSettingsSection({
|
||||
const [projectReferences, setProjectReferences] =
|
||||
useState<SshHostsSnapshot['projectReferences']>()
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [loadError, setLoadError] = useState<string>()
|
||||
const [error, setError] = useState<string>()
|
||||
const [editingId, setEditingId] = useState<string | 'new'>()
|
||||
const [busyHostId, setBusyHostId] = useState<string>()
|
||||
@@ -202,34 +203,51 @@ export function SshHostsSettingsSection({
|
||||
setHosts(snapshot.hosts)
|
||||
setSecureStorageAvailable(snapshot.secureStorageAvailable)
|
||||
setProjectReferences(snapshot.projectReferences)
|
||||
setError(undefined)
|
||||
setLoadError(undefined)
|
||||
},
|
||||
[]
|
||||
)
|
||||
|
||||
const loadSnapshot = useCallback(async (): Promise<void> => {
|
||||
setLoading(true)
|
||||
setLoadError(undefined)
|
||||
try {
|
||||
applySnapshot(await requestSnapshot())
|
||||
} catch (reason) {
|
||||
setLoadError(
|
||||
displayErrorMessage(
|
||||
reason,
|
||||
t('sshHosts.errors.readFailed')
|
||||
)
|
||||
)
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}, [applySnapshot, requestSnapshot, t])
|
||||
|
||||
useEffect(() => {
|
||||
let active = true
|
||||
void requestSnapshot()
|
||||
.then((snapshot) => {
|
||||
setLoading(true)
|
||||
setLoadError(undefined)
|
||||
void requestSnapshot().then(
|
||||
(snapshot) => {
|
||||
if (active) {
|
||||
applySnapshot(snapshot)
|
||||
setLoading(false)
|
||||
}
|
||||
})
|
||||
.catch((reason: unknown) => {
|
||||
},
|
||||
(reason: unknown) => {
|
||||
if (active) {
|
||||
setError(
|
||||
setLoadError(
|
||||
displayErrorMessage(
|
||||
reason,
|
||||
t('sshHosts.errors.readFailed')
|
||||
)
|
||||
)
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
if (active) {
|
||||
setLoading(false)
|
||||
}
|
||||
})
|
||||
}
|
||||
)
|
||||
return () => {
|
||||
active = false
|
||||
}
|
||||
@@ -620,7 +638,28 @@ export function SshHostsSettingsSection({
|
||||
)}
|
||||
|
||||
{loading ? (
|
||||
<div className="settings-empty">{t('sshHosts.loading')}</div>
|
||||
<EmptyState
|
||||
description={t('sshHosts.loading')}
|
||||
icon={<LoaderCircle size={22} />}
|
||||
title={t('sshHosts.loading')}
|
||||
variant="loading"
|
||||
/>
|
||||
) : loadError ? (
|
||||
<EmptyState
|
||||
action={
|
||||
<button
|
||||
className="secondary-button"
|
||||
onClick={() => void loadSnapshot()}
|
||||
type="button"
|
||||
>
|
||||
<RefreshCw aria-hidden="true" size={14} />
|
||||
{t('sshHosts.actions.retry')}
|
||||
</button>
|
||||
}
|
||||
description={loadError}
|
||||
icon={<Server size={22} />}
|
||||
title={t('sshHosts.loadFailedTitle')}
|
||||
/>
|
||||
) : hosts.length === 0 ? (
|
||||
<EmptyState
|
||||
action={
|
||||
|
||||
@@ -122,11 +122,12 @@ describe('UpdateSettingsSection', () => {
|
||||
checkUpdatesOnStartup: false
|
||||
})
|
||||
)
|
||||
expect(source).toBeDisabled()
|
||||
expect(source).toBeEnabled()
|
||||
|
||||
fireEvent.click(
|
||||
screen.getByRole('button', { name: '立即检查更新' })
|
||||
)
|
||||
expect(source).toHaveValue('mirror')
|
||||
expect(await screen.findByText('发现新版本 0.9.0'))
|
||||
.toBeInTheDocument()
|
||||
expect(
|
||||
@@ -144,7 +145,7 @@ describe('UpdateSettingsSection', () => {
|
||||
expect(dialog).toHaveAttribute('aria-modal', 'true')
|
||||
expect(screen.getByLabelText('反馈类型')).toHaveFocus()
|
||||
expect(
|
||||
screen.getByText(/不会自动发送对话、日志、文件/)
|
||||
screen.getByText(/不会发送对话、Prompt、凭据、文件内容/)
|
||||
).toBeInTheDocument()
|
||||
fireEvent.keyDown(dialog, { key: 'Escape' })
|
||||
expect(
|
||||
@@ -204,6 +205,55 @@ describe('UpdateSettingsSection', () => {
|
||||
expect(alert).not.toHaveTextContent('Error invoking remote method')
|
||||
})
|
||||
|
||||
it('routes download-page failures through app notifications', async () => {
|
||||
const onNotify = vi.fn()
|
||||
Object.defineProperty(window, 'goodbuddy', {
|
||||
configurable: true,
|
||||
value: {
|
||||
app: {
|
||||
getInfo: vi.fn(async () => ({
|
||||
name: 'GoodBuddy',
|
||||
version: '0.8.1',
|
||||
platform: 'win32',
|
||||
arch: 'x64',
|
||||
shortcut: 'Ctrl+Shift+Space'
|
||||
}))
|
||||
},
|
||||
updates: {
|
||||
getSettings: vi.fn(async () => ({
|
||||
checkUpdatesOnStartup: false,
|
||||
updateSource: 'mirror',
|
||||
magicNotesEnabled: true,
|
||||
magicNoteCommentMode: 'immediate',
|
||||
magicNoteCommentFormat: 'combined'
|
||||
})),
|
||||
updateSettings: vi.fn(),
|
||||
check: vi.fn(),
|
||||
openReleasePage: vi.fn(async () => {
|
||||
throw new Error('Shell refused the release URL')
|
||||
}),
|
||||
onResult: vi.fn(() => () => {})
|
||||
}
|
||||
} as unknown as DesktopApi
|
||||
})
|
||||
|
||||
render(<UpdateSettingsSection onNotify={onNotify} />)
|
||||
fireEvent.click(
|
||||
await screen.findByRole('button', { name: '打开下载页' })
|
||||
)
|
||||
|
||||
await waitFor(() =>
|
||||
expect(onNotify).toHaveBeenCalledWith({
|
||||
dedupeKey: 'open-update-download-page-failed',
|
||||
message: 'Shell refused the release URL',
|
||||
tone: 'error'
|
||||
})
|
||||
)
|
||||
expect(
|
||||
screen.queryByText('Shell refused the release URL')
|
||||
).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('keeps feedback available when update settings are unavailable', async () => {
|
||||
Object.defineProperty(window, 'goodbuddy', {
|
||||
configurable: true,
|
||||
|
||||
@@ -11,11 +11,15 @@ import type {
|
||||
VersionCheckResult
|
||||
} from '../../shared/application-settings-contracts'
|
||||
import type { AppInfo } from '../../shared/contracts'
|
||||
import type { AppNotificationInput } from './notifications'
|
||||
import {
|
||||
SettingsCategoryHeader,
|
||||
SettingsWarningList
|
||||
} from './SettingsPrimitives'
|
||||
import { displayErrorMessage } from './error-message'
|
||||
import {
|
||||
displayErrorMessage,
|
||||
displayNetworkAwareErrorMessage
|
||||
} from './error-message'
|
||||
import { FeedbackDialog } from './FeedbackDialog'
|
||||
|
||||
function formatBytes(bytes: number): string {
|
||||
@@ -25,19 +29,11 @@ function formatBytes(bytes: number): string {
|
||||
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`
|
||||
}
|
||||
|
||||
function updateErrorMessage(
|
||||
reason: unknown,
|
||||
fallback: string,
|
||||
networkMessage: string
|
||||
): string {
|
||||
const message = displayErrorMessage(reason, fallback)
|
||||
if (/fetch failed/i.test(message)) {
|
||||
return networkMessage
|
||||
}
|
||||
return message
|
||||
}
|
||||
|
||||
export function UpdateSettingsSection(): React.JSX.Element {
|
||||
export function UpdateSettingsSection({
|
||||
onNotify
|
||||
}: {
|
||||
onNotify?: (notification: AppNotificationInput) => void
|
||||
}): React.JSX.Element {
|
||||
const { t } = useTranslation('settingsSections')
|
||||
const [settings, setSettings] = useState<ApplicationSettings>()
|
||||
const [appInfo, setAppInfo] = useState<AppInfo>()
|
||||
@@ -79,7 +75,7 @@ export function UpdateSettingsSection(): React.JSX.Element {
|
||||
if (active) {
|
||||
const fallback = t('updates.errors.readSettingsFailed')
|
||||
setError(
|
||||
updateErrorMessage(
|
||||
displayNetworkAwareErrorMessage(
|
||||
reason,
|
||||
fallback,
|
||||
t('updates.errors.network', { fallback })
|
||||
@@ -108,7 +104,7 @@ export function UpdateSettingsSection(): React.JSX.Element {
|
||||
} catch (reason) {
|
||||
const fallback = t('updates.errors.saveSettingsFailed')
|
||||
setError(
|
||||
updateErrorMessage(
|
||||
displayNetworkAwareErrorMessage(
|
||||
reason,
|
||||
fallback,
|
||||
t('updates.errors.network', { fallback })
|
||||
@@ -134,7 +130,7 @@ export function UpdateSettingsSection(): React.JSX.Element {
|
||||
} catch (reason) {
|
||||
const fallback = t('updates.errors.saveSourceFailed')
|
||||
setError(
|
||||
updateErrorMessage(
|
||||
displayNetworkAwareErrorMessage(
|
||||
reason,
|
||||
fallback,
|
||||
t('updates.errors.network', {
|
||||
@@ -159,7 +155,7 @@ export function UpdateSettingsSection(): React.JSX.Element {
|
||||
} catch (reason) {
|
||||
const fallback = t('updates.errors.checkFailed')
|
||||
setError(
|
||||
updateErrorMessage(
|
||||
displayNetworkAwareErrorMessage(
|
||||
reason,
|
||||
fallback,
|
||||
t('updates.errors.sourceNetwork', {
|
||||
@@ -175,6 +171,30 @@ export function UpdateSettingsSection(): React.JSX.Element {
|
||||
}
|
||||
}
|
||||
|
||||
const openReleasePage = async (): Promise<void> => {
|
||||
const updates = window.goodbuddy.updates
|
||||
if (!updates) {
|
||||
onNotify?.({
|
||||
dedupeKey: 'open-update-download-page-failed',
|
||||
message: t('updates.errors.serviceUnavailable'),
|
||||
tone: 'error'
|
||||
})
|
||||
return
|
||||
}
|
||||
try {
|
||||
await updates.openReleasePage()
|
||||
} catch (reason) {
|
||||
onNotify?.({
|
||||
dedupeKey: 'open-update-download-page-failed',
|
||||
message: displayErrorMessage(
|
||||
reason,
|
||||
t('updates.errors.openReleasePageFailed')
|
||||
),
|
||||
tone: 'error'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<SettingsCategoryHeader
|
||||
@@ -219,7 +239,6 @@ export function UpdateSettingsSection(): React.JSX.Element {
|
||||
aria-label={t('updates.source.label')}
|
||||
disabled={
|
||||
!settings ||
|
||||
!settings.checkUpdatesOnStartup ||
|
||||
saving ||
|
||||
checking
|
||||
}
|
||||
@@ -254,9 +273,7 @@ export function UpdateSettingsSection(): React.JSX.Element {
|
||||
</button>
|
||||
<button
|
||||
className="secondary-button"
|
||||
onClick={() =>
|
||||
void window.goodbuddy.updates?.openReleasePage()
|
||||
}
|
||||
onClick={() => void openReleasePage()}
|
||||
type="button"
|
||||
>
|
||||
<ExternalLink aria-hidden="true" size={13} />
|
||||
|
||||
@@ -611,6 +611,20 @@ describe('WorkspacePrimitives', () => {
|
||||
)
|
||||
})
|
||||
|
||||
it('announces shared loading empty states consistently', () => {
|
||||
render(
|
||||
<EmptyState
|
||||
description="正在读取内容。"
|
||||
title="正在加载"
|
||||
variant="loading"
|
||||
/>
|
||||
)
|
||||
|
||||
const status = screen.getByRole('status')
|
||||
expect(status).toHaveAttribute('aria-live', 'polite')
|
||||
expect(status).toHaveAttribute('aria-busy', 'true')
|
||||
})
|
||||
|
||||
it('uses the shared destructive confirmation flow', () => {
|
||||
const onRequestConfirm = vi.fn()
|
||||
const onConfirm = vi.fn()
|
||||
|
||||
@@ -330,16 +330,23 @@ export function EmptyState({
|
||||
description,
|
||||
icon,
|
||||
level = 'section',
|
||||
title
|
||||
title,
|
||||
variant = 'default'
|
||||
}: {
|
||||
action?: ReactNode
|
||||
description: ReactNode
|
||||
icon?: ReactNode
|
||||
level?: 'page' | 'section' | 'table'
|
||||
title?: string
|
||||
variant?: 'default' | 'loading'
|
||||
}): React.JSX.Element {
|
||||
return (
|
||||
<div className={`empty-state empty-state--${level}`}>
|
||||
<div
|
||||
aria-busy={variant === 'loading' ? 'true' : undefined}
|
||||
aria-live={variant === 'loading' ? 'polite' : undefined}
|
||||
className={`empty-state empty-state--${level}`}
|
||||
role={variant === 'loading' ? 'status' : undefined}
|
||||
>
|
||||
{icon && (
|
||||
<span aria-hidden="true" className="empty-state__icon">
|
||||
{icon}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import {
|
||||
displayErrorMessage,
|
||||
displayNetworkAwareErrorMessage
|
||||
} from './error-message'
|
||||
|
||||
describe('error message formatting', () => {
|
||||
it('replaces fetch failures with localized network guidance', () => {
|
||||
expect(
|
||||
displayNetworkAwareErrorMessage(
|
||||
new Error(
|
||||
"Error invoking remote method 'application:update:check': TypeError: fetch failed"
|
||||
),
|
||||
'Version check failed',
|
||||
'Check your network and try again'
|
||||
)
|
||||
).toBe('Check your network and try again')
|
||||
})
|
||||
|
||||
it('preserves bounded HTTP and provider details', () => {
|
||||
expect(
|
||||
displayNetworkAwareErrorMessage(
|
||||
new Error('HTTP 503: release manifest unavailable'),
|
||||
'Version check failed',
|
||||
'Check your network and try again'
|
||||
)
|
||||
).toBe('HTTP 503: release manifest unavailable')
|
||||
expect(
|
||||
displayErrorMessage(
|
||||
new Error(
|
||||
"Error invoking remote method 'application:update:check': Error: provider rejected request"
|
||||
),
|
||||
'Version check failed'
|
||||
)
|
||||
).toBe('provider rejected request')
|
||||
})
|
||||
})
|
||||
@@ -22,3 +22,16 @@ export function displayErrorMessage(
|
||||
.trim()
|
||||
return message || fallback
|
||||
}
|
||||
|
||||
export function displayNetworkAwareErrorMessage(
|
||||
reason: unknown,
|
||||
fallback: string,
|
||||
networkMessage: string
|
||||
): string {
|
||||
const message = displayErrorMessage(reason, fallback)
|
||||
return /(?:fetch failed|failed to fetch|networkerror|network request failed)/iu.test(
|
||||
message
|
||||
)
|
||||
? networkMessage
|
||||
: message
|
||||
}
|
||||
|
||||
@@ -79,7 +79,15 @@ export const app = {
|
||||
unread: 'Unread',
|
||||
unreadRemote: 'Unread remote message',
|
||||
noRemote: 'No remote conversations yet',
|
||||
empty: 'No recent conversations yet',
|
||||
emptyDescription:
|
||||
'Start a conversation and it will appear here.',
|
||||
noMatches: 'No matching conversations',
|
||||
noMatchesDescription:
|
||||
'Change your search terms or clear the search to view all conversations.',
|
||||
clearSearch: 'Clear search',
|
||||
loadFailed: 'Could not load recent conversations',
|
||||
retryLoad: 'Reload conversations',
|
||||
renameAria: 'Rename conversation {{title}}',
|
||||
saveName: 'Save conversation name',
|
||||
cancelRename: 'Cancel rename',
|
||||
@@ -159,8 +167,9 @@ export const app = {
|
||||
workspace: 'Workspace',
|
||||
tools: 'Tools and approval',
|
||||
executeApproval:
|
||||
'Use authorized tools; high-risk actions still require approval',
|
||||
askReadOnly: 'Read-only run with no changes allowed',
|
||||
'Use all tools, processes, network access, and writable paths available to the current account; calls are recorded in Activity',
|
||||
askReadOnly:
|
||||
'Stay within the read-only boundary for answers and retrieval; make no changes',
|
||||
noWorkspace: 'No workspace configured'
|
||||
},
|
||||
errors: {
|
||||
@@ -204,6 +213,11 @@ export const app = {
|
||||
readStatus: 'Failed to read Agent Runtime status',
|
||||
readSettings: 'Failed to read Runtime settings',
|
||||
switch: 'Failed to switch Runtime'
|
||||
},
|
||||
state: {
|
||||
ready: 'Ready',
|
||||
connecting: 'Connecting',
|
||||
unavailable: 'Unavailable'
|
||||
}
|
||||
},
|
||||
chat: {
|
||||
@@ -367,6 +381,7 @@ export const app = {
|
||||
}
|
||||
},
|
||||
approval: {
|
||||
waiting: 'Awaiting approval: {{tool}}',
|
||||
deny: 'Deny',
|
||||
once: 'Allow once',
|
||||
session: 'Allow for conversation',
|
||||
@@ -476,11 +491,13 @@ export const app = {
|
||||
modes: {
|
||||
ask: {
|
||||
label: 'Ask · Read only',
|
||||
description: 'Read-only answers without modifying files'
|
||||
description:
|
||||
'Stay within the read-only boundary for answers and retrieval; make no changes'
|
||||
},
|
||||
execute: {
|
||||
label: 'Execute · Full access',
|
||||
description: 'Run tools with the account’s full permissions'
|
||||
description:
|
||||
'Use all tools, processes, network access, and writable paths available to the current account; calls are recorded in Activity'
|
||||
}
|
||||
},
|
||||
voice: {
|
||||
@@ -556,12 +573,13 @@ export const app = {
|
||||
imageGeneration:
|
||||
'Image model: describe a scene to generate an image that will appear here and be saved to Results.',
|
||||
agentAsk:
|
||||
'{{runtime}} Ask mode: can only search enabled knowledge bases and cannot modify files.',
|
||||
'{{runtime}} Ask mode: stays within the read-only boundary for answers and retrieval and makes no changes.',
|
||||
agentExecute:
|
||||
'{{runtime}} Execute mode: tool calls do not show GoodBuddy approvals and are recorded in Activity.',
|
||||
ask: 'Ask mode: read-only answers without tool calls or file changes.',
|
||||
'{{runtime}} Execute mode: uses all tools, processes, network access, and writable paths available to the current account; calls are recorded in Activity.',
|
||||
ask:
|
||||
'Ask mode: stays within the read-only boundary for answers and retrieval and makes no changes.',
|
||||
execute:
|
||||
'Execute mode: tools are automatically authorized and calls are still recorded in Activity.'
|
||||
'Execute mode: uses all tools, processes, network access, and writable paths available to the current account; calls are recorded in Activity.'
|
||||
},
|
||||
errors: {
|
||||
pasteImageType: 'Only JPEG, PNG, or WebP images can be pasted',
|
||||
@@ -574,6 +592,15 @@ export const app = {
|
||||
brandingSaved: 'Branding saved',
|
||||
updateAvailable:
|
||||
'GoodBuddy {{version}} is available. View it in About & Updates.',
|
||||
startupUpdateCheckFailed:
|
||||
'Startup update check failed ({{source}}): {{error}}',
|
||||
updateCheckFailed: 'Version check failed',
|
||||
updateCheckNetwork:
|
||||
'Could not connect to the update source. Check your network or proxy and try again.',
|
||||
updateSources: {
|
||||
github: 'GitHub',
|
||||
mirror: 'Mirror node'
|
||||
},
|
||||
channelConversationAutomatic:
|
||||
'Channel conversations are created automatically when the client receives a new message',
|
||||
deleteConversationCancelFailed:
|
||||
|
||||
@@ -10,6 +10,7 @@ export const settingsSections = {
|
||||
},
|
||||
sshHosts: {
|
||||
loading: 'Loading SSH hosts…',
|
||||
loadFailedTitle: 'Could not load SSH hosts',
|
||||
listLabel: 'SSH host list',
|
||||
securityNotice:
|
||||
'When a host is added or edited, GoodBuddy inspects its host key before sending credentials and running a bounded system probe. The host and encrypted password are saved only after every step succeeds.',
|
||||
@@ -191,6 +192,7 @@ export const settingsSections = {
|
||||
removeProjectsHeading: 'Also remove these related project records:',
|
||||
actions: {
|
||||
add: 'Add host',
|
||||
retry: 'Retry',
|
||||
edit: 'Edit and revalidate',
|
||||
validate: 'Validate and save',
|
||||
editNamed: 'Edit {{name}}',
|
||||
@@ -757,6 +759,11 @@ export const settingsSections = {
|
||||
'Used only if we need to contact you for more information.',
|
||||
characterCount: '{{count}} / {{maximum}} characters'
|
||||
},
|
||||
diagnostics: {
|
||||
label: 'Attach recent desktop diagnostics',
|
||||
description:
|
||||
'Off by default. When selected, this adds only timestamps, components, stages, stable error codes, error types, and fixed short messages from recent desktop diagnostics. It does not include conversations, prompts, credentials, file contents, paths, raw provider responses, or remote Agent logs.'
|
||||
},
|
||||
screenshot: {
|
||||
title: 'Screenshot (optional)',
|
||||
help:
|
||||
@@ -783,11 +790,15 @@ export const settingsSections = {
|
||||
}
|
||||
},
|
||||
privacy:
|
||||
'GoodBuddy will send the feedback type, title, description, optional email, app version, operating system, architecture, interface language, and any screenshot you add. Conversations, logs, files, project paths, model settings, and credentials are never attached automatically.',
|
||||
'GoodBuddy will send the feedback type, title, description, optional email, app version, operating system, architecture, interface language, and any screenshot you add. Desktop diagnostics are not uploaded by default; a bounded summary is appended to the description only when selected. Conversations, prompts, credentials, file contents, paths, raw provider responses, and remote Agent logs are not sent.',
|
||||
validation: {
|
||||
titleRequired: 'Enter a feedback title.',
|
||||
descriptionMinimum:
|
||||
'The detailed description must contain at least 10 characters.',
|
||||
descriptionMaximum:
|
||||
'The detailed description must be {{maximum}} characters or fewer. Your draft is preserved; shorten it and try again.',
|
||||
descriptionMaximumWithDiagnostics:
|
||||
'When desktop diagnostics are attached, the detailed description must be {{maximum}} characters or fewer. Your draft is preserved; shorten it and try again.',
|
||||
emailInvalid: 'Enter a valid contact email or leave it blank.'
|
||||
},
|
||||
actions: {
|
||||
@@ -830,7 +841,9 @@ export const settingsSections = {
|
||||
timeout:
|
||||
'The feedback service connection timed out. Check your network and try again.',
|
||||
'invalid-response':
|
||||
'The feedback service returned an invalid result. Try again later.'
|
||||
'The feedback service returned an invalid result. Try again later.',
|
||||
'diagnostics-unavailable':
|
||||
'The selected desktop diagnostics could not be read, so no feedback was sent. Your draft and selection are preserved; retry or clear the diagnostics checkbox before submitting.'
|
||||
}
|
||||
},
|
||||
updates: {
|
||||
@@ -842,6 +855,7 @@ export const settingsSections = {
|
||||
saveSettingsFailed: 'Could not save update settings',
|
||||
saveSourceFailed: 'Could not save the update source',
|
||||
checkFailed: 'Version check failed',
|
||||
openReleasePageFailed: 'Could not open the download page',
|
||||
network: '{{fallback}}. Check the system status and try again.',
|
||||
sourceNetwork:
|
||||
'{{fallback}}: Could not connect to update source "{{source}}". Check your network or proxy and try again.'
|
||||
|
||||
@@ -76,7 +76,13 @@ export const app = {
|
||||
unread: '未读',
|
||||
unreadRemote: '未读远程消息',
|
||||
noRemote: '尚无远程会话',
|
||||
empty: '还没有最近会话',
|
||||
emptyDescription: '新建对话后,会话会显示在这里。',
|
||||
noMatches: '没有匹配的对话',
|
||||
noMatchesDescription: '请修改搜索关键词,或清除搜索后查看全部会话。',
|
||||
clearSearch: '清除搜索',
|
||||
loadFailed: '最近会话加载失败',
|
||||
retryLoad: '重新读取会话',
|
||||
renameAria: '重命名会话 {{title}}',
|
||||
saveName: '保存会话名称',
|
||||
cancelRename: '取消重命名',
|
||||
@@ -148,8 +154,9 @@ export const app = {
|
||||
runtime: 'Runtime',
|
||||
workspace: '工作目录',
|
||||
tools: '工具与审批',
|
||||
executeApproval: '使用已授权工具;高风险操作仍需审批',
|
||||
askReadOnly: '只读运行,不允许执行变更',
|
||||
executeApproval:
|
||||
'使用当前账号可用的全部工具、进程、网络和可写路径;调用记录到活动',
|
||||
askReadOnly: '保持只读边界,仅问答和检索,不执行任何变更',
|
||||
noWorkspace: '未设置工作目录'
|
||||
},
|
||||
errors: {
|
||||
@@ -193,6 +200,11 @@ export const app = {
|
||||
readStatus: 'Agent Runtime 状态读取失败',
|
||||
readSettings: 'Runtime 设置读取失败',
|
||||
switch: 'Runtime 切换失败'
|
||||
},
|
||||
state: {
|
||||
ready: '就绪',
|
||||
connecting: '连接中',
|
||||
unavailable: '不可用'
|
||||
}
|
||||
},
|
||||
chat: {
|
||||
@@ -351,6 +363,7 @@ export const app = {
|
||||
}
|
||||
},
|
||||
approval: {
|
||||
waiting: '等待审批:{{tool}}',
|
||||
deny: '拒绝',
|
||||
once: '仅此次',
|
||||
session: '此会话',
|
||||
@@ -455,11 +468,12 @@ export const app = {
|
||||
modes: {
|
||||
ask: {
|
||||
label: 'Ask · 只读问答',
|
||||
description: '只读问答,不修改文件'
|
||||
description: '保持只读边界,仅问答和检索,不执行任何变更'
|
||||
},
|
||||
execute: {
|
||||
label: 'Execute · 完全权限',
|
||||
description: '使用当前账号的完整权限执行工具操作'
|
||||
description:
|
||||
'使用当前账号可用的全部工具、进程、网络和可写路径;调用记录到活动'
|
||||
}
|
||||
},
|
||||
voice: {
|
||||
@@ -521,11 +535,12 @@ export const app = {
|
||||
imageGeneration:
|
||||
'图像生成模型:输入画面描述后,生成结果会直接显示并保存到成果。',
|
||||
agentAsk:
|
||||
'{{runtime}} Ask 模式:只允许搜索当前启用的知识库,不会修改文件。',
|
||||
'{{runtime}} Ask 模式:保持只读边界,仅问答和检索,不执行任何变更。',
|
||||
agentExecute:
|
||||
'{{runtime}} Execute 模式:工具调用不会弹出 GoodBuddy 审批,并会记录到活动。',
|
||||
ask: 'Ask 模式:只读问答,不会调用工具或修改文件。',
|
||||
execute: 'Execute 模式:已启用工具自动授权,调用仍会记录到活动。'
|
||||
'{{runtime}} Execute 模式:使用当前账号可用的全部工具、进程、网络和可写路径;调用记录到活动。',
|
||||
ask: 'Ask 模式:保持只读边界,仅问答和检索,不执行任何变更。',
|
||||
execute:
|
||||
'Execute 模式:使用当前账号可用的全部工具、进程、网络和可写路径;调用记录到活动。'
|
||||
},
|
||||
errors: {
|
||||
pasteImageType: '仅支持粘贴 JPEG、PNG 或 WebP 图片',
|
||||
@@ -537,6 +552,14 @@ export const app = {
|
||||
notices: {
|
||||
brandingSaved: '品牌设置已保存',
|
||||
updateAvailable: '发现 GoodBuddy {{version}},可在“关于与更新”中查看',
|
||||
startupUpdateCheckFailed:
|
||||
'启动更新检查失败({{source}}):{{error}}',
|
||||
updateCheckFailed: '版本检查失败',
|
||||
updateCheckNetwork: '无法连接更新源,请检查网络或代理后重试',
|
||||
updateSources: {
|
||||
github: 'GitHub',
|
||||
mirror: '镜像节点'
|
||||
},
|
||||
channelConversationAutomatic:
|
||||
'通道项目的会话由客户端收到新消息后自动创建',
|
||||
deleteConversationCancelFailed:
|
||||
|
||||
@@ -5,6 +5,7 @@ export const settingsSections = {
|
||||
},
|
||||
sshHosts: {
|
||||
loading: '正在读取 SSH 主机…',
|
||||
loadFailedTitle: 'SSH 主机加载失败',
|
||||
listLabel: 'SSH 主机列表',
|
||||
securityNotice:
|
||||
'添加或编辑主机时,GoodBuddy 会先检查 Host Key,再发送认证凭据并执行有界系统探测。只有全部成功后才会保存主机和加密密码。',
|
||||
@@ -183,6 +184,7 @@ export const settingsSections = {
|
||||
removeProjectsHeading: '同时删除以下关联项目记录:',
|
||||
actions: {
|
||||
add: '添加主机',
|
||||
retry: '重试',
|
||||
edit: '编辑',
|
||||
validate: '验证并保存',
|
||||
editNamed: '编辑 {{name}}',
|
||||
@@ -710,6 +712,11 @@ export const settingsSections = {
|
||||
emailHelp: '仅在需要进一步了解情况时用于联系你。',
|
||||
characterCount: '已输入 {{count}} / {{maximum}} 个字符'
|
||||
},
|
||||
diagnostics: {
|
||||
label: '附加最近桌面诊断记录',
|
||||
description:
|
||||
'默认关闭。选中后仅附加最近桌面诊断的时间、组件、阶段、稳定错误码、错误类型和固定短消息;不包含对话、Prompt、凭据、文件内容、路径、Provider 原始响应或远端 Agent 日志。'
|
||||
},
|
||||
screenshot: {
|
||||
title: '截图(可选)',
|
||||
help: '选择或粘贴一张 PNG、JPEG 或 WebP 图片,最大 5 MB。',
|
||||
@@ -734,10 +741,14 @@ export const settingsSections = {
|
||||
}
|
||||
},
|
||||
privacy:
|
||||
'将发送反馈类型、标题、描述、可选邮箱、GoodBuddy 版本、操作系统、架构、界面语言,以及你主动添加的截图。不会自动发送对话、日志、文件、项目路径、模型配置或凭据。',
|
||||
'将发送反馈类型、标题、描述、可选邮箱、GoodBuddy 版本、操作系统、架构、界面语言,以及你主动添加的截图。默认不会上传桌面诊断;只有勾选后才会把有界诊断摘要追加到描述。不会发送对话、Prompt、凭据、文件内容、路径、Provider 原始响应或远端 Agent 日志。',
|
||||
validation: {
|
||||
titleRequired: '请输入反馈标题。',
|
||||
descriptionMinimum: '详细描述至少需要 10 个字符。',
|
||||
descriptionMaximum:
|
||||
'详细描述不能超过 {{maximum}} 个字符;草稿已保留,请缩短后重试。',
|
||||
descriptionMaximumWithDiagnostics:
|
||||
'附加桌面诊断时,详细描述不能超过 {{maximum}} 个字符;草稿已保留,请缩短后重试。',
|
||||
emailInvalid: '请输入有效的联系邮箱,或将其留空。'
|
||||
},
|
||||
actions: {
|
||||
@@ -774,7 +785,9 @@ export const settingsSections = {
|
||||
network: '无法连接反馈服务,请检查网络后重试。',
|
||||
timeout: '连接反馈服务超时,请检查网络后重试。',
|
||||
'invalid-response':
|
||||
'反馈服务返回了无效结果,请稍后重试。'
|
||||
'反馈服务返回了无效结果,请稍后重试。',
|
||||
'diagnostics-unavailable':
|
||||
'无法读取所选的桌面诊断记录,本次没有发送反馈。草稿和选择已保留,请重试或取消附加诊断后提交。'
|
||||
}
|
||||
},
|
||||
updates: {
|
||||
@@ -785,6 +798,7 @@ export const settingsSections = {
|
||||
saveSettingsFailed: '保存更新设置失败',
|
||||
saveSourceFailed: '保存检查更新源失败',
|
||||
checkFailed: '版本检查失败',
|
||||
openReleasePageFailed: '打开下载页失败',
|
||||
network: '{{fallback}}:请检查系统状态后重试',
|
||||
sourceNetwork:
|
||||
'{{fallback}}:无法连接更新源“{{source}}”,请检查网络或代理后重试'
|
||||
|
||||
@@ -9059,6 +9059,41 @@ details.settings-section > :not(summary) + :not(summary) {
|
||||
color: var(--danger);
|
||||
}
|
||||
|
||||
.feedback-diagnostics-option {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
color: var(--text-primary);
|
||||
cursor: pointer;
|
||||
gap: var(--space-2);
|
||||
}
|
||||
|
||||
.feedback-diagnostics-option > input {
|
||||
margin: 2px 0 0;
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
.feedback-diagnostics-option > span {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
flex-direction: column;
|
||||
gap: var(--space-1);
|
||||
}
|
||||
|
||||
.feedback-diagnostics-option strong {
|
||||
font-size: var(--font-body);
|
||||
}
|
||||
|
||||
.feedback-diagnostics-option small {
|
||||
color: var(--text-muted);
|
||||
font-size: var(--font-caption);
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.feedback-diagnostics-option:has(input:disabled) {
|
||||
cursor: default;
|
||||
opacity: 0.65;
|
||||
}
|
||||
|
||||
.feedback-screenshot {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
Reference in New Issue
Block a user