mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-03 22:51:36 -05:00
A server Auto Nest showed only "Nesting on the nest server" for however long the job took, and Stop could take a whole 20-second heartbeat to reach the worker. Now the desktop shows the same Best plan so far strip a local run does, and a job that ends while OpenNest is in the background says so. - Worker: RecordingNestingEngine taps each solve's progress. NestJobReporter stores only the latest stage and plan, at most once every two seconds, so a chatty engine cannot flood SQLite. Each round also reads the cancel flag, so Stop reaches the worker within one interval (about 2 s in the Docker smoke test). - Server: schema v16 adds per-job revision, progress, plan and planRevision columns, which the upgrade adds only where missing. PUT .../progress and .../plan renew the lease like a heartbeat. GET .../events is Server-Sent Events, woken by an in-process change signal: plan and job events with revision ids, keep-alives, Last-Event-ID resume, and the final state always sent before the stream ends. GET .../plan serves the polling fallback. Progress goes over HTTP because the worker never opens the database (another host, NFS). - Desktop: NestJobWatch follows the stream. When the stream drops it polls once and reconnects, and it polls throughout when the server has no stream. RemoteNestPlanPreview draws worker plans from the client's own request, including cutout-trial frame proxies. ServerNestNotice shows a tray balloon (a toast on Windows 10/11) when the job ends while OpenNest is not in front. A real toast would need an AUMID shortcut that Velopack does not promise. Clicking the balloon brings the review forward; nothing is kept without Keep. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
56 lines
2.0 KiB
C#
56 lines
2.0 KiB
C#
using System;
|
|
using System.Threading;
|
|
using OpenNest.Engine.Jobs.Cutouts;
|
|
|
|
namespace OpenNest.Engine.Jobs.Remote;
|
|
|
|
/// <summary>
|
|
/// Passes every solve to another engine and records what it was asked and what it returned
|
|
/// in <see cref="Transcript"/>. A solve that throws records nothing. The nest server's worker
|
|
/// wraps the selected engine in one, so the client can replay the run (<see cref="RemoteNestSubmission"/>).
|
|
/// </summary>
|
|
public sealed class RecordingNestingEngine : INestingEngine
|
|
{
|
|
private readonly INestingEngine inner;
|
|
|
|
public RecordingNestingEngine(INestingEngine inner)
|
|
{
|
|
this.inner = inner ?? throw new ArgumentNullException(nameof(inner));
|
|
}
|
|
|
|
public NestSolveTranscript Transcript { get; } = new();
|
|
|
|
/// <summary>
|
|
/// Also receives each solve's own progress, before the pipeline turns plans into sheets:
|
|
/// the worker's live reports. A bundled cutout trial's commits count proxies, so it passes
|
|
/// only candidates and plans, as the pipeline's own progress does.
|
|
/// </summary>
|
|
public IProgress<NestJobProgress> Progress { get; init; }
|
|
|
|
public NestJobResult Solve(NestJob job, IProgress<NestJobProgress> progress = null, CancellationToken token = default)
|
|
{
|
|
if (Progress != null)
|
|
{
|
|
var tap = CutoutPipelinePrepass.HasProxies(job) ? new NestPipeline.PreviewProgress(Progress) : Progress;
|
|
progress = progress == null ? tap : new BothProgress(progress, tap);
|
|
}
|
|
var result = inner.Solve(job, progress, token);
|
|
if (result != null)
|
|
{
|
|
lock (Transcript)
|
|
Transcript.Add(job, result);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
private sealed class BothProgress(IProgress<NestJobProgress> first, IProgress<NestJobProgress> second)
|
|
: IProgress<NestJobProgress>
|
|
{
|
|
public void Report(NestJobProgress value)
|
|
{
|
|
first.Report(value);
|
|
second.Report(value);
|
|
}
|
|
}
|
|
}
|