Implements Phases 1-8 of the TFTSR implementation plan. Rust backend (Tauri 2.x, src-tauri/): - Multi-provider AI: OpenAI-compatible, Anthropic, Gemini, Mistral, Ollama - PII detection engine: 11 regex patterns with overlap resolution - SQLCipher AES-256 encrypted database with 10 versioned migrations - 28 Tauri IPC commands for triage, analysis, document, and system ops - Ollama: hardware probe, model recommendations, pull/delete with events - RCA and blameless post-mortem Markdown document generators - PDF export via printpdf - Audit log: SHA-256 hash of every external data send - Integration stubs for Confluence, ServiceNow, Azure DevOps (v0.2) Frontend (React 18 + TypeScript + Vite, src/): - 9 pages: full triage workflow NewIssue→LogUpload→Triage→Resolution→RCA→Postmortem→History+Settings - 7 components: ChatWindow, TriageProgress, PiiDiffViewer, DocEditor, HardwareReport, ModelSelector, UI primitives - 3 Zustand stores: session, settings (persisted), history - Type-safe tauriCommands.ts matching Rust backend types exactly - 8 IT domain system prompts (Linux, Windows, Network, K8s, DB, Virt, HW, Obs) DevOps: - .woodpecker/test.yml: rustfmt, clippy, cargo test, tsc, vitest on every push - .woodpecker/release.yml: linux/amd64 + linux/arm64 builds, Gogs release upload Verified: - cargo check: zero errors - tsc --noEmit: zero errors - vitest run: 13/13 unit tests passing Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
82 lines
2.5 KiB
JavaScript
82 lines
2.5 KiB
JavaScript
import { Action } from './Action';
|
|
import { intervalProvider } from './intervalProvider';
|
|
import { arrRemove } from '../util/arrRemove';
|
|
export class AsyncAction extends Action {
|
|
constructor(scheduler, work) {
|
|
super(scheduler, work);
|
|
this.scheduler = scheduler;
|
|
this.work = work;
|
|
this.pending = false;
|
|
}
|
|
schedule(state, delay = 0) {
|
|
var _a;
|
|
if (this.closed) {
|
|
return this;
|
|
}
|
|
this.state = state;
|
|
const id = this.id;
|
|
const scheduler = this.scheduler;
|
|
if (id != null) {
|
|
this.id = this.recycleAsyncId(scheduler, id, delay);
|
|
}
|
|
this.pending = true;
|
|
this.delay = delay;
|
|
this.id = (_a = this.id) !== null && _a !== void 0 ? _a : this.requestAsyncId(scheduler, this.id, delay);
|
|
return this;
|
|
}
|
|
requestAsyncId(scheduler, _id, delay = 0) {
|
|
return intervalProvider.setInterval(scheduler.flush.bind(scheduler, this), delay);
|
|
}
|
|
recycleAsyncId(_scheduler, id, delay = 0) {
|
|
if (delay != null && this.delay === delay && this.pending === false) {
|
|
return id;
|
|
}
|
|
if (id != null) {
|
|
intervalProvider.clearInterval(id);
|
|
}
|
|
return undefined;
|
|
}
|
|
execute(state, delay) {
|
|
if (this.closed) {
|
|
return new Error('executing a cancelled action');
|
|
}
|
|
this.pending = false;
|
|
const error = this._execute(state, delay);
|
|
if (error) {
|
|
return error;
|
|
}
|
|
else if (this.pending === false && this.id != null) {
|
|
this.id = this.recycleAsyncId(this.scheduler, this.id, null);
|
|
}
|
|
}
|
|
_execute(state, _delay) {
|
|
let errored = false;
|
|
let errorValue;
|
|
try {
|
|
this.work(state);
|
|
}
|
|
catch (e) {
|
|
errored = true;
|
|
errorValue = e ? e : new Error('Scheduled action threw falsy error');
|
|
}
|
|
if (errored) {
|
|
this.unsubscribe();
|
|
return errorValue;
|
|
}
|
|
}
|
|
unsubscribe() {
|
|
if (!this.closed) {
|
|
const { id, scheduler } = this;
|
|
const { actions } = scheduler;
|
|
this.work = this.state = this.scheduler = null;
|
|
this.pending = false;
|
|
arrRemove(actions, this);
|
|
if (id != null) {
|
|
this.id = this.recycleAsyncId(scheduler, id, null);
|
|
}
|
|
this.delay = null;
|
|
super.unsubscribe();
|
|
}
|
|
}
|
|
}
|
|
//# sourceMappingURL=AsyncAction.js.map
|