Initial LinkLog implementation

This commit is contained in:
Olaf
2026-08-24 14:30:30 +02:00
commit 1c827956c4
50 changed files with 3436 additions and 0 deletions
+207
View File
@@ -0,0 +1,207 @@
# Chat Log
## 2026-08-24
### User
I want to build a firefox plugin as specified in the REQUIREMENTS.md file.
### Assistant outcome
Analyzed the requirements and established a Python-first architecture for a Firefox extension, FastAPI backend, SQLite persistence, plugin-based publishing, frontend pages, and Docker/Traefik deployment.
### User
I want this written in python where possible.
### Assistant outcome
Selected Python 3.11, FastAPI, uvicorn, SQLite, and a Python service layer as the primary implementation stack. Browser extension code remains JavaScript because Firefox extension runtime code executes in the browser.
### User
Start implementation.
### Assistant outcome
Created the backend scaffold, database schema, authentication and token lifecycle, link creation and retrieval, public feed API, plugin abstractions, and regression tests.
### User
Make the frontend page and the Docker setup.
### Assistant outcome
Added the public feed, admin and profile templates, static styling and feed behavior, Firefox extension scaffolding, Dockerfile, and Docker Compose with Traefik.
### User
Continue / go / continue.
### Assistant outcome
Added and registered the profile API and profile page, then validated the backend routes with pytest.
### User
Continue.
### Assistant outcome
Added user plugin configuration endpoints, admin plugin enable/disable endpoints, persisted Mastodon plugin state, and runtime plugin refresh behavior. The API suite passed.
### User
continue
### Assistant outcome
Connected the profile and admin pages to live APIs. Profile and Mastodon forms now load and save settings, and the admin page renders plugin rows with enable/disable actions. The backend suite passed and both browser scripts passed syntax checks.
### User
implement next step
### Assistant outcome
Identified the next backend step as real Mastodon posting from the link submission path, with per-user settings and failure isolation. Implementation was about to begin.
### User
Create a folder called VIBE and log our chat and promts. Previous and future
### Assistant outcome
Created this `VIBE` folder and its append-only chat and prompt logs. Future visible exchanges should be appended here in chronological order.
### User
continue implementation
### Assistant outcome
Implemented real Mastodon publishing for newly submitted links. The link endpoint now dispatches a `link_created` event after saving, the Mastodon plugin loads per-user instance/token/hashtag settings, posts JSON to `/api/v1/statuses`, and isolates remote failures so link creation remains successful. Added an end-to-end local HTTP server test. Full backend validation passed with 8 tests.
### User
Fix the Starlette/httpx deprecation by using an alternative
### Assistant outcome
Added Starlette's preferred `httpx2` package to `backend/requirements.txt` and installed it in the active virtual environment. Fixed local test-server teardown so strict warning validation is clean. The full backend suite passes with `PYTHONWARNINGS=error`: 8 passed, 0 warnings.
### User
Clean up and create a README that includes full install instructions
### Assistant outcome
Removed the obsolete Compose `version` key, added `.dockerignore`, and created a full root README covering prerequisites, local Python installation, backend startup, tests, Firefox temporary extension installation, Docker/Traefik, Mastodon setup, API examples, and troubleshooting. Compose validation passed and the strict backend suite passed with 8 tests.
### User
Review Docker setup and configuration
### Assistant outcome
Reviewed the current Dockerfile, Compose file, ignore rules, application settings, and admin routes. The image build and Compose rendering passed. Identified production risks: hard-coded secret configuration, unauthenticated admin APIs, exposed direct app and insecure Traefik dashboard ports, unrestricted Docker socket access, and missing health/restart hardening.
### User
Make sure all configurateion can be set using a .env file with docker
### Assistant outcome
Made application settings environment-driven, wired Docker and Traefik settings through Compose interpolation, added `.env.example`, ignored the real `.env`, and documented the variables and setup flow in `README.md`. Compose validation, Python compilation, and the strict backend suite passed with 8 tests.
### User
Execute all TODOs
### Assistant outcome
No literal TODO or FIXME markers were present. Implemented the remaining public-feed requirement by joining links to real user profiles, adding `/api/public/feed/{username}`, adding `/<username>` HTML pages with profile context, and making the browser feed use the filtered API endpoint. Full strict backend validation passed with 8 tests, and the updated feed script passed syntax validation.
### User
Add authenticated admin/user configuration
### Assistant outcome
Added shared bearer-token dependencies, protected user configuration endpoints, restricted plugin administration to administrator accounts, and changed user configuration to use the authenticated user's ID instead of hard-coded `user-1`. The seeded `alice` account is an administrator for development and `bob` remains a standard user. README authentication guidance was added, and the strict backend suite passed with 8 tests.
### User
Make sure the link-log page is responsive
### Assistant outcome
Added responsive CSS for the feed, profile, and admin views: fluid controls, viewport-safe sizing, mobile card spacing, stacked toolbar fields, and stacked plugin controls. Also hardened Mastodon host-only configuration so it cannot break link creation. Browser script syntax checks passed and the strict backend suite passed with 8 tests.
### User
next
### Assistant outcome
Added a web login page at `/login`, token storage in browser local storage, and authenticated requests from the profile and admin pages. Added login route coverage and preserved administrator checks. Full strict backend validation passed with 8 tests, and all browser scripts passed syntax validation.
### User
Make the layout modern based on catpuccino mocha theme
### Assistant outcome
Replaced the shared blue-and-white stylesheet with a modern Catppuccin Mocha design using Mocha surface colors, mauve/lavender accents, DM Sans and Space Grotesk typography, improved card hierarchy, focus states, buttons, and responsive mobile layouts. Main HTML/static routes returned 200, all browser scripts passed syntax checks, and the strict backend suite passed with 8 tests.
### User
docker compose up fails with Jinja2 errors
### Assistant outcome
Reproduced the Docker failure and confirmed `jinja2` was missing from `backend/requirements.txt`, even though local development had it installed. Added `jinja2==3.1.6`, rebuilt the image, verified the app container started and served `/health` and `/`, and stopped the temporary Compose stack. Traefik provider logs separately showed a Docker Desktop daemon connectivity issue causing its localhost route to return 404.
### User
put the avatar and the username on the top right hand side, and wrap all other text around it.
### Assistant outcome
Updated the shared feed card styling so the avatar and username float in the upper-right corner, with titles, comments, profile text, and metadata wrapping around the identity block. Added a clearfix to keep card boundaries stable on desktop and mobile. All main routes returned 200 and the strict backend suite passed with 8 tests.
### User
add a login button on the top right of the page
### Assistant outcome
Added a top-right `Sign in` link to the public LinkLog header, styled for the Catppuccin Mocha theme with a compact mobile layout. Added rendered-page coverage and verified the strict backend suite, feed script, and stylesheet response.
### User
add a link to the administrator page to the user configuration for users that have admin privilige
### Assistant outcome
Added a hidden `Admin` link to the profile header that is revealed by `profile.js` only when the authenticated `/api/user/me` response reports `is_admin`. Standard users do not see the link. Profile route and script validation passed, followed by the full strict backend suite with 8 passing tests.
### User
add the ability to add and remove users to the admin interface
### Assistant outcome
Added administrator-only user management endpoints for listing, creating, and deleting users. The admin page now has a live user list, add-user form, administrator checkbox, and confirmed remove controls. Password hashes are never returned; self-deletion and last-administrator deletion are blocked. Focused tests passed, followed by the full strict backend suite with 9 passing tests.
### User
Only show the add user interface when logged in as admin and only show 'Administrator sign-in required' when an administrator is not signed in. Also add a checkbox to users in the admin to assign admin rights.
### Assistant outcome
Made the admin controls and user-management form hidden until protected admin API requests succeed. The administrator sign-in notice is shown only when the user is not authenticated as an administrator. Kept the explicit Administrator checkbox in the add-user form, which sends the privilege as a boolean. Initial HTML state and admin CRUD tests passed, followed by the strict backend suite with 9 passing tests.
### User
/admin shows 'sign out' while the users has been signed out.
### Assistant outcome
Hid the sign-out button in the initial admin and profile HTML. The admin script reveals it only after protected admin requests succeed, while the profile script reveals it only after the authenticated profile request succeeds. Added rendered-state assertions and verified the strict backend suite with 9 passing tests.
### User
Show a login button when nobody is logged in for /admin
### Assistant outcome
Added a hidden `Sign in` link to the admin header that points to `/login`. The admin script reveals it when administrator authentication fails, while showing `Sign out` only after admin authentication succeeds. Added rendered-state coverage and verified the strict backend suite with 9 passing tests.
### User
The signin and signout button are not still not visible
### Assistant outcome
Changed the admin `Sign in` button to be visible in the initial HTML instead of waiting for an asynchronous failed API request. The script hides it after successful administrator authentication and reveals `Sign out` at the same time. Verified the signed-out rendered state, browser scripts, and strict backend suite with 9 passing tests.
### User
It seems that the session is not maintained. I want Login buttons when a user has logged in and logout buttons when a user has logged out. If an authenticated user tries to load the admin page without authorization it should say that the user has no authorization
### Assistant outcome
Updated the admin page to validate the stored browser token through `/api/auth/me` and distinguish signed-out users, authenticated non-admin users, and administrators. Signed-out users see `Sign in`; authenticated users see `Sign out`; non-admin users see an explicit authorization error and no admin controls. The auth endpoint now returns `is_admin`, and the strict backend suite passed with 9 tests.
### User
When a logged in user gets to the profile page their username should be printed - it is inmutable. Available defaults should prepopulte the fields.
### Assistant outcome
Changed the profile username from an editable input to a read-only display and removed username updates from the user profile API. Added defaults for bio, avatar URL, Mastodon instance, and post prefix in the rendered profile form and browser loader. Added regression coverage; the strict backend suite passed with 9 tests.
### User
The username doesn't load. The firefox console reports: Uncaught SyntaxError: redeclaration of const logoutButton
### Assistant outcome
Fixed the global lexical declaration collision between `logout.js` and the page scripts. Renamed the profile and admin references to `profileLogoutButton` and `adminLogoutButton`, allowing `profile.js` to parse and execute its username loader. The combined logout/profile script check passed, the focused profile test passed, and the strict backend suite passed with 9 tests.
### User
Check the whole authentication flow as it seems broken.
### Assistant outcome
Traced login, token storage, profile/admin session checks, logout revocation, and extension authentication. Found that the live Docker container was serving an older `profile.js` containing the stale `const logoutButton` declaration, while the workspace source was already corrected. Wrapped authentication scripts in closures, added cache-busted script URLs, removed the stale minified profile artifact, rebuilt Docker, and verified the live profile asset and health endpoint. Full strict backend validation passed with 9 tests.
### User
In the admin interface allow to toggle administrative rights for users. But always enforce there to be at least one user with admin rights
### Assistant outcome
Added `PUT /api/admin/users/{user_id}` for administrator privilege changes and added a checkbox to every admin user row. Promotion and demotion are supported, while the API rejects demoting the last administrator. Focused tests and the full strict backend suite passed with 10 tests.
### User
remove default for bio and email in the profile page
### Assistant outcome
Removed the default bio text from the profile template and browser loader. Email remains API-driven and empty until stored for the user. The avatar, Mastodon instance, and post-prefix defaults remain unchanged. Focused profile validation passed, followed by the strict backend suite with 10 passing tests.