Skip to content

Commit d2a35f3

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

5 files changed

Lines changed: 87 additions & 69 deletions

File tree

pecan/src/components/Sidebar.tsx

Lines changed: 39 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -86,63 +86,45 @@ function Sidebar({ onClose, isOpen, onOpenSettings, onOpenAuth }: Readonly<Input
8686
path="/monitor-builder"
8787
onClose={onClose}
8888
/>
89-
<SidebarOption
90-
option="COMMS"
91-
path="/comms"
92-
onClose={onClose}
93-
/>
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 */}
112-
<li>
113-
<button
114-
onClick={() => setIsControlOpen(!isControlOpen)}
115-
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"
116-
>
117-
<span className="text-sidebarfg text-3xl font-heading leading-6 scale-y-75 uppercase text-left">
118-
Vehicle Control
119-
</span>
120-
<ChevronDown className={`text-sidebarfg transition-transform duration-300 ${isControlOpen ? 'rotate-180' : ''}`} />
121-
</button>
122-
123-
<div className={`overflow-hidden transition-all duration-300 ease-in-out ${isControlOpen ? 'max-h-64 opacity-100' : 'max-h-0 opacity-0'}`}>
124-
<ul className="list-none p-0 m-0 bg-black/10">
125-
<SidebarOption
126-
option="Throttle Mapper"
127-
path="/throttle-mapper"
128-
onClose={onClose}
129-
nested
130-
/>
131-
<SidebarOption
132-
option="CAN Transmitter"
133-
path="/can-transmitter"
134-
onClose={onClose}
135-
nested
136-
/>
137-
{/* <SidebarOption
138-
option="TX Messages"
139-
path="/tx"
140-
onClose={onClose}
141-
nested
142-
/> */}
143-
</ul>
144-
</div>
145-
</li>
89+
{import.meta.env.DEV && (
90+
<SidebarOption
91+
option="COMMS"
92+
path="/comms"
93+
onClose={onClose}
94+
isPending={true}
95+
/>
96+
)}
97+
{import.meta.env.DEV && (
98+
<li>
99+
<button
100+
onClick={() => setIsControlOpen(!isControlOpen)}
101+
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"
102+
>
103+
<span className="text-sidebarfg text-3xl font-heading leading-6 scale-y-75 uppercase text-left">
104+
Vehicle Control
105+
</span>
106+
<ChevronDown className={`text-sidebarfg transition-transform duration-300 ${isControlOpen ? 'rotate-180' : ''}`} />
107+
</button>
108+
<div className={`overflow-hidden transition-all duration-300 ease-in-out ${isControlOpen ? 'max-h-64 opacity-100' : 'max-h-0 opacity-0'}`}>
109+
<ul className="list-none p-0 m-0 bg-black/10">
110+
<SidebarOption
111+
option="Throttle Mapper"
112+
path="/throttle-mapper"
113+
onClose={onClose}
114+
nested
115+
isPending={true}
116+
/>
117+
<SidebarOption
118+
option="CAN Transmitter"
119+
path="/can-transmitter"
120+
onClose={onClose}
121+
nested
122+
isPending={true}
123+
/>
124+
</ul>
125+
</div>
126+
</li>
127+
)}
146128

147129
</ul>
148130
</div>

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)