Documentation Index
Fetch the complete documentation index at: https://docs.skyvexsoftware.com/llms.txt
Use this file to discover all available pages before exploring further.
useFlightManager provides direct control over the flight lifecycle: starting, pausing, resuming, ending, and commenting on flights. It hydrates state from GET /api/flight-manager/state and subscribes to flight:manager Socket.io events for real-time updates.
For most plugins, useTrackingSession is the better starting point — it wraps useFlightManager with derived state (isTracking, isPaused, elapsedTime, phase) and recovery handling. Use useFlightManager when you need lower-level control or want to avoid the extra derived state computation.
Import
import { useFlightManager } from "@skyvexsoftware/stratos-sdk";
Signature
function useFlightManager(): UseFlightManagerReturn
type UseFlightManagerReturn = {
currentFlight: CurrentFlight | null;
startFlight: (plan: FlightPlan) => Promise<StartFlightResult>;
pauseFlight: () => Promise<boolean>;
resumeFlight: () => Promise<boolean>;
endFlight: (
status?: "completed" | "diverted" | "crashed" | "cancelled"
) => Promise<boolean>;
addComment: (message: string) => Promise<boolean>;
runPreflightChecks: (plan: FlightPlan) => Promise<PreflightCheckResult | null>;
};
Return value
| Field | Type | Description |
|---|
currentFlight | CurrentFlight | null | Active flight state, or null when no flight is in progress |
startFlight | (plan: FlightPlan) => Promise<StartFlightResult> | Begin a new flight with the given flight plan |
pauseFlight | () => Promise<boolean> | Pause the active flight |
resumeFlight | () => Promise<boolean> | Resume a paused flight |
endFlight | (status?) => Promise<boolean> | End the active flight with an optional terminal status |
addComment | (message: string) => Promise<boolean> | Attach a pilot comment to the active flight |
runPreflightChecks | (plan: FlightPlan) => Promise<PreflightCheckResult | null> | Validate a flight plan before starting |
Types
FlightPlan
type FlightPlan = {
source: "va" | "simbrief" | "manual";
sourceId?: string;
callsign: string;
flightNumber?: string;
airlineCode?: string;
departureIcao: string;
arrivalIcao: string;
route: string[];
aircraftIcao: string;
aircraftName?: string;
cruiseAltitude?: number;
plannedDistance?: number;
estimatedFlightTime?: number;
departureCoords?: { lat: number; lon: number };
arrivalCoords?: { lat: number; lon: number };
};
StartFlightResult
type StartFlightResult = {
success: boolean;
flight?: CurrentFlight;
preflightResult?: PreflightCheckResult;
/** VA-issued confirmation message pilot must acknowledge */
vaConfirmation?: string;
/** Sim variables sent to VA for display in confirmation dialog */
simVariables?: Record<string, string>;
error?: string;
};
PreflightCheckResult
type PreflightCheckResult = {
passed: boolean;
checks: PreflightCheck[];
};
type PreflightCheck = {
name: string;
passed: boolean;
message: string;
severity: "error" | "warning";
};
CurrentFlight
type CurrentFlight = {
flightPlan: FlightPlan;
status: "preflight" | "starting" | "active" | "paused" | "completing" | "completed" | "failed" | "cancelled";
vaTrackingId: string | null;
stratosFlightId: string | null;
startedAt: number | null;
pausedAt: number | null;
totalPausedMs: number;
elapsedMs: number;
timeCaptureMode: "block" | "air";
timeCaptureStartAt: number | null;
timeCaptureEndAt: number | null;
currentPhase: FlightPhase;
latitude: number;
longitude: number;
altitude: number;
groundSpeed: number;
heading: number;
startingFuel: number;
currentFuel: number;
lastUpdateSentAt: number | null;
updatesSent: number;
updateIntervalMs: number;
comments: FlightComment[];
lastError: string | null;
};
Usage
Start a flight
import { useFlightManager } from "@skyvexsoftware/stratos-sdk";
export function StartFlightButton() {
const { startFlight, currentFlight } = useFlightManager();
const handleStart = async () => {
const result = await startFlight({
source: "manual",
callsign: "SWR123",
departureIcao: "YSSY",
arrivalIcao: "YMML",
route: ["SY", "ML"],
aircraftIcao: "B738",
});
if (!result.success) {
console.error("Failed to start flight:", result.error);
}
};
return (
<button onClick={handleStart} disabled={currentFlight !== null}>
Start Flight
</button>
);
}
Run preflight checks first
const { runPreflightChecks, startFlight } = useFlightManager();
const plan: FlightPlan = { /* ... */ };
const checks = await runPreflightChecks(plan);
if (checks && !checks.passed) {
const errors = checks.checks.filter((c) => c.severity === "error");
console.error("Preflight failed:", errors);
return;
}
await startFlight(plan);
End a flight
const { endFlight } = useFlightManager();
// End with a specific status
await endFlight("completed");
// Without a status — defaults to "completed" on the server
await endFlight();
Notes
- All action methods (
startFlight, pauseFlight, etc.) call REST endpoints on the local shell server. They return a boolean or result object indicating success.
- State updates arrive via
flight:manager Socket.io events — the currentFlight value updates reactively without polling.
runPreflightChecks returns null if the server is unreachable.