Skip to content

Commit 8dc4855

Browse files
committed
Update AccumulatorTypes.ts, dev flags, build number and force update
1 parent e58a898 commit 8dc4855

5 files changed

Lines changed: 59 additions & 40 deletions

File tree

pecan/src/components/Sidebar.tsx

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -90,56 +90,39 @@ function Sidebar({ onClose, isOpen, onOpenSettings, onOpenAuth }: Readonly<Input
9090
option="COMMS"
9191
path="/comms"
9292
onClose={onClose}
93+
isPending={true}
9394
/>
94-
{/* <SidebarOption
95-
option="Throttle Mapper"
96-
path="/throttle-mapper"
97-
onClose={onClose}
98-
/>
99-
<SidebarOption
100-
option="CAN Transmitter"
101-
path="/can-transmitter"
102-
onClose={onClose}
103-
/>
104-
<SidebarOption
105-
option="TX Messages"
106-
path="/tx"
107-
onClose={onClose}
108-
/> */}
109-
110-
111-
{/* DROPDOWN GROUP */}
11295
<li>
113-
<button
96+
<button
11497
onClick={() => setIsControlOpen(!isControlOpen)}
11598
className="flex w-full gap-3 h-20 items-center justify-between box-border px-3 bg-option hover:bg-option-select/75 transition-colors border-none cursor-pointer"
11699
>
117-
<span className="text-sidebarfg text-3xl font-heading leading-6 scale-y-75 uppercase text-left">
118-
Vehicle Control
100+
<span className="flex items-center gap-2">
101+
<span className="text-sidebarfg text-3xl font-heading leading-6 scale-y-75 uppercase text-left">
102+
Vehicle Control
103+
</span>
104+
<span className="text-xs bg-yellow-500/20 text-yellow-500 px-1.5 py-0.5 rounded border border-yellow-500/40 font-mono tracking-wider">
105+
DEV
106+
</span>
119107
</span>
120108
<ChevronDown className={`text-sidebarfg transition-transform duration-300 ${isControlOpen ? 'rotate-180' : ''}`} />
121109
</button>
122-
123110
<div className={`overflow-hidden transition-all duration-300 ease-in-out ${isControlOpen ? 'max-h-64 opacity-100' : 'max-h-0 opacity-0'}`}>
124111
<ul className="list-none p-0 m-0 bg-black/10">
125112
<SidebarOption
126113
option="Throttle Mapper"
127114
path="/throttle-mapper"
128115
onClose={onClose}
129116
nested
117+
isPending={true}
130118
/>
131119
<SidebarOption
132120
option="CAN Transmitter"
133121
path="/can-transmitter"
134122
onClose={onClose}
135123
nested
124+
isPending={true}
136125
/>
137-
{/* <SidebarOption
138-
option="TX Messages"
139-
path="/tx"
140-
onClose={onClose}
141-
nested
142-
/> */}
143126
</ul>
144127
</div>
145128
</li>

pecan/src/components/accumulator/AccumulatorTypes.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* for the 5-module accumulator pack monitoring system.
66
*/
77

8+
import { formatCanId } from '../../utils/canProcessor';
9+
810
// Module identifiers
911
export const MODULE_IDS = ['M1', 'M2', 'M3', 'M4', 'M5'] as const;
1012
export type ModuleId = typeof MODULE_IDS[number];
@@ -51,7 +53,7 @@ export function getCellSignalInfo(module: ModuleId, cellIndex: number): { msgId:
5153
const msgNum = Math.ceil(cellIndex / CELLS_PER_VOLTAGE_MSG) - 1; // 0-indexed offset
5254
const canId = VOLTAGE_BASE_ID[module] + msgNum;
5355
const signalName = `${module}_Cell${cellIndex}_Voltage`;
54-
return { msgId: String(canId), signalName };
56+
return { msgId: formatCanId(canId), signalName };
5557
}
5658

5759
/**
@@ -66,7 +68,7 @@ export function getThermistorSignalInfo(module: ModuleId, thermistorIndex: numbe
6668
const msgNum = Math.ceil(thermistorIndex / THERMISTORS_PER_TEMP_MSG) - 1; // 0-indexed offset
6769
const canId = TEMP_BASE_ID[module] + msgNum;
6870
const signalName = `${module}_Thermistor${thermistorIndex}`;
69-
return { msgId: String(canId), signalName };
71+
return { msgId: formatCanId(canId), signalName };
7072
}
7173

7274
// Legacy functions for backwards compatibility

pecan/src/pages/Dashboard.tsx

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -761,15 +761,16 @@ function Dashboard() {
761761
)
762762
}
763763

764-
{/* Performance Tab - Fixed at bottom (controlled by settings) */}
765-
{showPerfOverlay && (
766-
<div className="fixed bottom-0 left-0 right-0 z-30">
767-
<div className="w-full py-2 px-4 bg-data-textbox-bg/95 backdrop-blur text-gray-300 text-xs border-t border-white/10">
768-
<div className="flex justify-between items-center max-w-6xl mx-auto flex-wrap gap-1">
764+
{/* Bottom bar: Build version + Force update, and perf stats when overlay enabled */}
765+
<div className="fixed bottom-0 left-0 right-0 z-30 py-1.5 px-4 bg-data-textbox-bg/95 backdrop-blur text-gray-400 text-xs border-t border-white/10">
766+
<div className="flex justify-between items-center max-w-6xl mx-auto flex-wrap gap-2">
767+
<span title="Git commit this build is based on">
768+
Build: <code className="font-mono text-gray-300">{typeof __GIT_COMMIT__ !== "undefined" ? __GIT_COMMIT__ : "—"}</code>
769+
</span>
770+
{showPerfOverlay && (
771+
<div className="flex flex-wrap gap-2">
769772
<span>FPS: {performanceStats.fps}</span>
770-
<span className="hidden sm:inline">
771-
CAN: {dataStoreStats.totalMessages > 0 ? "Live" : "0"}
772-
</span>
773+
<span className="hidden sm:inline">CAN: {dataStoreStats.totalMessages > 0 ? "Live" : "0"}</span>
773774
<span className="hidden md:inline">
774775
Mem: {performanceStats.memoryUsage}
775776
{typeof performanceStats.memoryUsage === "number" ? "MB" : ""}
@@ -779,9 +780,25 @@ function Dashboard() {
779780
</span>
780781
<span className="hidden lg:inline">Store Mem: {dataStoreStats.memoryEstimateMB}MB</span>
781782
</div>
782-
</div>
783+
)}
784+
<button
785+
type="button"
786+
onClick={async () => {
787+
if (!confirm("Clear PWA cache and reload to get the latest version?")) return;
788+
try {
789+
const regs = await navigator.serviceWorker?.getRegistrations?.() ?? [];
790+
for (const reg of regs) await reg.unregister();
791+
const names = await caches?.keys?.() ?? [];
792+
for (const name of names) await caches.delete(name);
793+
} catch (_) { /* ignore */ }
794+
window.location.reload();
795+
}}
796+
className="text-gray-400 hover:text-white underline cursor-pointer shrink-0"
797+
>
798+
Force update
799+
</button>
783800
</div>
784-
)}
801+
</div>
785802
</div>
786803
);
787804
}

pecan/src/vite-env.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/// <reference types="vite/client" />
2+
3+
/** Git commit hash (short) injected at build time for version display */
4+
declare const __GIT_COMMIT__: string;

pecan/vite.config.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@ import react from "@vitejs/plugin-react";
33
import tailwindcss from "@tailwindcss/vite";
44
import type { Plugin } from "vite";
55
import { VitePWA } from 'vite-plugin-pwa';
6+
import { execSync } from 'node:child_process';
7+
8+
function getGitCommit(): string {
9+
try {
10+
return execSync('git rev-parse --short HEAD', { encoding: 'utf-8' }).trim();
11+
} catch {
12+
return 'unknown';
13+
}
14+
}
615

716
// Custom domain: pecan.westernformularacing.org (no base path needed)
817

@@ -73,8 +82,12 @@ function startWebSocketServer() {
7382
}
7483

7584
// https://vite.dev/config/
85+
const gitCommit = getGitCommit();
7686
export default defineConfig({
7787
base: '/',
88+
define: {
89+
__GIT_COMMIT__: JSON.stringify(gitCommit),
90+
},
7891
plugins: [
7992
react(),
8093
tailwindcss(),

0 commit comments

Comments
 (0)