diff --git a/src/App.vue b/src/App.vue index eeb53aa..00136dc 100644 --- a/src/App.vue +++ b/src/App.vue @@ -24,6 +24,10 @@ const importError = ref('') const fileInput = ref(null) const placingPreset = ref(null) const selectedCapabilityIds = ref([]) +type TransferKind = 'received' | 'sent' | 'stored' +interface TransferRecord { id: string; kind: TransferKind; scenarioName: string; stepNumber: number; stepExplanation: string; senderId: string; destinationId: string; payload: string; timestamp: string } +const transferHistory = ref([]) +const dataTab = ref('received') function loadLandscape(): LandscapeModel { try { return validateLandscape(JSON.parse(localStorage.getItem(STORAGE_KEY) || 'null')) } catch { return demoLandscape() } @@ -72,7 +76,7 @@ function addStep() { } function deleteStep(index: number) { selectedScenario.value?.steps.splice(index, 1); persist() } -function resetPlayback() { playing.value = false; stepIndex.value = -1; packetProgress.value = 0; eventLog.value = []; stopAnimation() } +function resetPlayback() { playing.value = false; stepIndex.value = -1; packetProgress.value = 0; eventLog.value = []; transferHistory.value = []; stopAnimation() } function startScenario(systemId?: string) { if (systemId) { const candidate = landscape.value.scenarios.find((scenario) => scenario.startSystemId === systemId) @@ -84,9 +88,26 @@ function advanceStep() { if (!selectedScenario.value || stepIndex.value + 1 >= selectedScenario.value.steps.length) { playing.value = false; return } stepIndex.value += 1; packetProgress.value = 0 const step = selectedScenario.value.steps[stepIndex.value] + recordTransfers(step) eventLog.value.unshift(`${new Date().toLocaleTimeString()} · ${step.explanation}`) animatePacket(step.delayMs / speed.value) } +function recordTransfers(step: ScenarioModel['steps'][number]) { + if (!selectedScenario.value) return + const now = new Date().toLocaleTimeString() + for (const connectionId of step.connectionIds) { + const connection = landscape.value.connections.find((item) => item.id === connectionId) + if (!connection) continue + const payload = step.payload || connection.payload + transferHistory.value.push( + { id: uid('transfer'), kind: 'sent', scenarioName: selectedScenario.value.name, stepNumber: stepIndex.value + 1, stepExplanation: step.explanation, senderId: connection.sourceId, destinationId: connection.targetId, payload, timestamp: now }, + { id: uid('transfer'), kind: 'received', scenarioName: selectedScenario.value.name, stepNumber: stepIndex.value + 1, stepExplanation: step.explanation, senderId: connection.sourceId, destinationId: connection.targetId, payload, timestamp: now }, + { id: uid('transfer'), kind: 'stored', scenarioName: selectedScenario.value.name, stepNumber: stepIndex.value + 1, stepExplanation: step.explanation, senderId: connection.sourceId, destinationId: connection.targetId, payload, timestamp: now } + ) + } +} +function recordsForSelectedSystem(kind: TransferKind) { if (!selectedSystem.value) return []; return transferHistory.value.filter((record) => kind === 'sent' ? record.senderId === selectedSystem.value?.id : record.destinationId === selectedSystem.value?.id) } +function systemName(id: string) { return landscape.value.systems.find((system) => system.id === id)?.name || id } function animatePacket(duration: number) { stopAnimation(); const started = performance.now() const tick = (now: number) => { packetProgress.value = Math.min(1, (now - started) / duration); drawPackets(); if (packetProgress.value < 1) animationFrame = requestAnimationFrame(tick); else if (playing.value) setTimeout(advanceStep, 180 / speed.value) } @@ -160,6 +181,7 @@ onUnmounted(stopAnimation)
CONNECTION

{{ selectedConnection.label }}

SCENARIO

{{ selectedScenario.name }}

Steps
{{ String(index + 1).padStart(2, '0') }}
⌘

Select an item

Choose a system, connection, or scenario to inspect and edit its details.

+
No simulated data yet. Run a scenario to populate this history.
Step {{ record.stepNumber }} · {{ record.timestamp }}{{ record.scenarioName }}
{{ systemName(record.senderId) }} → {{ systemName(record.destinationId) }}

{{ record.stepExplanation }}

{{ record.payload }}
diff --git a/src/inspector.css b/src/inspector.css new file mode 100644 index 0000000..83accfe --- /dev/null +++ b/src/inspector.css @@ -0,0 +1 @@ +.data-inspector{border-top:1px solid #263149}.data-tabs{display:flex;gap:5px;margin-bottom:12px}.data-tabs button{border:1px solid #33405a;background:#151d2d;color:#8996af;border-radius:4px;padding:6px 8px;font-size:10px;text-transform:capitalize}.data-tabs button.active{background:#8795ff;color:#08101f}.transfer-card{border:1px solid #2b3852;background:#0d1320;border-radius:6px;padding:9px;margin:8px 0;font-size:11px}.transfer-meta{display:flex;justify-content:space-between;gap:8px;color:#8795ff}.transfer-meta span{color:#7d89a2}.transfer-route{color:#dce4f4;margin-top:7px}.transfer-card p{color:#8996af;line-height:1.35;margin:5px 0}.transfer-card pre{white-space:pre-wrap;overflow:auto;color:#a9d8ce;font-size:10px;margin:5px 0 0} diff --git a/src/main.ts b/src/main.ts index 18a0f4d..0a40cc6 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,6 +1,7 @@ import { createApp } from 'vue' import App from './App.vue' import './style.css' +import './inspector.css' import './style.css' createApp(App).mount('#app')