@@ -37,7 +37,7 @@ import type { InvokeChangesetOperationParams, InvokeChangesetOperationResult } f
3737import { AhpErrorCodes , AHP_SESSION_NOT_FOUND , ContentEncoding , JSON_RPC_INTERNAL_ERROR , ProtocolError , ResourceChangeType , ResourceType , ResourceWriteMode , type CreateResourceWatchParams , type CreateResourceWatchResult , type DirectoryEntry , type ResourceCopyParams , type ResourceCopyResult , type ResourceDeleteParams , type ResourceDeleteResult , type ResourceListResult , type ResourceMkdirParams , type ResourceMkdirResult , type ResourceMoveParams , type ResourceMoveResult , type ResourceReadResult , type ResourceResolveParams , type ResourceResolveResult , type ResourceWatchState , type ResourceWriteParams , type ResourceWriteResult , type IStateSnapshot } from '../common/state/sessionProtocol.js' ;
3838import { ChangesSummary , ChatInteractivity , ChatOriginKind , MessageAttachmentKind , type Annotation , type AnnotationEntry , type AnnotationsState , type ChatOrigin , type Customization , type Message , type MessageAttachment , type MessageResourceAttachment } from '../common/state/protocol/state.js' ;
3939import type { ChatPendingMessageSetAction , ChatTurnStartedAction , SessionConfigChangedAction } from '../common/state/protocol/actions.js' ;
40- import { ISessionGitHubState , ISessionGitState , MessageKind , ResponsePartKind , SESSION_META_GITHUB_KEY , SESSION_META_GIT_KEY , SESSION_META_MULTI_ROOT_KEY , SESSION_META_SOURCE_CONTROL_KEY , AH_META_ORCHESTRATION_DB_KEY , readSessionSpawnDepth , parseSessionOrchestration , withSessionSpawnDepth , withSessionOrchestration , SessionLifecycle , SessionStatus , ToolCallStatus , ToolResultContentType , AH_META_WORKSPACELESS_DB_KEY , AH_META_IS_ARCHIVED_DB_KEY , AH_META_IS_DONE_DB_KEY , AH_META_IS_READ_DB_KEY , buildChatUri , buildDefaultChatUri , buildResourceWatchChannelUri , buildSubagentChatUri , buildSubagentSessionUriPrefix , hostBuildInfoFromProduct , isAhpChatChannel , isDefaultChatUri , isSubagentChatUri , isSubagentSession , parseChatUri , parseDefaultChatUri , parseRequiredSessionUriFromChatUri , parseResourceWatchChannelUri , parseSessionMultiRootMetadata , parseSubagentSessionUri , readSessionExternal , readSessionGitHubState , readSessionGitState , readSessionMultiRootMetadata , readSessionSourceControlState , readSessionWorkspaceless , withSessionExternal , withSessionGitHubState , withSessionGitState , withSessionMultiRootMetadata , withSessionSourceControlState , withSessionStatusFlag , withSessionWorkspaceless , withSessionFolderPickerDecision , readSessionFolderPickerDecision , parseSessionFolderPickerDecision , SESSION_META_FOLDER_PICKER_KEY , readSessionEhcliAdoptable , type ISessionSourceControlState , type SessionConfigState , type SessionSummary , type ToolResultSubagentContent , type Turn , type UsageInfo , chatStorageUri , hasReportedUsage } from '../common/state/sessionState.js' ;
40+ import { ISessionGitHubState , ISessionGitState , MessageKind , ResponsePartKind , SESSION_META_GITHUB_KEY , SESSION_META_GIT_KEY , SESSION_META_MULTI_ROOT_KEY , SESSION_META_SOURCE_CONTROL_KEY , AH_META_ORCHESTRATION_DB_KEY , readSessionSpawnDepth , parseSessionOrchestration , withSessionSpawnDepth , withSessionOrchestration , SessionLifecycle , SessionStatus , ToolCallStatus , ToolResultContentType , AH_META_WORKSPACELESS_DB_KEY , AH_META_IS_ARCHIVED_DB_KEY , AH_META_IS_DONE_DB_KEY , AH_META_IS_READ_DB_KEY , buildChatUri , buildDefaultChatUri , buildResourceWatchChannelUri , buildSubagentChatUri , buildSubagentSessionUriPrefix , hostBuildInfoFromProduct , isAhpChatChannel , isDefaultChatUri , isSubagentChatUri , isSubagentSession , needsSessionGitStateRefresh , parseChatUri , parseDefaultChatUri , parseRequiredSessionUriFromChatUri , parseResourceWatchChannelUri , parseSessionMultiRootMetadata , parseSubagentSessionUri , readSessionExternal , readSessionGitHubState , readSessionGitState , readSessionMultiRootMetadata , readSessionSourceControlState , readSessionWorkspaceless , withSessionExternal , withSessionGitHubState , withSessionGitState , withSessionMultiRootMetadata , withSessionSourceControlState , withSessionStatusFlag , withSessionWorkspaceless , withSessionFolderPickerDecision , readSessionFolderPickerDecision , parseSessionFolderPickerDecision , SESSION_META_FOLDER_PICKER_KEY , readSessionEhcliAdoptable , type ISessionSourceControlState , type SessionConfigState , type SessionSummary , type ToolResultSubagentContent , type Turn , type UsageInfo , chatStorageUri , hasReportedUsage } from '../common/state/sessionState.js' ;
4141import { readToolCallMeta } from '../common/meta/agentToolCallMeta.js' ;
4242import { readEphemeralSessionMeta , withEphemeralSessionMeta } from '../common/meta/agentEphemeralSessionMeta.js' ;
4343import { readChatSurfaceMeta , withChatSurfaceMeta } from '../common/meta/agentChatSurfaceMeta.js' ;
@@ -3842,11 +3842,12 @@ export class AgentService extends Disposable implements IAgentService {
38423842 // restore path that normally calls `_attachGitState` is skipped — so
38433843 // trigger it lazily here for the first subscriber. `_attachGitState`
38443844 // is async and updates `_meta.git` once ready, which clients see via
3845- // the normal state-update stream. A state without a branch is treated
3846- // as missing too: a failed git probe can persist one, and it would
3847- // otherwise mask the very repair this lazy refresh exists to perform.
3845+ // the normal state-update stream. State that does not describe a
3846+ // usable checkout counts as missing too: a failed probe can persist
3847+ // a branch-less remnant, and it would otherwise mask the very
3848+ // repair this lazy refresh exists to perform.
38483849 const sessionState = this . _stateManager . getSessionState ( resourceStr ) ;
3849- if ( ! isAhpChatChannel ( resourceStr ) && sessionState && readSessionGitState ( sessionState . _meta ) ?. branchName === undefined ) {
3850+ if ( ! isAhpChatChannel ( resourceStr ) && sessionState && needsSessionGitStateRefresh ( readSessionGitState ( sessionState . _meta ) ) ) {
38503851 const workingDirectory = sessionState . workingDirectories ?. [ 0 ]
38513852 ? URI . parse ( sessionState . workingDirectories [ 0 ] )
38523853 : undefined ;
0 commit comments