1- import { UsageLimitRecoveryCard } from "./chat/UsageLimitRecoveryCard " ;
1+ import { usageLimitRecoveryBannerItem } from "./chat/UsageLimitRecoveryBanner " ;
22import {
33 resolveBackgroundDraftWorkspaceOptions ,
44 resolveDraftHeroState ,
@@ -6966,7 +6966,27 @@ export default function ChatView(props: ChatViewProps) {
69666966 } ) ,
69676967 [ feedbackSubmissions , routeThreadKey ] ,
69686968 ) ;
6969+ const limitRecoveryBanner =
6970+ serverRuntime ?. status === "failed" &&
6971+ serverRuntime . lastErrorClass === "usage_limit" &&
6972+ activeThreadShell ?. latestRun
6973+ ? usageLimitRecoveryBannerItem ( {
6974+ runId : activeThreadShell . latestRun . runId ,
6975+ resetAt : serverRuntime . usageLimitResetAt ?? null ,
6976+ stoppedAt : activeThreadShell . latestRun . completedAt ?? activeThreadShell . updatedAt ,
6977+ recovery : activeThreadShell . limitRecovery ?? null ,
6978+ explanation : serverRuntime . lastError ,
6979+ onChange : async ( limitRecovery ) => {
6980+ const result = await updateThreadMetadata ( {
6981+ environmentId,
6982+ input : { threadId : activeThreadShell . id , limitRecovery } ,
6983+ } ) ;
6984+ if ( result . _tag === "Failure" ) throw squashAtomCommandFailure ( result ) ;
6985+ } ,
6986+ } )
6987+ : null ;
69696988 const composerBannerItems = useMemo < ComposerBannerStackItem [ ] > ( ( ) => {
6989+ const limitRecoveryItems = limitRecoveryBanner === null ? [ ] : [ limitRecoveryBanner ] ;
69706990 const backgroundWorkItems = backgroundWorkBannerItem === null ? [ ] : [ backgroundWorkBannerItem ] ;
69716991 const resumeCompactionItems =
69726992 resumeCompactionBannerItem === null ? [ ] : [ resumeCompactionBannerItem ] ;
@@ -6978,6 +6998,7 @@ export default function ChatView(props: ChatViewProps) {
69786998 if ( ! localCheckoutBranchMismatch || ! showBranchMismatchBanner || ! activeBranchMismatchKey ) {
69796999 return [
69807000 ...feedbackBannerItems ,
7001+ ...limitRecoveryItems ,
69817002 ...usageLimitsItems ,
69827003 ...projectCloneItems ,
69837004 ...systemComposerBannerItems ,
@@ -6989,6 +7010,7 @@ export default function ChatView(props: ChatViewProps) {
69897010 }
69907011 return [
69917012 ...feedbackBannerItems ,
7013+ ...limitRecoveryItems ,
69927014 ...usageLimitsItems ,
69937015 ...projectCloneItems ,
69947016 ...systemComposerBannerItems ,
@@ -7038,6 +7060,7 @@ export default function ChatView(props: ChatViewProps) {
70387060 } , [
70397061 activeBranchMismatchKey ,
70407062 feedbackBannerItems ,
7063+ limitRecoveryBanner ,
70417064 handleRestoreThreadBranch ,
70427065 isRestoringThreadBranch ,
70437066 backgroundWorkBannerItem ,
@@ -10357,7 +10380,11 @@ export default function ChatView(props: ChatViewProps) {
1035710380 onOpenProviderSetup = { openProviderSetup }
1035810381 />
1035910382 < ThreadErrorBanner
10360- error = { visibleThreadError }
10383+ error = {
10384+ limitRecoveryBanner !== null && visibleThreadError === serverRuntime ?. lastError
10385+ ? null
10386+ : visibleThreadError
10387+ }
1036110388 errorClass = {
1036210389 localServerError === null && visibleThreadError === serverRuntime ?. lastError
1036310390 ? ( serverRuntime ?. lastErrorClass ?? null )
@@ -10505,26 +10532,6 @@ export default function ChatView(props: ChatViewProps) {
1050510532 data-chat-composer-stack = "true"
1050610533 className = "group/composer-stack pointer-events-auto relative z-10 mx-auto w-full max-w-3xl"
1050710534 >
10508- { serverRuntime ?. status === "failed" &&
10509- serverRuntime . lastErrorClass === "usage_limit" &&
10510- activeThreadShell ?. latestRun ? (
10511- < UsageLimitRecoveryCard
10512- key = { activeThreadShell . latestRun . runId }
10513- stoppedAt = {
10514- activeThreadShell . latestRun . completedAt ?? activeThreadShell . updatedAt
10515- }
10516- runId = { activeThreadShell . latestRun . runId }
10517- resetAt = { serverRuntime . usageLimitResetAt ?? null }
10518- recovery = { activeThreadShell . limitRecovery ?? null }
10519- onChange = { async ( limitRecovery ) => {
10520- const result = await updateThreadMetadata ( {
10521- environmentId,
10522- input : { threadId : activeThread . id , limitRecovery } ,
10523- } ) ;
10524- if ( result . _tag === "Failure" ) throw squashAtomCommandFailure ( result ) ;
10525- } }
10526- />
10527- ) : null }
1052810535 { isDraftHeroState ? (
1052910536 < div className = "absolute inset-x-0 bottom-full" >
1053010537 < div
0 commit comments