mirror of
https://github.com/NanmiCoder/claude-code-haha.git
synced 2026-10-10 11:53:10 +08:00
fix(desktop): hide checkpoint preview budget from chat
This commit is contained in:
@@ -21,6 +21,7 @@ import {
|
||||
} from './virtualHeightCache'
|
||||
import { relativizeWorkspacePath } from './CurrentTurnChangeCard'
|
||||
import { sessionsApi } from '../../api/sessions'
|
||||
import { ApiError } from '../../api/client'
|
||||
import { subagentsApi, type SubagentRunResponse } from '../../api/subagents'
|
||||
import { teamsApi } from '../../api/teams'
|
||||
import { resetAgentRunActivityCache } from './useAgentRunActivity'
|
||||
@@ -6062,6 +6063,28 @@ describe('MessageList nested tool calls', () => {
|
||||
expect(screen.queryByLabelText('Turn changed files')).toBeNull()
|
||||
})
|
||||
|
||||
it('does not show the checkpoint preview budget as a chat error', async () => {
|
||||
vi.spyOn(sessionsApi, 'getTurnCheckpoints').mockRejectedValue(new ApiError(413, {
|
||||
error: 'HISTORY_CHECKPOINT_PREVIEW_LIMIT',
|
||||
message: 'This transcript exceeds the full checkpoint preview budget. Chat history remains available in pages.',
|
||||
}))
|
||||
useChatStore.setState({ sessions: { [ACTIVE_TAB]: makeSessionState({
|
||||
messages: [
|
||||
{ id: 'user-1', type: 'user_text', content: 'Continue the work', timestamp: 1 },
|
||||
{ id: 'assistant-1', type: 'assistant_text', content: 'Done', timestamp: 2 },
|
||||
],
|
||||
}) } })
|
||||
|
||||
await act(async () => {
|
||||
render(<MessageList />)
|
||||
await Promise.resolve()
|
||||
})
|
||||
|
||||
expect(sessionsApi.getTurnCheckpoints).toHaveBeenCalledTimes(1)
|
||||
expect(screen.getByText('Done')).toBeTruthy()
|
||||
expect(screen.queryByText(/This transcript exceeds the full checkpoint preview budget/)).toBeNull()
|
||||
})
|
||||
|
||||
it('renders multiple historical turn change cards across three turns', async () => {
|
||||
vi.spyOn(sessionsApi, 'getTurnCheckpoints').mockResolvedValue({
|
||||
checkpoints: [
|
||||
|
||||
@@ -1437,6 +1437,15 @@ function getApiErrorMessage(error: unknown) {
|
||||
: String(error)
|
||||
}
|
||||
|
||||
function isCheckpointPreviewBudgetError(error: unknown): boolean {
|
||||
return error instanceof ApiError &&
|
||||
error.status === 413 &&
|
||||
typeof error.body === 'object' &&
|
||||
error.body !== null &&
|
||||
'error' in error.body &&
|
||||
error.body.error === 'HISTORY_CHECKPOINT_PREVIEW_LIMIT'
|
||||
}
|
||||
|
||||
function isSessionTurnCheckpoint(value: unknown): value is SessionTurnCheckpoint {
|
||||
if (!value || typeof value !== 'object') return false
|
||||
const checkpoint = value as Partial<SessionTurnCheckpoint>
|
||||
@@ -3078,7 +3087,8 @@ export function MessageList({
|
||||
.catch((error) => {
|
||||
if (cancelled) return
|
||||
setTurnChangeCards([])
|
||||
setTurnChangeLoadError(getApiErrorMessage(error))
|
||||
// This limit only disables optional turn previews; the chat transcript is still readable.
|
||||
setTurnChangeLoadError(isCheckpointPreviewBudgetError(error) ? null : getApiErrorMessage(error))
|
||||
})
|
||||
.finally(() => {
|
||||
if (!cancelled) {
|
||||
|
||||
Reference in New Issue
Block a user