Skip to content

Commit f18a62d

Browse files
fix: implement autonomous simulation mode for deployed environments
1 parent c33bacd commit f18a62d

1 file changed

Lines changed: 45 additions & 3 deletions

File tree

src/pages/Plan.tsx

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,43 @@ export default function Plan() {
284284
content: m.content,
285285
}));
286286

287+
// ── SIMULATED ORCHESTRATION FALLBACK ──
288+
const generateMockResponse = (msg: string) => {
289+
const isFlight = /fly|flight|travel|nairobi|london|dubai|paris/i.test(msg);
290+
const isHotel = /hotel|stay|accommodation|tokyo/i.test(msg);
291+
292+
let manifest: any = null;
293+
if (isFlight) {
294+
manifest = {
295+
type: "flight_manifest",
296+
origin: "NBO",
297+
destination: "LHR",
298+
options: [
299+
{ tier: "Prime", id: "SIM-001", airline: "British Airways", price: 420, currency: "USD", duration: "8h 45m", origin: "NBO", destination: "LHR" },
300+
{ tier: "Economic", id: "SIM-002", airline: "Kenya Airways", price: 310, currency: "USD", duration: "12h 10m", origin: "NBO", destination: "LHR" },
301+
{ tier: "Elite", id: "SIM-003", airline: "Emirates", price: 850, currency: "USD", duration: "7h 15m", origin: "NBO", destination: "LHR" }
302+
]
303+
};
304+
} else if (isHotel) {
305+
manifest = {
306+
type: "hotel_briefing",
307+
city: "Tokyo",
308+
options: [
309+
{ tier: "Prime", name: "Tokyo Grand Palace", price: 250, rating: 5, amenities: ["Spa", "Pool"] },
310+
{ tier: "Economic", name: "Shibuya Inn", price: 110, rating: 4, amenities: ["WiFi", "Breakfast"] },
311+
{ tier: "Elite", name: "The Ritz Tokyo", price: 650, rating: 5, amenities: ["Butler", "Sky Bar"] }
312+
]
313+
};
314+
}
315+
316+
return {
317+
response: isFlight || isHotel
318+
? "I have successfully polled the global grids in simulated mode. Please review the curated options below to secure your Flow."
319+
: "I am currently operating in simulated mode as the live ExFlo node is unreachable. I can still help you explore the orchestration flow—try asking for a flight from Nairobi to London!",
320+
manifest
321+
};
322+
};
323+
287324
try {
288325
const res = await fetch(`${BACKEND_URL}/chat`, {
289326
method: "POST",
@@ -307,17 +344,22 @@ export default function Plan() {
307344
},
308345
]);
309346
} catch (err) {
310-
console.error("Ashley backend unreachable:", err);
347+
console.warn("Ashley backend unreachable, switching to simulation:", err);
311348
if (statusInterval.current) clearInterval(statusInterval.current);
349+
350+
// Artificial delay for realism
351+
await new Promise(r => setTimeout(r, 1000));
352+
353+
const mock = generateMockResponse(userMsg);
312354
setIsTyping(false);
313355
setIsOffline(true);
314356
setMessages((prev) => [
315357
...prev,
316358
{
317359
role: "assistant",
318-
content:
319-
"I'm encountering a disruption on the orchestration layer — it appears the ExFlo node is temporarily offline. Please ensure the backend is running and try again. I will be standing by. 🛡️",
360+
content: mock.response,
320361
isStreaming: true,
362+
manifest: mock.manifest,
321363
},
322364
]);
323365
}

0 commit comments

Comments
 (0)