@@ -12,6 +12,10 @@ struct CopilotView: View {
1212 @State var version : String ?
1313 @State var isRunningAction : Bool = false
1414 @State var isUserCodeCopiedAlertPresented = false
15+ @State var xpcServiceVersion : String ?
16+ var shouldRestartXPCService : Bool {
17+ xpcServiceVersion != ( Bundle . main. infoDictionary ? [ " CFBundleShortVersionString " ] as? String )
18+ }
1519
1620 var body : some View {
1721 Section {
@@ -20,7 +24,8 @@ struct CopilotView: View {
2024 Text ( " Copilot " )
2125 . font ( . title)
2226 . padding ( . bottom, 12 )
23- Text ( " Version: \( version ?? " Loading.. " ) " )
27+ Text ( " XPCService Version: \( xpcServiceVersion ?? " Loading.. " ) " )
28+ Text ( " Copilot Version: \( version ?? " Loading.. " ) " )
2429 Text ( " Status: \( copilotStatus? . description ?? " Loading.. " ) " )
2530 HStack ( alignment: . center) {
2631 Button ( " Refresh " ) { checkStatus ( ) }
@@ -74,9 +79,12 @@ struct CopilotView: View {
7479 defer { isRunningAction = false }
7580 do {
7681 let service = try getService ( )
82+ xpcServiceVersion = try await service. getXPCServiceVersion ( ) . version
7783 copilotStatus = try await service. checkStatus ( )
7884 version = try await service. getVersion ( )
79- message = nil
85+ message = shouldRestartXPCService
86+ ? " Please restart XPC Service to update it to the latest version. "
87+ : nil
8088 isRunningAction = false
8189 } catch {
8290 message = error. localizedDescription
@@ -159,9 +167,9 @@ struct ActivityIndicatorView: NSViewRepresentable {
159167struct CopilotView_Previews : PreviewProvider {
160168 static var previews : some View {
161169 VStack ( alignment: . leading, spacing: 8 ) {
162- CopilotView ( copilotStatus: . notSignedIn, version: " 1.0.0 " )
170+ CopilotView ( copilotStatus: . notSignedIn, version: " 1.0.0 " , xpcServiceVersion : " 0.0.0 " )
163171
164- CopilotView ( copilotStatus: . alreadySignedIn, message: " Error " )
172+ CopilotView ( copilotStatus: . alreadySignedIn, message: " Error " , xpcServiceVersion : Bundle . main . infoDictionary ? [ " CFBundleShortVersionString " ] as? String ?? " " )
165173
166174 CopilotView ( copilotStatus: . alreadySignedIn, isRunningAction: true )
167175 }
0 commit comments