Skip to content

Commit ebfc454

Browse files
committed
Refines measurement display and shot continuity
Merges sequential event data for thorough comparisons Applies new brand color styling Ensures hole and shot numbers carry forward Enhances clarity and unifies metric conversions
1 parent 2b63f07 commit ebfc454

26 files changed

+2091
-17
lines changed

.ai-context.md

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
# AI Assistant Context File
2+
3+
> **Purpose**: This file helps AI assistants understand the project structure and where to find documentation.
4+
5+
## 📂 Project Structure
6+
7+
### User-Facing Documentation
8+
- **Location**: `docs/` (user guides, authoring guides, etc.)
9+
- **Purpose**: Help users create and use app scripts
10+
- **Files**: authoring-guide.md, user-guide.md, schema-reference.md, etc.
11+
12+
### Technical Documentation
13+
- **Location**: `docs/technical/`**START HERE**
14+
- **Purpose**: Implementation details, bug fixes, feature documentation
15+
- **Index**: [`docs/technical/README.md`](./docs/technical/README.md)
16+
- **When to check**: Before making ANY code changes
17+
18+
### Application Code
19+
- **Frontend**: `src/` - React/TypeScript application
20+
- `src/components/` - React components
21+
- `src/hooks/` - Custom React hooks
22+
- `src/graphql/` - GraphQL queries
23+
- `src/utils/` - Utility functions
24+
25+
- **Backend**: `server/` - Node.js Express server
26+
- `server/src/index.ts` - Main server entry
27+
- `server/src/events.ts` - Event type definitions
28+
- `server/.env` - Environment variables (not in repo)
29+
30+
- **Schema**: `schema/` - JSON schemas for app scripting
31+
- **Examples**: `examples/` - Example script files
32+
33+
## 🎯 Quick Rules for AI Assistants
34+
35+
### Before Making Changes
36+
1. **ALWAYS** check [`docs/technical/README.md`](./docs/technical/README.md) first
37+
2. Look for related documentation about the feature/component you're changing
38+
3. Understand the event ordering (newest at index 0)
39+
4. Consider both initial load AND SSE update paths
40+
41+
### When Creating New Features
42+
1. Implement the feature
43+
2. Create documentation in `docs/technical/FEATURE_NAME.md`
44+
3. Update [`docs/technical/README.md`](./docs/technical/README.md) to include your new doc
45+
4. Use the template structure provided in the README
46+
47+
### When Fixing Bugs
48+
1. Check if a fix already exists in `docs/technical/`
49+
2. Implement the fix
50+
3. Document it in `docs/technical/FIX_DESCRIPTION.md`
51+
4. Update the index
52+
53+
## 📚 Key Documentation Files
54+
55+
Must-read before working on these areas:
56+
57+
| Working On | Read This |
58+
|------------|-----------|
59+
| Event handling | [ACTIVITY_SESSION_STATE.md](./docs/technical/ACTIVITY_SESSION_STATE.md) |
60+
| Measurement display | [MEASUREMENT_TILES_MULTI_EVENT.md](./docs/technical/MEASUREMENT_TILES_MULTI_EVENT.md) |
61+
| Hole/shot tracking | [SHOT_NUMBER_CARRY_FORWARD_FIX.md](./docs/technical/SHOT_NUMBER_CARRY_FORWARD_FIX.md) |
62+
| Unit conversion | [UNIT_CONVERSION_SYSTEM.md](./docs/technical/UNIT_CONVERSION_SYSTEM.md) |
63+
| Filtering events | [DEVICE_ID_FILTERING.md](./docs/technical/DEVICE_ID_FILTERING.md) |
64+
| Local development | [WEBHOOK_LOCAL_FIX.md](./docs/technical/WEBHOOK_LOCAL_FIX.md) |
65+
| Azure Storage | [LOCAL_AZURE_STORAGE_SETUP.md](./docs/technical/LOCAL_AZURE_STORAGE_SETUP.md) |
66+
67+
## 🔍 Common Patterns
68+
69+
### Event List Structure
70+
```typescript
71+
// Events are ordered: newest at index 0
72+
const events = [
73+
{ id: '3', timestamp: '14:08:00' }, // ← Newest (index 0)
74+
{ id: '2', timestamp: '14:07:55' },
75+
{ id: '1', timestamp: '14:07:50' } // ← Oldest
76+
];
77+
78+
// To search backward in time = search forward through array
79+
for (let i = currentIndex + 1; i < events.length; i++) {
80+
const olderEvent = events[i]; // Going back in time
81+
}
82+
```
83+
84+
### Session Matching
85+
```typescript
86+
// Always check ActivitySession.Id when correlating events
87+
const { activitySessionId } = getSessionIds(event);
88+
if (prevSessionId === activitySessionId) {
89+
// Events belong to same session
90+
}
91+
```
92+
93+
### Data Extraction
94+
```typescript
95+
// Events have nested structures
96+
const payload = event?.data?.EventModel || event?.EventModel || event;
97+
```
98+
99+
## 🚫 Common Mistakes to Avoid
100+
101+
1. **Don't assume event order** - Newest is at index 0, not at the end
102+
2. **Don't store transient data in session state** - Only store truly shared data (like course info)
103+
3. **Don't forget SSE updates** - Changes must work for both initial load AND real-time updates
104+
4. **Don't skip documentation** - Always document significant changes
105+
5. **Don't create root-level .md files** - Put technical docs in `docs/technical/`
106+
107+
## 💾 Key State Management
108+
109+
### Session State (useRef)
110+
- **Location**: `src/hooks/useActivitySessionState.ts`
111+
- **Purpose**: Store course info shared across events in same ActivitySession
112+
- **Storage**: `useRef<Map<string, ActivitySessionData>>`
113+
- **Why useRef**: Prevents re-renders, persists across component lifecycle
114+
115+
### Local Storage
116+
- **Unit preferences**: `measurementUnitSystem` ('imperial' | 'metric')
117+
- **Persists across**: Page refreshes, browser sessions
118+
119+
### URL Parameters
120+
- **Device filtering**: `?deviceId=abc123`
121+
- **Bay filtering**: `?bayId=bay-1`
122+
123+
## 🔧 Development Commands
124+
125+
```bash
126+
# Install dependencies
127+
npm install
128+
129+
# Start frontend dev server (port 5000)
130+
npm run dev
131+
132+
# Start backend server (port 4000)
133+
cd server && npm start
134+
135+
# Run both with watch mode
136+
npm run start-dev
137+
138+
# Validate example scripts
139+
npm run validate
140+
141+
# Format code
142+
npm run format
143+
```
144+
145+
## 📝 File Naming Conventions
146+
147+
### Technical Documentation
148+
- **Features**: `FEATURE_NAME.md` (e.g., `DEVICE_ID_FILTERING.md`)
149+
- **Fixes**: `FIX_DESCRIPTION.md` (e.g., `SHOT_NUMBER_CARRY_FORWARD_FIX.md`)
150+
- **Setup**: `SETUP_DESCRIPTION.md` (e.g., `LOCAL_AZURE_STORAGE_SETUP.md`)
151+
- **All CAPS with underscores**: Easier to spot in file listings
152+
153+
### Code Files
154+
- **Components**: PascalCase (e.g., `WebhookInspector.tsx`)
155+
- **Hooks**: camelCase with 'use' prefix (e.g., `useActivitySessionState.ts`)
156+
- **Utils**: camelCase (e.g., `sessionHelpers.ts`)
157+
158+
## 🎯 Remember
159+
160+
**The `docs/technical/` folder is your AI context repository.**
161+
162+
When a user says:
163+
- "Why does X work this way?" → Check docs/technical/
164+
- "Can you implement Y?" → Check if Y is documented first
165+
- "This is broken!" → Check if there's a fix doc
166+
- "How does Z work?" → Point them to the relevant doc
167+
168+
**Always update documentation when you make significant changes!**
169+
170+
---
171+
172+
**Last Updated**: October 3, 2025

0 commit comments

Comments
 (0)