Blame

82654c Claude (MCP) 2026-03-18 18:25:40
[mcp] Add spec for dashboard visibility toggle (READ_ACCESS control)
1
---
2
category: spec
3
tags:
4
- design
5
- dashboard
6
- permissions
7
- ux
8
last_updated: 2026-03-18
9
confidence: high
10
---
11
12
# Dashboard Visibility Toggle
13
14
## Problem
15
16
Wiki permissions (READ_ACCESS, WRITE_ACCESS, ATTACHMENT_ACCESS) are managed in the otterwiki admin panel at `/-/admin/permissions_and_registration`. This is buried and unfamiliar to new users. The most common permission change — controlling who can *read* the wiki — should be accessible from the platform dashboard.
17
18
The platform previously had an `is_public` flag in the `wikis` table that overlaid the per-wiki permissions, causing confusion when the two disagreed. That flag is now inert. This spec replaces it with a dashboard control that writes directly to the per-wiki DB — single source of truth, no overlay.
19
20
## Design
21
22
Add a **visibility selector** to the wiki settings card on the platform dashboard (`/app/`). Three states:
23
24
| Label | READ_ACCESS value | Meaning |
25
|---|---|---|
26
| **Private** | `APPROVED` | Only the owner and explicitly approved users can read |
27
| **Logged in** | `REGISTERED` | Any authenticated platform user can read |
28
| **Public** | `ANONYMOUS` | Anyone on the internet can read |
29
30
Default for new wikis: **Private** (APPROVED).
31
32
The selector controls `READ_ACCESS` only. WRITE_ACCESS and ATTACHMENT_ACCESS remain independent, managed via the otterwiki admin panel. This matches common wiki patterns (e.g., public read + restricted write).
33
34
## Mechanism
35
36
### Read
37
38
Open a raw `sqlite3` connection to `{wiki_dir}/wiki.db`:
39
40
```sql
41
SELECT value FROM preferences WHERE name = 'READ_ACCESS'
42
```
43
44
Map the value to the three-state selector. If the value is missing or unrecognized, default to "Private."
45
46
### Write
47
48
On selector change:
49
50
```sql
51
INSERT OR REPLACE INTO preferences (name, value) VALUES ('READ_ACCESS', ?)
52
```
53
54
Before writing, call `_init_wiki_db()` to ensure the DB and `preferences` table exist. This is already idempotent.
55
56
### Staleness
57
58
After a direct write to `wiki.db`, otterwiki workers with that wiki already loaded won't see the change until their next request triggers `_swap_database()``update_app_config()`. This is pre-existing behavior — the same staleness applies to changes made via the otterwiki admin panel. No new issue.
59
60
## Implementation
61
62
### Files to change
63
64
- **`app/api_server.py`**: Add a helper to read `READ_ACCESS` from a wiki's DB. Add a POST handler to update it. The dashboard GET already loads wiki data — extend it to include current visibility state.
65
- **`app/management/templates/wiki_settings.html`**: Add a visibility selector card (three radio buttons or a segmented control) above the existing MCP section.
66
- **`app/resolver.py`**: No changes needed. The resolver already reads `READ_ACCESS` from the per-wiki DB on each request.
67
68
### UI placement
69
70
The visibility selector goes in the wiki settings card on the dashboard, prominently placed (above MCP details). Label: "Visibility" with the three options and a one-line explanation of each.
71
72
### What NOT to do
73
74
- Do NOT add a column to the platform `wikis` table. The selector reads and writes `wiki.db` directly.
75
- Do NOT import otterwiki models. Use raw `sqlite3`, same as `_init_wiki_db()`.
76
- Do NOT change WRITE_ACCESS or ATTACHMENT_ACCESS from this control. Those are independent.
77
78
## Edge cases
79
80
- **Visibility changed via otterwiki admin panel**: The dashboard will reflect the current DB value on next load. No conflict — single source of truth.
81
- **wiki.db doesn't exist yet**: Call `_init_wiki_db()` before reading. It's idempotent.
82
- **Unrecognized READ_ACCESS value**: Display as "Private" (safest default).
83
84
## Relationship to otterwiki admin panel
85
86
The dashboard toggle and the otterwiki admin panel write the same `preferences` row. They are two UIs for the same field. The dashboard is simpler (one control for the most common operation); the admin panel is comprehensive (all three access controls, all four levels including ADMIN).
87
88
The [[Administration]] default wiki page directs users to the admin panel for full permission control. The dashboard toggle is a convenience shortcut.