Implement resident app and bounded continuous diagnostics for 1.18.0; offline checks pass

这个提交包含在:
mac 于 2026-11-06 16:49:15 +08:00 提交
1 父节点 ecadafd8c3
当前提交 2b2a98d665
16 个文件已更改
+322 -98

没有与搜索条件相匹配的文件

+41 -34
查看文件
@@ -121,9 +121,8 @@ typedef NS_ENUM(NSInteger,DYRegistrationState) { DYChecking, DYRegistering, DYRe
@property(assign) NSProgressIndicator *progress;
@property(assign) DYSurface *registrationCard;
@property DYRegistrationState registrationState;
@property BOOL keepOpen, terminating;
@property NSInteger secondsRemaining;
@property(retain) NSTimer *exitTimer;
@property BOOL terminating;
@property(retain) NSStatusItem *statusItem;
@property(retain) NSMutableDictionary *diagnostics;
@property(retain) DYBetaUpdater *updater;
@property(assign) NSTextField *updateTitle, *updateDetail, *diagnosticDetail, *reportID;
@@ -137,18 +136,16 @@ typedef NS_ENUM(NSInteger,DYRegistrationState) { DYChecking, DYRegistering, DYRe
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)notification {
self.keepOpen = [NSProcessInfo.processInfo.arguments containsObject:@"--show-introduction"];
self.window.title = @"大鱼调色";
self.window.appearance = [NSAppearance appearanceNamed:NSAppearanceNameDarkAqua];
self.window.titlebarAppearsTransparent = YES; self.window.backgroundColor = DYColor(.105,.14,.20);
self.window.contentMinSize = NSMakeSize(760,620); [self.window setContentSize:NSMakeSize(920,850)]; [self.window center];
DYBetaStart();
[self buildInterface]; [self buildMenu];
[self buildInterface]; [self buildMenu]; [self buildStatusItem];
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(refreshDiagnostics:) name:DYBetaDiagnosticsChanged object:nil];
self.updater = [[[DYBetaUpdater alloc] init] autorelease];
__block AppDelegate *owner = self;
self.updater.changed = ^(NSDictionary *state) { [owner updateChanged:state]; };
self.updateProgressTimer = [NSTimer scheduledTimerWithTimeInterval:.2 target:self selector:@selector(refreshUpdateProgress:) userInfo:nil repeats:YES];
NSInteger expected=[NSUserDefaults.standardUserDefaults integerForKey:@"betaPendingUpdateBuild"];
if(expected>0 && [NSBundle.mainBundle.infoDictionary[@"CFBundleVersion"]integerValue]>=expected){
DYBetaEvent(@"update_installer",@{@"status":@"completed",@"count":@(expected)});
@@ -157,6 +154,14 @@ typedef NS_ENUM(NSInteger,DYRegistrationState) { DYChecking, DYRegistering, DYRe
[NSWorkspace.sharedWorkspace.notificationCenter addObserver:self selector:@selector(accessibilityChanged:)
name:NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification object:nil];
[self.window makeKeyAndOrderFront:nil]; [self refreshDiagnostics:nil]; [self checkRegistration:nil]; [self.updater check];
// Explicit QA opt-in on the signed, installed wrapper only. Never stalls the host.
if([NSProcessInfo.processInfo.arguments containsObject:@"--diagnostics-probe"])
[self performSelector:@selector(runDiagnosticsProbe) withObject:nil afterDelay:5];
}
- (void)runDiagnosticsProbe {
DYBetaEvent(@"diagnostic_summary",@{@"status":@"probe_begin"});
[NSThread sleepForTimeInterval:12];
DYBetaEvent(@"diagnostic_summary",@{@"status":@"probe_recovered"});
}
- (void)buildMenu {
NSMenu *menu = [[[NSMenu alloc] initWithTitle:@"大鱼调色"] autorelease];
@@ -203,12 +208,12 @@ typedef NS_ENUM(NSInteger,DYRegistrationState) { DYChecking, DYRegistering, DYRe
self.progress.style = NSProgressIndicatorStyleBar; self.progress.indeterminate = YES; self.progress.translatesAutoresizingMaskIntoConstraints = NO;
self.retryButton = DYButton(@"检查中…",DYBlue(),NO,self,@selector(checkRegistration:));
self.keepButton = DYButton(@"查看功能介绍",DYColor(.20,.46,.94),YES,self,@selector(keepIntroduction:));
self.exitDetail = DYLabel(@"注册成功后,将显示 3 秒退出倒计时。",15,NSFontWeightSemibold,DYGreen());
self.exitDetail = DYLabel(@"应用会保持运行,关闭窗口后继续后台诊断。",15,NSFontWeightSemibold,DYGreen());
[self.exitDetail.heightAnchor constraintGreaterThanOrEqualToConstant:38].active = YES;
NSStackView *registration = DYStack(@[DYHeading(@"puzzlepiece.extension",@"插件连接",DYBlue()),self.statusTitle,self.statusDetail,self.progress,
self.exitDetail,DYStack(@[self.retryButton,self.keepButton],NSUserInterfaceLayoutOrientationHorizontal,8)],NSUserInterfaceLayoutOrientationVertical,13);
self.registrationCard = DYCard(DYBlue(),registration);
self.confirmationButton = DYButton(@"已确认正常,退出",DYGreen(),NO,self,@selector(confirmHost:));
self.confirmationButton = DYButton(@"已确认,后台运行",DYGreen(),NO,self,@selector(confirmHost:));
self.confirmationButton.enabled = NO;
self.confirmationButton.toolTip = @"请先在 Final Cut Pro 中应用大鱼调色并确认效果正常,再点击此按钮。";
NSStackView *host = DYStack(@[DYHeading(@"play.rectangle",@"在 Final Cut Pro 中检查",DYGreen()),
@@ -237,7 +242,7 @@ typedef NS_ENUM(NSInteger,DYRegistrationState) { DYChecking, DYRegistering, DYRe
self.reportID=DYLabel(@"报告标识准备中…",10,NSFontWeightRegular,DYSecondary());self.reportID.selectable=YES;
self.sendSummaryButton=DYButton(@"发送诊断摘要",DYColor(.67,.59,1),NO,self,@selector(sendSummary:));
DYSurface *diagnosticCard=DYCard(DYColor(.67,.59,1),DYStack(@[DYHeading(@"waveform.path.ecg",@"一起完善大鱼调色",DYColor(.67,.59,1)),self.diagnosticToggle,
DYLabel(@"仅发送版本、系统环境、加载耗时和本插件错误摘要;不发送素材、预设或账号。可随时关闭,诊断保留 30 天。",12,NSFontWeightRegular,DYSecondary()),
DYLabel(@"后台自动发送版本、系统环境、阶段耗时、内存及本产品崩溃/卡顿调用栈摘要到 dayu.media;不发送素材、预设或账号。可随时关闭,保留 30 天。",12,NSFontWeightRegular,DYSecondary()),
self.reportID,self.diagnosticDetail,self.sendSummaryButton],NSUserInterfaceLayoutOrientationVertical,10));
NSStackView *beta=DYStack(@[updateCard,diagnosticCard],NSUserInterfaceLayoutOrientationHorizontal,14);
[updateCard.heightAnchor constraintEqualToAnchor:diagnosticCard.heightAnchor].active=YES;
@@ -326,7 +331,7 @@ typedef NS_ENUM(NSInteger,DYRegistrationState) { DYChecking, DYRegistering, DYRe
- (void)checkRegistration:(id)sender {
if (self.integrityRejected) return;
if (self.diagnostics && (self.registrationState == DYChecking || self.registrationState == DYRegistering)) return;
[self.exitTimer invalidate]; self.exitTimer = nil; self.registrationState = DYChecking;
self.registrationState = DYChecking;
self.retryButton.enabled = NO; self.retryButton.title = @"检查中…";
self.statusTitle.stringValue = @"正在检查插件…"; self.statusTitle.textColor = NSColor.whiteColor;
self.statusDetail.stringValue = @"正在检查本机插件登记,随后自动提交注册。";
@@ -400,17 +405,25 @@ typedef NS_ENUM(NSInteger,DYRegistrationState) { DYChecking, DYRegistering, DYRe
NSAccessibilityPostNotificationWithUserInfo(self.window,NSAccessibilityAnnouncementRequestedNotification,
@{NSAccessibilityAnnouncementKey:self.statusTitle.stringValue,NSAccessibilityPriorityKey:@(NSAccessibilityPriorityHigh)});
DYBetaEvent(@"registration",@{@"status":success?@"registered":@"failed"});
if(success)[self maybeStartCountdown];
if(success)[self refreshBackgroundState];
else self.exitDetail.stringValue=@"注册尚未完成,应用会保留此窗口以便重试。";
}
- (void)maybeStartCountdown {
if(self.terminating || self.registrationState!=DYReady)return;
if(self.keepOpen){self.exitDetail.stringValue=@"插件已就绪。关闭此窗口后,可继续在宿主中使用。";return;}
if(!self.updateCheckDone){self.exitDetail.stringValue=@"注册成功,正在检查公测更新…";return;}
if(self.exitTimer)return;
self.secondsRemaining=3;[self updateCountdown];
self.exitTimer=[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(exitTick:) userInfo:nil repeats:YES];
- (void)refreshBackgroundState {
if(self.registrationState==DYReady)self.exitDetail.stringValue=DYBetaEnabled()?@"后台诊断已开启。关闭窗口后继续运行,可从菜单栏重新打开或退出。":@"诊断已关闭。应用保持运行,可从菜单栏退出。";
}
- (void)buildStatusItem {
self.statusItem=[NSStatusBar.systemStatusBar statusItemWithLength:NSVariableStatusItemLength];
self.statusItem.button.image=[NSImage imageWithSystemSymbolName:@"slider.horizontal.3" accessibilityDescription:@"大鱼调色后台诊断"];
self.statusItem.button.toolTip=@"大鱼调色 · 后台运行";
NSMenu *menu=[[[NSMenu alloc]initWithTitle:@"大鱼调色"]autorelease];
NSMenuItem *show=[menu addItemWithTitle:@"打开大鱼调色" action:@selector(showMainWindow:) keyEquivalent:@""];show.target=self;
NSMenuItem *send=[menu addItemWithTitle:@"发送诊断摘要" action:@selector(sendSummary:) keyEquivalent:@""];send.target=self;
[menu addItem:NSMenuItem.separatorItem];
NSMenuItem *quit=[menu addItemWithTitle:@"退出大鱼调色" action:@selector(terminate:) keyEquivalent:@""];quit.target=NSApp;
self.statusItem.menu=menu;
}
- (void)showMainWindow:(id)sender { [self.window makeKeyAndOrderFront:nil];[NSApp activateIgnoringOtherApps:YES]; }
- (BOOL)applicationShouldHandleReopen:(NSApplication *)app hasVisibleWindows:(BOOL)visible { if(!visible)[self showMainWindow:nil];return YES; }
- (void)updateChanged:(NSDictionary *)state {
if(self.terminating)return;
NSString *phase=state[@"phase"];
@@ -425,10 +438,12 @@ typedef NS_ENUM(NSInteger,DYRegistrationState) { DYChecking, DYRegistering, DYRe
self.updateInstallButton.enabled=[@[@"available",@"ready",@"host_wait",@"installer"]containsObject:phase];
self.updateInstallButton.title=[phase isEqual:@"available"]?@"下载更新":@"安装更新";
self.updateCancelButton.hidden=![phase isEqual:@"downloading"];
[self.updateProgressTimer invalidate];self.updateProgressTimer=nil;
if([phase isEqual:@"downloading"])self.updateProgressTimer=[NSTimer scheduledTimerWithTimeInterval:.5 target:self selector:@selector(refreshUpdateProgress:) userInfo:nil repeats:YES];
self.updateProgress.indeterminate=[@[@"checking",@"validating"]containsObject:phase];
if(self.updateProgress.indeterminate)[self.updateProgress startAnimation:nil];else [self.updateProgress stopAnimation:nil];
self.updateProgress.doubleValue=[@[@"ready",@"host_wait",@"installer"]containsObject:phase]?1:0;
[self maybeStartCountdown];
[self refreshBackgroundState];
}
- (void)refreshUpdateProgress:(NSTimer *)timer {
if([self.updater.state[@"phase"]isEqual:@"downloading"])self.updateProgress.doubleValue=self.updater.downloadFraction;
@@ -441,7 +456,7 @@ typedef NS_ENUM(NSInteger,DYRegistrationState) { DYChecking, DYRegistering, DYRe
- (void)cancelUpdate:(id)sender { [self keepIntroduction:nil];[self.updater cancel]; }
- (void)refreshDiagnostics:(NSNotification *)note {
NSDictionary *state=DYBetaStatus();BOOL enabled=DYBetaEnabled();self.diagnosticToggle.state=enabled?NSControlStateValueOn:NSControlStateValueOff;
self.sendSummaryButton.enabled=enabled;
self.sendSummaryButton.enabled=enabled; [self refreshBackgroundState];
self.reportID.stringValue=[NSString stringWithFormat:@"报告标识:%@",state[@"installation_id"]?:@"准备中…"];
NSNumber *uploaded=state[@"last_upload"];
if(!enabled)self.diagnosticDetail.stringValue=@"诊断已关闭。不会继续上传,待发送摘要已清除。";
@@ -451,23 +466,14 @@ typedef NS_ENUM(NSInteger,DYRegistrationState) { DYChecking, DYRegistering, DYRe
}
- (void)toggleDiagnostics:(id)sender { [self keepIntroduction:nil];DYBetaSetEnabled(self.diagnosticToggle.state==NSControlStateValueOn);[self refreshDiagnostics:nil]; }
- (void)sendSummary:(id)sender { [self keepIntroduction:nil];DYBetaSendSummary();self.diagnosticDetail.stringValue=@"已加入后台发送队列,送达后会显示时间。"; }
- (void)updateCountdown { self.exitDetail.stringValue = [NSString stringWithFormat:@"%ld 秒后自动退出\n点击“查看功能介绍”可保留窗口",(long)self.secondsRemaining]; }
- (void)exitTick:(NSTimer *)timer {
if (--self.secondsRemaining <= 0) {
[timer invalidate]; self.exitTimer = nil; self.diagnostics[@"terminationReason"] = @"registration-succeeded"; [self writeDiagnostics]; [NSApp terminate:nil];
} else [self updateCountdown];
}
- (void)keepIntroduction:(id)sender {
self.keepOpen = YES; [self.exitTimer invalidate]; self.exitTimer = nil;
self.keepButton.title = @"正在浏览介绍"; self.keepButton.enabled = NO;
self.exitDetail.stringValue = @"已保留功能介绍窗口。插件可独立在宿主中使用。";
[self showMainWindow:sender]; [self refreshBackgroundState];
}
- (void)confirmHost:(id)sender {
if (self.registrationState != DYReady) return;
DYBetaEvent(@"host_confirmed",@{@"status":@"user_confirmed"});
self.diagnostics[@"hostVerification"] = @"user-confirmed";
self.diagnostics[@"terminationReason"] = @"user-confirmed-host";
[self writeDiagnostics]; [NSApp terminate:nil];
[self writeDiagnostics]; [self.window orderOut:nil];
}
- (void)writeDiagnostics {
NSURL *base = [NSFileManager.defaultManager URLsForDirectory:NSApplicationSupportDirectory inDomains:NSUserDomainMask].firstObject;
@@ -493,13 +499,14 @@ typedef NS_ENUM(NSInteger,DYRegistrationState) { DYChecking, DYRegistering, DYRe
}
- (void)closeWindow:(id)sender { [self.window performClose:sender]; }
- (void)accessibilityChanged:(NSNotification *)note { [self.window.contentView setNeedsDisplay:YES]; }
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)app { return YES; }
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)app { return NO; }
- (void)applicationWillTerminate:(NSNotification *)note {
self.terminating = YES; [self.exitTimer invalidate]; self.exitTimer = nil;
self.terminating = YES;
[NSStatusBar.systemStatusBar removeStatusItem:self.statusItem];
self.updater.changed=nil; [self.updater cancel];DYBetaStop();
[self.updateProgressTimer invalidate];self.updateProgressTimer=nil;
[NSNotificationCenter.defaultCenter removeObserver:self];
[NSWorkspace.sharedWorkspace.notificationCenter removeObserver:self];
}
- (void)dealloc { [_exitTimer invalidate]; [_exitTimer release]; [_diagnostics release]; [_updater release]; [_updateProgressTimer invalidate]; [_updateProgressTimer release]; [super dealloc]; }
- (void)dealloc { [_statusItem release]; [_diagnostics release]; [_updater release]; [_updateProgressTimer invalidate]; [_updateProgressTimer release]; [super dealloc]; }
@end
+2 -2
查看文件
@@ -17,9 +17,9 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.17.1</string>
<string>1.18.0</string>
<key>CFBundleVersion</key>
<string>103</string>
<string>104</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSHumanReadableCopyright</key>