@@ -171,7 +173,7 @@
diff --git a/DOCS/Changes/2026-10-04_Async_PKI_Init.md b/DOCS/Changes/2026-10-04_Async_PKI_Init.md
new file mode 100644
index 0000000..7b3a072
--- /dev/null
+++ b/DOCS/Changes/2026-10-04_Async_PKI_Init.md
@@ -0,0 +1,35 @@
+# Async PKI initialization (2026-10-04)
+
+Goal: `Init PKI` can take minutes (DH parameters); it no longer holds an HTTP request. Plan: [Async_PKI_Init_PLAN](2026-10-04_Async_PKI_Init_PLAN.md).
+
+## Changes
+
+| Area | Change |
+|---|---|
+| API (`APP_PROFILER/routers/system.py`) | `POST /system/init` returns `202 {"state":"running"}` and runs the init in a background thread; `409` if a job is running or the PKI is initialized. New `GET /system/init/status` (`state`, `step`, `initialized`, `started_at`, `finished_at`, `error`). `DELETE /system/pki` and `POST /profiles` return `409` while a job is running |
+| Service (`APP_PROFILER/services/pki.py`) | In-memory job state under a lock; the thread uses its own DB session; steps `init-pki`, `ca`, `server-cert`, `dh`, `ta-key`, `crl`; EasyRSA error text is stored in `error` |
+| Interrupted runs | A marker file `/.pki-init-in-progress` (outside the PKI directory) exists while a job runs and is removed on success. A leftover marker (restart, crash, failed job) means the PKI is incomplete: it is wiped and rebuilt on the next Init. A PKI without the marker and with `ca.crt` counts as initialized and is **never** wiped automatically |
+| UI (`APP_UI/src/views/PKIConfig.vue`) | State comes from the server on page load; spinner and step text while running, polling every 3 s; Init, Clear and Save disabled while running; Init disabled with a hint once initialized; success or error message at the end; a `409` on start attaches to the running job; the button locks on click |
+| Docs | `DOCS/Profiler_Management/API_Reference.md` |
+| Test | `APP_PROFILER/test_async_pki_init.py` (one test with EasyRSA stubs): 202, second start 409, status `running`, Clear 409, then `done` and a further start 409 |
+
+## Verification (containers)
+
+| Check | Result |
+|---|---|
+| `pytest test_async_pki_init.py` and `test_profile_note.py` in `python:3.12-alpine` | 2 passed |
+| Existing complete PKI | status `initialized: true`, Init is a no-op |
+| Clear, then Init | `202`, second start `409`, steps `init-pki` → `dh` → `done` (3 s and 54 s in two runs) |
+| Partial PKI with the marker (simulated interrupted run) | wiped, rebuilt, marker removed, `initialized: true` |
+| Create a client during the run / after it | `409` / `200` |
+| UI bundle | `app-ui` builds and contains the status polling; the page behaviour is checked manually |
+
+## Notes
+
+- The Profiler must run as a single process (in-memory job state): `python main.py` in Docker, one `uvicorn` in the native unit. Do not add workers.
+- Initialization is not cancelled by a page reload; the page reattaches to the running job.
+- Not implemented: cancelling a run, progress percentage, async Clear PKI.
+
+## Existing installations
+
+No manual steps. Rebuild and restart the Profiler (native: `ovpmon-profiler`; Docker: `app-profiler`, `app-ui`). An already initialized PKI is detected as before.
diff --git a/DOCS/Changes/2026-10-04_Async_PKI_Init_PLAN.md b/DOCS/Changes/2026-10-04_Async_PKI_Init_PLAN.md
new file mode 100644
index 0000000..10f3047
--- /dev/null
+++ b/DOCS/Changes/2026-10-04_Async_PKI_Init_PLAN.md
@@ -0,0 +1,46 @@
+# Async PKI initialization: implementation plan (2026-10-04)
+
+Goal: `Init PKI` can take minutes (DH parameters). Run it in the background; the PKI Configuration page shows progress, survives a page reload and prevents a second start.
+
+## Current state
+- `POST /system/init` (`APP_PROFILER/routers/system.py`) runs `pki.init_pki()` synchronously: init-pki, build-ca, server cert, gen-dh, ta.key, gen-crl, CRL publish. The HTTP request stays open until it ends.
+- `pki.init_pki()` treats the PKI as initialized if `ca.crt` exists, so a PKI interrupted after the CA step (restart, crash) would be reported as ready.
+- `PKIConfig.vue`: `isLoading` is local to the page, so a reload loses the state and the button becomes active again.
+- The Profiler runs as a single process (`python main.py` in Docker, one `uvicorn` in the native unit), so in-memory job state is valid.
+
+## Steps
+
+### 1. Backend (`APP_PROFILER/`)
+- `services/pki.py`
+ - `is_initialized()`: true only when the PKI is complete (`ca.crt`, `dh.pem`, `ta.key`, `crl.pem` and the server certificate exist). Existing complete PKIs are detected without migration.
+ - Job state `init_job` (module level, guarded by a lock): `state` = `idle | running | done | error`, `step` (init-pki, CA, server certificate, DH, TLS key, CRL), `started_at`, `finished_at`, `error`.
+ - `start_init_async()`: refuses to start when a job is running or the PKI is complete; removes an incomplete PKI left by an interrupted run; starts a daemon thread with its **own** DB session; the thread updates `step` and ends in `done` or `error` (error text from EasyRSA, no secrets).
+- `routers/system.py`
+ - `POST /system/init` returns `202 {"state": "running"}` immediately; `409` if a job is running or the PKI is already initialized.
+ - `GET /system/init/status` returns `{state, step, initialized, started_at, finished_at, error}`.
+ - `DELETE /system/pki` returns `409` while an init job is running.
+ - `POST /profiles` returns `409` while an init job is running (the PKI is not complete).
+- After an application restart the state is `idle`; an interrupted PKI is reported as `initialized: false`, and Init PKI cleans it up and starts again.
+
+### 2. UI (`APP_UI/src/views/PKIConfig.vue`)
+- On mount call `GET /system/init/status`; state is taken from the server, not from the page.
+- `running`: spinner on the Init PKI button, the current step text ("Generating DH parameters..."), polling every 3 s, Init / Clear / Save disabled.
+- `done` or `initialized: true`: Init PKI is disabled with the hint "PKI is already initialized. Use Clear PKI to start over"; a success message is shown once when the job finishes while the page is open.
+- `error`: error message, Init PKI is enabled again.
+- After Clear PKI the status is reloaded and the button is enabled again.
+- A double click or a second tab cannot start a second job (button locked immediately on click, backend answers `409` anyway; the UI treats `409 running` as "attach to the running job").
+- Polling stops on unmount.
+
+### 3. Tests (minimal)
+- One pytest in `APP_PROFILER`: with the EasyRSA steps replaced by fast stubs, `POST /system/init` returns `202`, a second `POST` returns `409`, `GET /system/init/status` ends in `done` and `initialized: true`, a third `POST` returns `409`. No UI tests.
+
+### 4. Verification (containers, stand `ovpmon-test`, port 8089)
+- Rebuild `app-profiler` and `app-ui`. Clear PKI, press Init PKI: spinner appears, the page can be reloaded and still shows progress, buttons are locked, the result appears on completion, Init PKI stays locked afterwards, Clear PKI unlocks it.
+- Restart `ovp-profiler` during the run: status is `idle` and `initialized: false`, Init PKI cleans up and completes.
+- Existing PKI from the current stand is detected as initialized.
+
+### 5. Documentation
+- `DOCS/Profiler_Management/API_Reference.md` (new endpoints and `409` cases), `README.md`, `DOCS/General/Index.md`, summary `DOCS/Changes/2026-10-04_Async_PKI_Init.md`. Note for operators: single Profiler process is required (do not run several uvicorn workers).
+
+## Out of scope
+Cancelling a running init, progress percentage, async Clear PKI, job history.
diff --git a/DOCS/Changes/2026-10-04_Profile_Modal_Polish_PLAN.md b/DOCS/Changes/2026-10-04_Profile_Modal_Polish_PLAN.md
new file mode 100644
index 0000000..99c5649
--- /dev/null
+++ b/DOCS/Changes/2026-10-04_Profile_Modal_Polish_PLAN.md
@@ -0,0 +1,29 @@
+# Compact profile modal and note tooltip: implementation plan (2026-10-04)
+
+Goal: (1) make the profile details modal compact with a balanced layout, (2) show the profile note in a tooltip when hovering over the client name in the Certificates list. UI only; no API or DB changes.
+
+## Steps
+
+### 1. Compact modal (`APP_UI/src/components/ProfileDetailsModal.vue`)
+- Remove `modal-lg`: use the default Bootstrap width (500 px) and `modal-dialog-centered`; on phones it stays full width minus margins.
+- Layout of the details block: a compact two-column "label : value" list (fixed narrow label column, value left-aligned right next to it) instead of two wide columns. Rows: Status, Created, Expires (with days remaining next to the date, e.g. `2027-01-10 (98 d)`), Revoked (only if set), File.
+- Header: client name as the title with the status badge next to it; the separate "Client Name" and "Status" rows are removed.
+- File path: single line, `text-break`, small muted font.
+- Note: textarea with 3 rows, counter under it on the right; Save / Close buttons stay in the footer.
+- Dates: one short format (`YYYY-MM-DD HH:mm`) instead of locale date plus time.
+
+### 2. Note tooltip (`APP_UI/src/views/Certificates.vue`)
+- Hovering the username cell (both active and expired/revoked rows) shows a tooltip with the note text. No note: no tooltip.
+- Implementation: Bootstrap Tooltip (already a dependency) via a small directive `v-note-tooltip="cert.note"` in `APP_UI/src/directives/` (create on mount, update the text when the note changes after saving, dispose on unmount). Options: `placement: 'top'`, `container: 'body'`, `html: false` (note is plain text, so no XSS), long text wrapped to a max width of about 320 px, line breaks preserved.
+- Small note marker (`fa-note-sticky` icon, muted) next to the username when a note exists, so it is visible which clients have a note.
+- Styles in `assets/main.css`: tooltip max width, `white-space: pre-wrap`, dark theme colours via existing variables.
+
+### 3. Verification (containers, no new tests)
+- No new automated tests (UI only, no UI test infrastructure).
+- Rebuild `app-ui` in the existing stand (`ovpmon-test`, port 8089) and check manually: modal width and layout in light and dark themes and on a narrow window; tooltip on active and revoked rows; tooltip text updates right after saving a note; no tooltip for clients without a note; long and multi-line notes.
+
+### 4. Documentation
+- Summary appended to `DOCS/Changes/2026-10-04_Profile_Notes.md`; one line in the `README.md` changes table.
+
+## Out of scope
+Showing the note as a table column, editing the note from the list, API changes.
diff --git a/DOCS/Changes/2026-10-04_Profile_Notes.md b/DOCS/Changes/2026-10-04_Profile_Notes.md
new file mode 100644
index 0000000..ebcb629
--- /dev/null
+++ b/DOCS/Changes/2026-10-04_Profile_Notes.md
@@ -0,0 +1,55 @@
+# Profile details modal and notes (2026-10-04)
+
+Goal: make rows on the **Certificates** page clickable; a click opens a modal with the main profile details and a note that can be saved. Plan: [Profile_Notes_PLAN](2026-10-04_Profile_Notes_PLAN.md).
+
+## Changes
+
+| Area | Change |
+|---|---|
+| Model (`APP_PROFILER/models.py`) | `UserProfile.note` (nullable `Text`) |
+| Schemas (`APP_PROFILER/schemas.py`) | `note` in the profile response; `UserProfileNoteUpdate` (max 1000 chars, empty or whitespace-only becomes `null`) |
+| Migration (`APP_PROFILER/database.py`, `main.py`) | `ensure_columns()` runs after `create_all` and adds `note` to an existing `user_profiles` table if missing (idempotent) |
+| API (`APP_PROFILER/routers/profiles.py`) | `PUT /profiles/{id}/note` returns the updated profile; `404` if missing; JWT required. PUT is used because CORS does not allow PATCH |
+| UI (`APP_UI/src/components/ProfileDetailsModal.vue`) | New modal on `BaseModal`: name, status, created, expiration, days remaining, revoked date, file path, note textarea with counter; Save is enabled only after a change |
+| UI (`APP_UI/src/views/Certificates.vue`) | Rows (active and expired/revoked) open the modal; download/revoke buttons use `@click.stop`; `saveNote()` calls the API, shows a toast and reloads the list |
+| Fix (`APP_PROFILER/requirements.txt`) | Added `requests`: `services/utils.py` imports it to detect the public IP, and creating a client failed with `No module named 'requests'` (HTTP 500, "Config Generation failed") when Public IP was not set in server settings. The failed attempts had already issued the certificate in PKI |
+| Docs | `DOCS/Profiler_Management/API_Reference.md`: new endpoint and `note` field |
+| Tests | `APP_PROFILER/test_profile_note.py` (one test), `APP_PROFILER/requirements-dev.txt` |
+
+## Verification (in containers)
+
+| Check | Result |
+|---|---|
+| `pytest test_profile_note.py` in `python:3.12-alpine` | 1 passed |
+| `docker compose` build of all four images | OK |
+| New DB: `note` column present | OK |
+| Old-schema DB (no `note`): column added on start, data kept, second start is a no-op | OK |
+| `PUT /profiles/{id}/note` with JWT | 200, note returned by `GET /profiles` |
+| Without token / note over 1000 chars / unknown id | 401 / 422 / 404 |
+| Whitespace-only note | stored as `null` |
+| Browser check of the UI | manual (see below) |
+
+## Notes
+
+- Run the new test on its own (`cd APP_PROFILER && pip install -r requirements-dev.txt && pytest test_profile_note.py`): the older `test_server_process.py` also imports `main` with the default DB path.
+- On a revoked row the Revoke button is disabled; some browsers do not pass a click on a disabled button to the row, so the modal may not open from that spot. Click elsewhere in the row.
+- The modal closes right after Save; if the request fails the text is not kept.
+
+## Existing installations
+
+Rebuild the Profiler image so that `requests` is installed. A client name whose certificate was already issued by a failed attempt cannot be created again (Easy-RSA: certificate exists, HTTP 500); use another name or revoke/clear it in PKI.
+
+No manual steps: the `note` column is added on the next Profiler start (native: restart `ovpmon-profiler`; Docker: rebuild `app-profiler` and `app-ui`). Back up `ovpn_profiler.db` first.
+
+## Follow-up: compact modal and note tooltip (2026-10-04)
+
+Plan: [Profile_Modal_Polish_PLAN](2026-10-04_Profile_Modal_Polish_PLAN.md). UI only.
+
+| Area | Change |
+|---|---|
+| `ProfileDetailsModal.vue` | Default modal width (no `modal-lg`); name and status badge in the header; compact label : value list (Created, Expires with days remaining, Revoked, File); dates as `YYYY-MM-DD HH:mm`; 3-row note field |
+| `directives/noteTooltip.js` | `v-note-tooltip`: Bootstrap Tooltip with the note text (plain text, hover, hidden on click); recreated when the note changes, disposed on unmount |
+| `Certificates.vue` | Tooltip on the client cell in active and expired/revoked rows; muted note icon next to the name when a note exists |
+| `main.css` | `.note-tooltip` (max width 320 px, line breaks kept, light/dark theme variables), `.profile-meta` grid |
+
+Verification: `app-ui` image builds, the note icon and tooltip styles are in the bundle; layout and tooltip behaviour are checked manually.
diff --git a/DOCS/Changes/2026-10-04_Profile_Notes_PLAN.md b/DOCS/Changes/2026-10-04_Profile_Notes_PLAN.md
new file mode 100644
index 0000000..5a4dd2d
--- /dev/null
+++ b/DOCS/Changes/2026-10-04_Profile_Notes_PLAN.md
@@ -0,0 +1,29 @@
+# Profile details modal and notes: implementation plan (2026-10-04)
+
+Goal: on the **Certificates** page, rows become clickable. A click opens a modal with the main profile details and a free-text **note** that can be saved. Profiles have no note field today, so a minimal Profiler change is required to store it.
+
+## Steps
+
+### 1. Profiler backend (`APP_PROFILER/`)
+- `models.py`: `UserProfile.note = Column(Text, nullable=True)`.
+- `schemas.py`: `note: Optional[str]` in the response schema; new `UserProfileNoteUpdate` (max 1000 chars, empty string becomes `None`).
+- Startup migration: idempotent "add column if missing" step (pattern from `APP_CORE/db.py`), so existing databases do not fail with `no such column`.
+- `routers/profiles.py`: `PUT /profiles/{profile_id}/note` returns the updated profile; 404 if not found; JWT required (router-level `verify_token`). PUT is used because CORS does not allow PATCH.
+
+### 2. UI (`APP_UI/`)
+- New `src/components/ProfileDetailsModal.vue` built on `BaseModal.vue` (pattern: `NewClientModal.vue`): username, status badge, created, expiration, days remaining, revoked date, file path, note textarea, Save / Close.
+- `src/views/Certificates.vue`: clickable rows (active and expired/revoked), `@click.stop` on the download/revoke buttons, `saveNote()` via `profilesApiClient.put`, reload and toast.
+
+### 3. Tests (minimal)
+- One pytest test in `APP_PROFILER`: `PUT /profiles/{id}/note` stores the note and `GET /profiles` returns it (temporary DB, auth dependency overridden).
+- No UI tests (no test infrastructure in `APP_UI`).
+
+### 4. Build and verification (containers)
+- Tests and build run in containers; the result is deployed with `docker-compose` on this host for manual checks.
+
+### 5. Documentation
+- `DOCS/Profiler_Management/API_Reference.md`, `DOCS/General/Index.md`, `README.md` (Changes table).
+- Summary of the work: `DOCS/Changes/2026-10-04_Profile_Notes.md` (written at the end).
+
+## Out of scope
+Note history, per-user permissions, search by note, other pages.
diff --git a/DOCS/General/Index.md b/DOCS/General/Index.md
index c93c621..a5aa685 100644
--- a/DOCS/General/Index.md
+++ b/DOCS/General/Index.md
@@ -19,6 +19,8 @@ Welcome to the documentation for the OpenVPN Monitor suite.
- [Settings validation (2026-09-30)](../Changes/2026-09-30_Settings_Validation.md)
- [Privilege separation (2026-09-30)](../Changes/2026-09-30_Privilege_Separation.md)
- [Egress via Hysteria2 (2026-09-30)](../Changes/2026-09-30_Egress_via_Hysteria2.md)
+- [Profile notes (2026-10-04)](../Changes/2026-10-04_Profile_Notes.md)
+- [Async PKI init (2026-10-04)](../Changes/2026-10-04_Async_PKI_Init.md)
## 🔍 Core Monitoring (`APP_CORE`)
The core module responsible for log parsing, real-time statistics, and the primary API.
diff --git a/DOCS/Profiler_Management/API_Reference.md b/DOCS/Profiler_Management/API_Reference.md
index 532485b..9d2d64f 100644
--- a/DOCS/Profiler_Management/API_Reference.md
+++ b/DOCS/Profiler_Management/API_Reference.md
@@ -18,17 +18,23 @@ Manage OpenVPN Client profiles (`.ovpn` configs and certificates).
### `GET /profiles`
List all user profiles.
-- **Response**: Array of profile objects (id, username, status, expiration_date, etc.).
+- **Response**: Array of profile objects (id, username, status, expiration_date, note, etc.).
### `POST /profiles`
Create a new user profile.
- **Body**: `{"username": "jdoe"}`
- **Action**: Generates keys, requests certificate, builds `.ovpn` file.
+- **Response `409`**: PKI initialization is running (the PKI is not complete yet).
### `DELETE /profiles/{id}`
Revoke a user profile.
- **Action**: Revokes certificate in CRL and marks profile as revoked in DB.
+### `PUT /profiles/{id}/note`
+Set or clear the free-text note of a profile.
+- **Body**: `{"note": "text"}` (max 1000 characters; empty or `null` clears the note)
+- **Response**: Updated profile object (including `note`). `404` if the profile does not exist.
+
### `GET /profiles/{id}/download`
Download the `.ovpn` configuration file for a user.
- **Response**: File stream (application/x-openvpn-profile).
@@ -53,11 +59,20 @@ Update PKI settings (e.g., Key Size, Certificate Expiry).
- **Body**: JSON object matching `PKISetting` schema.
### `POST /system/init`
-Initialize the PKI infrastructure (InitCA, GenDH, BuildServerCert).
-- **Note**: Only runs if PKI is empty.
+Start PKI initialization (init-pki, CA, server certificate, DH, TLS key, CRL) as a background job. Returns immediately.
+- **Response `202`**: `{"state": "running"}`
+- **Response `409`**: a job is already running, or the PKI is already complete (`ca.crt`, `dh.pem`, `ta.key`, `crl.pem` and the server certificate). An incomplete PKI left by an interrupted run is removed and initialization starts again.
+- **Note**: Job state is kept in memory; the Profiler must run as a single process (one uvicorn worker). After a restart the state is `idle`.
+
+### `GET /system/init/status`
+Current state of the initialization job.
+- **Response**: `{ "state": "idle|running|done|error", "step": "init-pki|ca|server-cert|dh|ta-key|crl|null", "initialized": true, "started_at": "2026-10-04T10:00:00Z", "finished_at": null, "error": null }`
+- `initialized` reflects the files on disk (complete PKI), independent of `state`.
+- `error` contains the EasyRSA message when `state` is `error`.
### `DELETE /system/pki`
-**DANGER**: Completely wipes the PKI directory.
+**DANGER**: Completely wipes the PKI directory and resets the job state.
+- **Response `409`**: an initialization job is running.
---
diff --git a/README.md b/README.md
index bd73ba8..bc84aa3 100644
--- a/README.md
+++ b/README.md
@@ -61,6 +61,8 @@ No default user is created. Seed the initial admin with `OVPMON_INITIAL_ADMIN_US
| 2026-09-30 | Validation of server/PKI settings (config injection into the root-written OpenVPN config) | [Settings validation](DOCS/Changes/2026-09-30_Settings_Validation.md) |
| 2026-09-30 | API services run as an unprivileged user; root helper validates and installs the OpenVPN config, publishes the CRL | [Privilege separation](DOCS/Changes/2026-09-30_Privilege_Separation.md) (includes CRL publishing for `crl_verify`) |
| 2026-09-30 | Route OpenVPN clients through a Hysteria2 tunnel to an exit node | [Egress via Hysteria2](DOCS/Changes/2026-09-30_Egress_via_Hysteria2.md) |
+| 2026-10-04 | Certificates page: clickable rows, profile details modal with a saved note (`PUT /profiles/{id}/note`) | [Profile notes](DOCS/Changes/2026-10-04_Profile_Notes.md) (includes the compact modal and the note tooltip on the client name) |
+| 2026-10-04 | PKI initialization runs in the background: status endpoint, progress on the PKI page, protection against a second start | [Async PKI init](DOCS/Changes/2026-10-04_Async_PKI_Init.md) |
## Notes