# Rollout of the new UI: the view per poll

Decided by the product owner on 30 Oct 2026 (paper "Rollout neues Frontend und Premium-Übergang", part 1 and 2). This page
is the technical side: what the code does, the switch, the command for the existing polls and the deploy steps. Part 3 of
the paper (the Premium transition on 15 Nov) is a separate change.

## The rules

- **No switch on the account any more.** The dashboard, the user menu and every path in `v3_paths` are the new UI for
  everybody. `?ui=`, the `kulibri_ui` cookie and `users.ui_version` no longer count (they stay stored, unused).
- **Every poll has a view for its participants: classic or new.** It is `polls.options.uiMode`; a poll without it is
  classic, so the existing polls need no run over the whole table. The old third value `switch` (the participants chose)
  counts as new and is converted by the command below.
- **The poll's admins always open it in the new UI.** Admin means: the owner or a sub-admin by login, or the admin key in
  the link (the hashid of `polls.key`, or classic's old key `last4(ownerId)+ownerId`). The switch at the top of the poll page
  ("Neues kulibri | Klassisch") is for admins only and changes only their own look: it is the one-off `?classic=1`, nothing
  is remembered, the next visit is new again. In classic the same switch leads back.
- **Participants get the poll's view.** They have no switch and see nothing about it. `?classic=1` stays as the support
  valve (a bookmark with it keeps classic, even after the admin switched the poll to new).
- **Some polls only work in the new UI** and are new for everybody, `?classic=1` included: a course planner, a bring list, a
  poll with the waitlist (or with people still waiting or asking for a seat), a date poll with an option without a date.
  Such a poll cannot be set back to classic (the server answers 422 `ui_mode_required`). When a classic poll takes up one of
  these (the waitlist switched on, an option without a date added), it is set to new and stays so.
- **Options without a date count from `KULIBRI_UI_UNDATED_SINCE` on** (default 1 Sep 2026). Classic date polls hold such
  rows too (44 in the copy of October 2026, back to 2022) and run in classic; they are not moved.
- **Only the poll's admins change the view**: `POST /api/poll/ui-mode/{id}` `{ mode, key?, missing? }` (owner or sub-admin
  by login, or the admin key as `key`; 403 otherwise). Saving the poll's options never changes it. Going back to classic
  asks, optionally, "Was hat dir im neuen kulibri gefehlt?"; the answer goes to the feedback table (source `switchback`, the
  poll as page) and shows in the backend's feedback tab.
- **A new poll**: created by a signed-in admin, the editor asks at the top ("Ansicht für deine Teilnehmer", new by default,
  not remembered); created without an account it is new without a question. Course planner and bring list: no question.

## Where the admin sees and sets it

- **Dashboard:** every own poll shows "Ansicht für deine Teilnehmer: Neu | Klassisch" and can be changed there. A course
  planner and a bring list show "Neu" only; a poll that needs the new UI has "Klassisch" locked with the reason.
