@@ -27,6 +27,7 @@ import type {
2727 SessionPendingInfo ,
2828 ShellInfo ,
2929 SkillInfo ,
30+ VcsInfo ,
3031 OpenCodeEvent ,
3132 WebSearchProvider ,
3233} from "@opencode-ai/client"
@@ -49,6 +50,7 @@ type ShellWithLocation = ShellInfo & { readonly location: LocationRef }
4950
5051type LocationData = {
5152 info ?: LocationGetOutput
53+ vcs ?: VcsInfo
5254 agent ?: AgentInfo [ ]
5355 command ?: CommandInfo [ ]
5456 integration ?: IntegrationInfo [ ]
@@ -339,6 +341,17 @@ export const { use: useData, provider: DataProvider } = createSimpleContext({
339341 result . location . skill . invalidate ( event . location )
340342 void result . location . skill . sync ( event . location )
341343 break
344+ case "vcs.branch.updated" :
345+ setStore ( "location" , locationKey ( event . location ?? defaultLocation ( ) ) , ( data ) => ( {
346+ ...data ,
347+ vcs : {
348+ branch : {
349+ ...data ?. vcs ?. branch ,
350+ current : event . data . branch ,
351+ } ,
352+ } ,
353+ } ) )
354+ break
342355 case "session.agent.selected" :
343356 if ( store . session . info [ event . data . sessionID ] )
344357 setStore ( "session" , "info" , event . data . sessionID , "agent" , event . data . agent )
@@ -1152,6 +1165,7 @@ export const { use: useData, provider: DataProvider } = createSimpleContext({
11521165 } )
11531166 const location = ref ?? defaultLocation ( )
11541167 await Promise . all ( [
1168+ result . location . vcs . sync ( location ) ,
11551169 result . location . agent . sync ( location ) ,
11561170 result . location . command . sync ( location ) ,
11571171 result . location . integration . sync ( location ) ,
@@ -1168,6 +1182,7 @@ export const { use: useData, provider: DataProvider } = createSimpleContext({
11681182 invalidate ( ref ?: LocationRef ) {
11691183 const location = ref ?? defaultLocation ( )
11701184 sync . invalidate ( `location:${ locationKey ( location ) } ` )
1185+ result . location . vcs . invalidate ( location )
11711186 result . location . agent . invalidate ( location )
11721187 result . location . command . invalidate ( location )
11731188 result . location . integration . invalidate ( location )
@@ -1180,6 +1195,22 @@ export const { use: useData, provider: DataProvider } = createSimpleContext({
11801195 result . shell . invalidate ( location )
11811196 result . session . form . invalidate ( "global" , location )
11821197 } ,
1198+ vcs : {
1199+ info ( location ?: LocationRef ) {
1200+ return store . location [ locationKey ( location ?? defaultLocation ( ) ) ] ?. vcs
1201+ } ,
1202+ sync ( ref ?: LocationRef ) {
1203+ const location = ref ?? defaultLocation ( )
1204+ return sync . run ( `location.vcs:${ locationKey ( location ) } ` , async ( ) => {
1205+ const response = await client . api . vcs . get ( { location : locationQuery ( location ) } )
1206+ const key = locationKey ( response . location )
1207+ setStore ( "location" , key , { ...store . location [ key ] , vcs : response . data } )
1208+ } )
1209+ } ,
1210+ invalidate ( ref ?: LocationRef ) {
1211+ sync . invalidate ( `location.vcs:${ locationKey ( ref ?? defaultLocation ( ) ) } ` )
1212+ } ,
1213+ } ,
11831214 agent : {
11841215 list ( location ?: LocationRef ) {
11851216 return store . location [ locationKey ( location ?? defaultLocation ( ) ) ] ?. agent
@@ -1377,6 +1408,7 @@ export const { use: useData, provider: DataProvider } = createSimpleContext({
13771408 setStore ( "location" , key , { ...store . location [ key ] , info : location } )
13781409 } )
13791410 . catch ( ( error ) => console . error ( "Failed to preload location" , error ) )
1411+ void result . location . vcs . sync ( ) . catch ( ( error ) => console . error ( "Failed to preload VCS info" , error ) )
13801412 void result . project . sync ( ) . catch ( ( error ) => console . error ( "Failed to preload projects" , error ) )
13811413 return
13821414 }
0 commit comments