# DigiDala — Alpha49.7 Changeset

## Purpose

Fix the false client-side occupation conflict that could appear after the current Telegram user successfully occupied a free Mandala cell.

## Root cause established in Alpha49.6

Alpha49.6 attempted to determine whether the newly occupied cell belonged to the current user by comparing the API field `owner_user_id` with the Telegram user ID available in the Mini App.

That comparison is invalid because `owner_user_id` is the internal database `users.id`, while the Mini App has the Telegram user ID. The Alpha49.6 change therefore did not identify the current user's own occupation correctly.

## Alpha49.7 solution

The Mini App now tracks the index of the cell for which the current client has an occupation request in flight:

```text
pendingOwnOccupationIndex
```

The shared server-state reconciliation path suppresses the concurrent-occupation notice only while the newly occupied selected cell matches that pending own occupation.

The pending marker is cleared after a successful occupation or after an occupation error.

This keeps the two cases separate:

- successful occupation by the current user does not produce a false conflict;
- a genuine concurrent occupation by another participant still produces the conflict notice and disables the confirmation action.

## Scope

- `apps/miniapp/app.js` only changes the client-side occupation/synchronization handling.
- `apps/miniapp/index.html` updates Mini App cache-busters to `0.4.0-alpha.49.7`.
- `package.json` updates the project version to `0.4.0-alpha.49.7`.
- No backend, database schema, API, Pix ledger, payment flow or server-side Mandala lifecycle changes.

## Verification

Local automated verification:

```text
Structure: OK
JavaScript syntax: OK
Unit: 10/10
Integration: 37/37
API: 15/15
Total: 62/62
```

The exact tag `v0.4.0-alpha.49.7` was deployed with `scripts/deploy-test.sh v0.4.0-alpha.49.7`.

Deployment completed successfully and `/opt/pixdala/current` points to:

```text
/opt/pixdala/releases/v0.4.0-alpha.49.7
```

## Manual Telegram QA

### Own successful occupation

Passed. The current user can successfully occupy a free cell without receiving the false message that another participant has just occupied it.

### Genuine concurrent occupation

Passed in Sandbox with different Telegram users. While one user was composing a cell message, another user occupied the same cell. The first user's modal displayed the concurrent-occupation notice and the occupation button became inactive.

## Release status

Alpha49.7 is a verified functional checkpoint.

Release identity:

```text
Commit:
0f8fd46

Tag:
v0.4.0-alpha.49.7

Active release:
/opt/pixdala/releases/v0.4.0-alpha.49.7
```

## Historical note — Alpha49.6

Alpha49.6 was deployed after local automated verification, but manual Telegram QA showed that its attempted owner comparison did not fix the false conflict. The release is therefore not an accepted functional checkpoint and is superseded by Alpha49.7.
