Skip to content

Commit 66ce76f

Browse files
CopilotMrAlders0n
andcommitted
Separate capacity status messages: capacity full vs app down
Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
1 parent be674cc commit 66ce76f

2 files changed

Lines changed: 24 additions & 10 deletions

File tree

STATUS_MESSAGES.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,21 @@ Status messages follow these consistent conventions:
8989
- **Context**: When connecting to device and checking if a wardriving slot is available
9090
- **Minimum Visibility**: 500ms minimum enforced (or until API response received)
9191

92-
#### WarDriving app has reached capacity or is down
93-
- **Message**: `"WarDriving app has reached capacity or is down"`
92+
#### WarDriving app has reached capacity
93+
- **Message**: `"WarDriving app has reached capacity"`
9494
- **Color**: Red (error)
9595
- **Used in**: `checkCapacity()`, `postToMeshMapperAPI()`
96-
- **Source**: `content/wardrive.js:2051`, `content/wardrive.js:1115`, `content/wardrive.js:1049`, `content/wardrive.js:1068`
97-
- **Context**: Capacity check API denies slot on connect, returns error status, network is unreachable, or wardriving API returns allowed=false during active session
96+
- **Source**: `content/wardrive.js:1060`, `content/wardrive.js:1111`
97+
- **Context**: Capacity check API denies slot on connect (returns allowed=false), or wardriving API returns allowed=false during active session
98+
- **Minimum Visibility**: N/A (error state persists until disconnect)
99+
- **Notes**: Displayed when the API successfully responds but indicates capacity is full
100+
101+
#### WarDriving app is down
102+
- **Message**: `"WarDriving app is down"`
103+
- **Color**: Red (error)
104+
- **Used in**: `checkCapacity()`
105+
- **Source**: `content/wardrive.js:1050`, `content/wardrive.js:1067`
106+
- **Context**: Capacity check API returns error status or network is unreachable during connect
98107
- **Minimum Visibility**: N/A (error state persists until disconnect)
99108
- **Notes**: Implements fail-closed policy - connection is denied if API fails or is unreachable
100109

@@ -360,9 +369,9 @@ Result: "Message A" (visible 500ms) → "Message C"
360369

361370
## Summary
362371

363-
**Total Status Messages**: 29 unique message patterns
372+
**Total Status Messages**: 30 unique message patterns
364373
- **Connection**: 7 messages
365-
- **Capacity Check**: 3 messages (1 deprecated)
374+
- **Capacity Check**: 4 messages (1 deprecated)
366375
- **Ping Operation**: 6 messages (consolidated "Ping sent" for both manual and auto)
367376
- **GPS**: 2 messages
368377
- **Countdown Timers**: 6 message patterns (with dynamic countdown values)

content/wardrive.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,7 +1047,7 @@ async function checkCapacity(reason) {
10471047
// Fail closed on network errors for connect
10481048
if (reason === "connect") {
10491049
debugError("Failing closed (denying connection) due to API error");
1050-
setStatus("WarDriving app has reached capacity or is down", STATUS_COLORS.error);
1050+
setStatus("WarDriving app is down", STATUS_COLORS.error);
10511051
return false;
10521052
}
10531053
return true; // Always allow disconnect to proceed
@@ -1056,6 +1056,11 @@ async function checkCapacity(reason) {
10561056
const data = await response.json();
10571057
debugLog(`Capacity check response: allowed=${data.allowed}`);
10581058

1059+
// Handle capacity full vs. allowed cases separately
1060+
if (data.allowed === false && reason === "connect") {
1061+
setStatus("WarDriving app has reached capacity", STATUS_COLORS.error);
1062+
}
1063+
10591064
return data.allowed === true;
10601065

10611066
} catch (error) {
@@ -1064,7 +1069,7 @@ async function checkCapacity(reason) {
10641069
// Fail closed on network errors for connect
10651070
if (reason === "connect") {
10661071
debugError("Failing closed (denying connection) due to network error");
1067-
setStatus("WarDriving app has reached capacity or is down", STATUS_COLORS.error);
1072+
setStatus("WarDriving app is down", STATUS_COLORS.error);
10681073
return false;
10691074
}
10701075

@@ -1108,7 +1113,7 @@ async function postToMeshMapperAPI(lat, lon, heardRepeats) {
11081113
const data = await response.json();
11091114
if (data.allowed === false) {
11101115
debugWarn("MeshMapper API returned allowed=false, disconnecting");
1111-
setStatus("WarDriving app has reached capacity or is down", STATUS_COLORS.error);
1116+
setStatus("WarDriving app has reached capacity", STATUS_COLORS.error);
11121117
// Disconnect after a brief delay to ensure user sees the message
11131118
setTimeout(() => {
11141119
disconnect().catch(err => debugError(`Disconnect after capacity denial failed: ${err.message}`));
@@ -2044,7 +2049,7 @@ async function connect() {
20442049
const allowed = await checkCapacity("connect");
20452050
if (!allowed) {
20462051
debugWarn("Capacity check denied, disconnecting");
2047-
setStatus("WarDriving app has reached capacity or is down", STATUS_COLORS.error);
2052+
// Status message already set by checkCapacity()
20482053
// Disconnect after a brief delay to ensure user sees the message
20492054
setTimeout(() => {
20502055
disconnect().catch(err => debugError(`Disconnect after capacity denial failed: ${err.message}`));

0 commit comments

Comments
 (0)