Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ The next SDK version is **2.0.0**, on the same opencode **2.3.0** pin already re
### 🔧 Changes

- `StopAsync` and the `EnsureAsync` version-mismatch replacement treat a failed persistent-terminal handoff or clear as best-effort, whatever the exception type, as opencode's CLI does. Before: a failure other than an `OpenCodeServerException` ended `StopAsync` before it terminated the old service, and ended `EnsureAsync` at once. After: `StopAsync` terminates the old service; `EnsureAsync` keeps polling, and the last replacement failure becomes the inner exception of its timeout. The caller's cancellation still ends both. (#871)
- `StopAsync` with `Pty = Handoff` and the `EnsureAsync` replacement treat every persistent-terminal ticket-request, shutdown fallback or sidecar-publish failure as best-effort, as opencode's CLI does. Before: a failure other than an `OpenCodeException` could end the handoff preparation before terminal shutdown or empty-ticket publication completed. After: a failed ticket request still takes the terminal-shutdown fallback and publishes the empty handoff ticket; a failed shutdown no longer skips publication, and a failed publish no longer ends the preparation. The caller's cancellation still ends it. (#895)
- The packages' .NET dependency floors move from `10.0.13` to the `10.0.15` servicing release: on `net472` and `netstandard2.0`, `System.Text.Json`, `System.Threading.Channels`, `System.Collections.Immutable`, `Microsoft.Bcl.AsyncInterfaces`, `Microsoft.Bcl.Memory` and `Microsoft.Bcl.TimeProvider`; in `OpenCodeDotNet.Sdk.Extensions`, on every target, `Microsoft.Extensions.DependencyInjection.Abstractions` and `Microsoft.Extensions.Options.ConfigurationExtensions`. No security advisory of the .NET 10.0.14 or 10.0.15 release lists these packages.
- Event Types are copied and validated at the call and selected locally; physical attempts send no Types query. The whole bus is decoded once, so malformed unselected traffic reconnects every subscriber. Event and metadata instances are shared references, not deep-frozen graphs; consumers treat them as read-only. Queue bounds count events, not bytes, and subscriber count remains unbounded.
- Event subscriptions accept but no longer forward per-call Location. Every shared attempt sends only the client's ambient header snapshot; other operations retain their existing override behavior.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ public async Task PrepareAsync(
{
throw FailureClassification.CallerCancellation(failure, "The persistent-terminal handoff request was canceled.", cancellationToken);
}
catch (Exception failure) when (failure is OpenCodeException or OperationCanceledException or ArgumentException { ParamName: "endpoint" })
catch (Exception failure) when (failure is not OperationCanceledException || !cancellationToken.IsCancellationRequested)
{
// The SDK drops request failures where upstream warns (prepare in pty-handoff.ts); it has no warning channel here.
// Another caller may already have prepared and stopped this server; otherwise the
// daemon's terminals are shut down and the replacement starts without a handoff.
if (await IsFreshMatchAsync(sidecarPath, registration, cancellationToken).ConfigureAwait(false))
Expand Down Expand Up @@ -190,7 +191,7 @@ private PtyHandoffSidecar Parse(ServiceHandoffTicketResponse answer, ServiceRegi
/// </summary>
[SlopwatchSuppress(
"SW003",
"The pinned client's shutdown .catch(() => {}) is best-effort (prepare in pty-handoff.ts): endpoint refusal or a failed shutdown leads to a null sidecar and replacement without these terminals.")]
"The pinned client's prepare drops every shutdown fallback failure with .catch(() => {}) (prepare in pty-handoff.ts); the SDK drops it silently as upstream does. Only the caller's cancellation propagates, and a null sidecar is published next.")]
private async Task ShutdownAsync(ServiceRegistration registration, TimeSpan timeout, CancellationToken cancellationToken)
{
using var deadline = TimedCancellation.Create(timeout, time);
Expand All @@ -203,26 +204,26 @@ private async Task ShutdownAsync(ServiceRegistration registration, TimeSpan time
{
throw FailureClassification.CallerCancellation(failure, "The persistent-terminal shutdown fallback was canceled.", cancellationToken);
}
catch (Exception failure) when (failure is OpenCodeException or OperationCanceledException or ArgumentException { ParamName: "endpoint" })
catch (Exception failure) when (failure is not OperationCanceledException || !cancellationToken.IsCancellationRequested)
{
// Best-effort: the replacement starts without these terminals.
}
}

/// <summary>
/// <c>publish(...).catch(warn)</c>: a sidecar that cannot be written leaves the replacement
/// without a handoff; it never fails the preparation.
/// without a handoff; only the caller's cancellation fails the preparation.
/// </summary>
[SlopwatchSuppress(
"SW003",
"The pinned client only warns when publishing the handoff fails (prepare in pty-handoff.ts): the replacement then starts without the terminals, which is the best-effort contract.")]
"The pinned client's prepare catches every sidecar publish failure and only warns (prepare in pty-handoff.ts); the SDK has no warning channel here, so the failure is dropped. Only the caller's cancellation propagates, so the replacement starts without the terminals.")]
private async Task TryPublishAsync(string sidecarPath, PtyHandoffSidecar sidecar, CancellationToken cancellationToken)
{
try
{
await PublishAsync(sidecarPath, sidecar, cancellationToken).ConfigureAwait(false);
}
catch (OpenCodeServerException)
catch (Exception failure) when (failure is not OperationCanceledException || !cancellationToken.IsCancellationRequested)
{
// Best-effort: no sidecar means no handoff.
}
Expand Down
Loading
Loading