# DATA-001: Field labels persist after data refresh

**Status: REPRODUCED + A/B CONFIRMED** — NexusCRM shows ApiName variants, SF shows proper Labels

## Environment Setup

### Backend A — NexusCRM

1. Configure and start frontend:
   ```bash
   cd frontend
   echo "REACT_APP_BACKEND_URL=https://nexuscrm.pingcap.com" > .env
   npm run dev  # starts on localhost:5173
   ```

2. Get a JWT token:
   ```bash
   curl -s -X POST "https://nexuscrm.pingcap.com/services/oauth2/token" \
     -H "Content-Type: application/x-www-form-urlencoded" \
     -d "grant_type=client_credentials&client_id=test-gosf-client&client_secret=test-gosf-secret-123" \
     | python3 -c "import sys,json; print(json.load(sys.stdin).get('access_token',''))"
   ```

3. Login via JavaScript console:
   ```javascript
   localStorage.setItem('auth_token', '<JWT token from step 2>');
   localStorage.setItem('instance_url', 'https://nexuscrm.pingcap.com');
   location.reload();
   ```

### Backend B — Salesforce (via Vite proxy)

1. Configure and start frontend:
   ```bash
   cd frontend
   echo "REACT_APP_BACKEND_URL=https://pingcap--partialcop.sandbox.my.salesforce.com" > .env
   npm run dev  # starts on localhost:5173
   ```

2. Login via Backend mode → Advanced Options → Token:
   - Token: `00D...` (valid SF session token)
   - **CRITICAL**: instance_url must be `http://localhost:5173` (NOT the SF URL).
     This forces all API requests through the Vite proxy, bypassing CORS.
   - Click Login

## Steps (verified 2026-03-25)

1. Navigate to `http://localhost:5173/object/Account`
2. Observe the column headers in the list view
3. Double-click a record to open detail page
4. Observe the field labels in the INFORMATION section and edit form

## Actual Result (NexusCRM backend)

### List view column headers:
- "Name" — correct
- "External Id C" — should be "External ID"
- "Industry" — correct
- "Portal Id C" — should be "Portal ID"

### Record detail page:
- "Systemmodstamp" — should be "System Modstamp" or "Last Modified"
- "Name" — correct
- "Industry" — correct
- "External Id C" — should be "External ID"
- "Portal Id C" — should be "Portal ID"

### Edit form:
- Same labels as detail page

## Expected Result

Fields with defined Labels should show human-readable Labels:
- "External_Id__c" → "External ID"
- "Portal_ID__c" → "Portal ID"
- "SystemModstamp" → "System Modstamp"

Standard fields (Name, Industry) display correctly because their Labels
match common naming conventions.

## A/B Comparison (verified 2026-03-25 via Vite proxy)

SF Backend: `.env` → `REACT_APP_BACKEND_URL=https://pingcap--partialcop.sandbox.my.salesforce.com`
NexusCRM Backend: `.env` → `REACT_APP_BACKEND_URL=https://nexuscrm.pingcap.com`

| Field | SF Backend (Oracle) | NexusCRM Backend |
|-------|-----------|-----------------|
| Name field | **"Account Name"** (Label) | "Name" (ApiName) |
| Custom fields | **"Important"**, **"Online CSA Accepted"** (Labels) | "External Id C", "Portal Id C" (ApiName variants) |
| ID field | **"Account ID"** (Label) | "Id" (ApiName) |
| Available fields in picker | 234 | 12 |
| Quick Analytics | Total Records: 3,121 | Total Records: 1 (shows 100) |
| App | **"Sales"** with nav | No app configured |

**Confirmed: NexusCRM backend returns ApiName-based labels, SF returns proper Labels.**

## Root Cause

Custom fields created via Tooling API had their Labels set (DATA-004 API test
confirms 9/12 fields have Label != ApiName). However, the frontend may be using
a naive humanization of the API Name (remove underscores, title case) instead of
the `label` property from the describe response.

API test DATA-004 showed Labels are present in the describe response, so the issue
is likely in the frontend field label rendering — it may not be reading the `label`
property correctly for all fields.

## Failure Indicators

- Column headers show API Name variants instead of Labels
- Field labels show underscored names (e.g., "External_Id__c")
- Field labels show CamelCase API names (e.g., "SystemModstamp")
- Labels revert after data refresh/import

## Related

- DATA-004 (API): Confirmed 9/12 Account fields have distinct Labels in describe
- DATA-006 (API): Confirmed describe response has correct Salesforce shape