- **Editor:** the same setting at the very top, before the type and the title. It saves on its own, not with the poll.
- The paper's preview link "Im neuen kulibri ansehen" is not built: the admin always opens the poll in the new UI, so it
  would be the same as opening the poll (product owner, 30 Oct 2026: the admin's own view is always new).

## The texts

All three are in `frontend-v3/src/i18n` (`rollout.*`, `pollView.*`). Premium is not mentioned.

| Text | Where | When |
|---|---|---|
| 1 "Willkommen im neuen kulibri" | dashboard, dialog | once per account (notice `rollout-welcome`). Replaces opening "Was ist neu" by itself during the rollout; that one stays in the user menu. "Wie das Umstellen funktioniert" shows `frontend-v3/public/help/poll-view.png` |
| 2 "Das neue kulibri ist da" | poll page, dialog | once per account (notice `rollout-classic-poll`), without an account once per browser; only when the poll is classic and its admin sees it in the new UI |
| 3 | under the type tiles of the new-poll page, and under the link in the invite panel after creating | for whoever creates without an account |

## Measuring

- `polls.created_ui`: the UI the poll was created in (since 24 Oct 2026).
- `poll_ui_modes`: one row per change of the view, never updated: `from_mode`, `to_mode`, `user_id` (null for an admin link
  without an account and for the command), `source` (`create`: the view the poll was created with, one row per poll;
  `admin`; `rollout`: the command; `required`: the poll took up something only the new UI has). The view of a poll at any
  time follows from it.
- The nightly figures (2 Nov 2026, `DailyMetrics::POLL_VIEW_FIELDS`, the `all` row of `metrics_daily`, the day after):
  `poll_views_created_new` / `_classic` (the view new polls got, source `create`) and `poll_views_switched_new` / `_classic`
  (an admin changed it, source `admin`; the command and `required` are not choices and not counted). Null before the first
  logged change. The funnel's watchers show "Projekte zurück auf Klassisch": since the rollout there are no account switches,
  so this is the signal of dissatisfaction, with the answers to "Was hat dir im neuen kulibri gefehlt?" in the feedback tab.

## Switch and deploy

1. Deploy with `KULIBRI_UI_ROLLOUT=false` (the default): nothing changes for anybody.
2. `php artisan migrate` (new table `poll_ui_modes`).
3. Check which existing polls move to new: `php artisan kulibri:ui-rollout` (dry run; `--list` prints the ids per reason).
   In the copy of October 2026: 24 course planners, 2 bring lists, 3 with the waitlist, 2 with an option without a date,
   6 switchable; 11 were set to new already. Everything else stays classic.
4. `php artisan kulibri:ui-rollout --apply`.
5. `.env`: `KULIBRI_UI_ROLLOUT=true`, then `php artisan config:clear` (or `config:cache`).
6. Check: a classic poll link opens classic (`X-Kulibri-UI-Reason: poll-mode-classic`), the owner gets the new UI with text 2
   (`poll-admin`), `/dashboard` is the new UI for an account that chose classic before (`rollout`), a course planner is new
   with `?classic=1` (`poll-course`).

Back: `KULIBRI_UI_ROLLOUT=false` returns to the visitors' own choice. The views set meanwhile stay stored; with the switch off
they count only for Beta owners, as before.

## Reasons in `X-Kulibri-UI-Reason` during the rollout

`rollout` (a v3 path), `poll-admin` (an admin of the poll), `admin-classic-once` (an admin's one-off look at classic),
`poll-mode-new` / `poll-mode-classic` (the poll's view), `classic-once` (a participant's `?classic=1`), `new-once`,
`poll-course`, `poll-bringlist`, `poll-waitlist`, `poll-undated` (polls that need the new UI), and as before `poll-hidden`,
`poll-features-legacy`, `poll-not-found`, `poll-lookup-failed`.

## Code

| Part | Where |
|---|---|
| Rules, log, "needs the new UI" | `app/Kulibri/Ui/PollUiMode.php` |
| Which UI a request gets | `app/Kulibri/Ui/UiVersionResolver.php` (`rolloutPollChoice`) |
| Changing the view | `app/Http/Controllers/PollUiModeController.php`, route in `routes/api.php` |
| New poll, saving options | `PollController::postNew`, `keepSavedOptions`, `persistRequired` calls |
| Dashboard list, poll | `PollController::getMyPolls`, `getPoll` (`ui_mode`, `ui_required`, admins only) |
| Existing polls | `app/Console/Commands/UiRollout.php` |
| Handover rules of both UIs | `frontend/src/services/uiVersion.js` (`config.rollout`, `config.pollAdmin`) |
| New UI | `utils/pollUiMode.ts`, `composables/usePollView.ts`, `components/poll/PollViewSetting.vue`, `components/dashboard/DashboardPollView.vue`, `components/rollout/*`, `useClassicSwitch.ts` |
| Classic | the Beta popup is no longer opened (`RenderData.vue`); the switch only for a poll's admin (`uiVersion.js`) |
| Tests | `tests/Feature/UiRolloutTest.php`, `frontend-v3/src/__tests__/rollout.spec.ts`, `frontend/tests/unit/uiVersion.spec.js` |
