Skip to content

Commit 0a46075

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents 2413424 + ff04011 commit 0a46075

File tree

2 files changed

+40
-11
lines changed

2 files changed

+40
-11
lines changed

src/OneWare.Copilot/Services/CopilotChatService.cs

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,21 @@ private async Task<bool> AuthenticateAsync(Control? owner)
105105

106106
try
107107
{
108-
var currentAuthStatus = await _client.GetAuthStatusAsync();
109-
if (currentAuthStatus.IsAuthenticated) return true;
108+
bool isAuthenticated;
109+
try
110+
{
111+
var currentAuthStatus = await _client.GetAuthStatusAsync();
112+
isAuthenticated = currentAuthStatus.IsAuthenticated;
113+
}
114+
catch (IOException ex) when (ex.InnerException?.GetType().Name == "RemoteInvocationException" &&
115+
ex.Message.Contains("401"))
116+
{
117+
// Treat 401 authentication errors as unauthenticated
118+
ContainerLocator.Container.Resolve<ILogger>().LogWarning(ex, "Authentication check failed with 401, treating as unauthenticated.");
119+
isAuthenticated = false;
120+
}
121+
122+
if (isAuthenticated) return true;
110123

111124
var cliPath = settingsService.GetSettingValue<string>(CopilotModule.CopilotCliSettingKey);
112125

@@ -189,9 +202,21 @@ public async Task<bool> InitializeAsync()
189202
CliPath = cliPath
190203
});
191204

192-
var authStatus = await _client.GetAuthStatusAsync();
205+
bool isAuthenticated;
206+
try
207+
{
208+
var authStatus = await _client.GetAuthStatusAsync();
209+
isAuthenticated = authStatus.IsAuthenticated;
210+
}
211+
catch (IOException ex) when (ex.InnerException?.GetType().Name == "RemoteInvocationException" &&
212+
ex.Message.Contains("401"))
213+
{
214+
// Treat 401 authentication errors as unauthenticated
215+
ContainerLocator.Container.Resolve<ILogger>().LogWarning(ex, "Authentication check failed with 401, treating as unauthenticated.");
216+
isAuthenticated = false;
217+
}
193218

194-
if (!authStatus.IsAuthenticated)
219+
if (!isAuthenticated)
195220
{
196221
StatusChanged?.Invoke(this, new StatusEvent(false, "Not Authenticated"));
197222
EventReceived?.Invoke(this, new ChatButtonEvent(
@@ -252,12 +277,7 @@ private async Task InitializeSessionAsync()
252277

253278
var sessionId = _requestedSessionId;
254279
_requestedSessionId = null;
255-
256-
if (string.IsNullOrWhiteSpace(sessionId) && !_forceNewSession)
257-
{
258-
sessionId = await _client.GetLastSessionIdAsync();
259-
}
260-
280+
261281
if (string.IsNullOrWhiteSpace(sessionId))
262282
{
263283
var tools = toolProvider.GetTools();

src/OneWare.PackageManager/Installers/PluginPackageInstaller.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,19 @@ public override async Task<CompatibilityReport> CheckCompatibilityAsync(Package
3232
{
3333
var depsUrl = version.CompatibilityUrl ?? $"{package.SourceUrl}/{version.Version}/compatibility.txt";
3434
var deps = await _httpService.DownloadTextAsync(depsUrl);
35+
36+
// If download fails (network error), skip compatibility check and assume compatible
37+
// This allows offline usage without showing errors
38+
if (deps == null)
39+
{
40+
return new CompatibilityReport(true);
41+
}
42+
3543
return PluginCompatibilityChecker.CheckCompatibility(deps);
3644
}
3745

38-
return PluginCompatibilityChecker.CheckCompatibility(null);
46+
// No compatibility URL means no specific requirements - assume compatible
47+
return new CompatibilityReport(true);
3948
}
4049

4150
public override Task<PackageInstallerResult> InstallAsync(PackageInstallContext context,

0 commit comments

Comments
 (0)