Skip to content

Add live data updates system for admin panels and comprehensive session management system for admin interface - #6

Merged
ddon merged 18 commits into
BeamLabEU:devfrom
timujinne:dev
Sep 2, 2025
Merged

Add live data updates system for admin panels and comprehensive session management system for admin interface#6
ddon merged 18 commits into
BeamLabEU:devfrom
timujinne:dev

Conversation

@timujinne

Copy link
Copy Markdown
Contributor

Add live session control

Add profile changeset function and complete profile editing interface
with first name and last name fields. Includes validation and update
handlers for improved user experience.
Remove unnecessary redirect pipe for login route and add admin
shortcut route for improved navigation. Consolidates authentication
flow and enhances admin dashboard accessibility.
Add profile settings functionality and fix router integration.
Update version references in README and add detailed changelog
entry for new features and improvements.
Add profile settings and fix router integration
Implements real-time data synchronization across all admin interfaces
using isolated PubSub system for Users, Roles and Dashboard statistics.
Key features:
- PhoenixKit.PubSub.Manager: Autonomous PubSub system with lazy initialization
- PhoenixKit.Admin.Events: Centralized event broadcasting API
- Live updates for Users table (creation, updates, role changes)
- Live updates for Roles table (CRUD operations)
- Live updates for Dashboard statistics
- Graceful degradation when database unavailable
- Zero configuration - works independently of parent application
- Complete isolation from parent application PubSub
Technical implementation:
- GenServer-based PubSub manager with automatic startup
- LiveView subscriptions with handle_info event handlers
- Broadcasting integrated into Auth and Roles contexts
- Safe error handling for missing repository configuration
Testing: Comprehensive test suite validates all event types
Documentation: LIVE_UPDATES_README.md with setup and usage guide
Features:
- Complete session monitoring with active/expired session tracking
- Real-time session statistics dashboard with live updates
- Session revocation controls for individual and bulk operations
- Admin navigation integration with sessions sidebar menu
- PubSub events system for real-time session state updates
- Modern responsive UI with search, filtering, and pagination
- Security-focused design with token preview instead of full tokens
- Professional dashboard statistics cards with gradient design
Technical implementation:
- PhoenixKit.Users.Sessions context for session management
- SessionsLive component with real-time event subscriptions
- Admin events system extension for session broadcasting
- Navigation integration in admin sidebar and dashboard cards
- PostgreSQL optimized queries with proper session validation
- Role-based access control (Owner/Admin only)
- Fix alphabetical ordering of module aliases across all files
- Refactor nested function in update_user_status to reduce complexity
- Add implicit try-rescue pattern instead of explicit try blocks
- Improve module aliasing for better readability
- Remove trailing whitespace from test files
- Optimize PubSub event broadcasting for better error handling
These changes resolve all Credo warnings and improve maintainability
without affecting existing functionality.
Add automatic session termination when user roles are modified to ensure
permissions are updated immediately and prevent stale cached roles in user sessions.
- Add log_out_user_from_all_sessions/1 to PhoenixKitWeb.Users.Auth
- Add delete_all_user_session_tokens/1 and get_all_user_session_tokens/1 to Auth context
- Modify assign_role_internal/3, remove_role/2, and sync_user_roles/2 to trigger logout
- Force re-authentication after role changes for security
- Broadcast LiveView session disconnects to active user sessions
- Update role assignment tests to reflect function signature changes
This ensures role changes take effect immediately across all user sessions
and devices without requiring manual re-login prompts.
@ddon
ddon merged commit 99e928a into BeamLabEU:devSep 2, 2025
ddon pushed a commit that referenced this pull request Nov 12, 2025
…s-011CV2SvaLHQuUUHsv8RxWnm
Add configurable placeholder log creation with improved tracking
ddon pushed a commit that referenced this pull request Nov 12, 2025
This merge brings in the latest changes from dev (V16-V21 migrations) and adds V22 migration with additional email system improvements.
## What's New in V22
### Database Schema Enhancements
- Add aws_message_id field to phoenix_kit_email_logs (nullable, unique when present)
- Add bounced_at, complained_at, opened_at, clicked_at timestamps to email_logs
- Add partial unique index on aws_message_id (WHERE aws_message_id IS NOT NULL)
- Add composite index (message_id, aws_message_id) for fast correlation
- Add composite index (email_log_id, event_type) for 10-100x faster duplicate checks
### New Tables
- phoenix_kit_email_orphaned_events - Track SQS events without matching logs
- phoenix_kit_email_metrics - Track system metrics (extraction rates, placeholder logs)
### Documentation
- Add comprehensive Message ID Strategy documentation in EmailLog module
- Explain dual ID system: message_id (internal) vs aws_message_id (provider)
- Document workflow and search priority for event correlation
## Changes from Dev Branch
The dev branch already includes many improvements that were originally planned:
- ✅ Duplicate event checks for ALL event types (PR #5)
- ✅ Template variable validation (PR #8)
- ✅ RateLimiter stub function implementations
- ✅ AWS message_id extraction improvements (PR #7)
- ✅ Placeholder email log handling (PR #6)
## Migration Path
Run `mix phoenix_kit.update` to apply V16-V22 migrations in sequence.
## Database Constraints
- message_id: UNIQUE NOT NULL (existing)
- aws_message_id: PARTIAL UNIQUE WHERE aws_message_id IS NOT NULL (new)
- Composite indexes for faster searches and event deduplication
## Backward Compatibility
All changes are backward compatible:
- Existing logs work with both message_id strategies
- New fields are nullable
- Indexes use create_if_not_exists for idempotency
mdon added a commit to mdon/phoenix_kit that referenced this pull request May 5, 2026
…follow-up)
Closes NITPICK BeamLabEU#10 from CLAUDE_REVIEW.md on PR BeamLabEU#511. The lenient `:ok`
return on the missing-state branch of verify_oauth_state/2 dated from
an older flow that didn't always save state before redirect; that flow
is gone (every connect_oauth event now calls save_oauth_state/2 first
at integration_form.ex:227). A missing state at callback time now
implies either someone bypassed connect_oauth or the row was mutated
between authorize and callback — both are CSRF-relevant. Returns
{:error, :state_mismatch} on that branch with an updated comment
explaining why.
No tests exercised the lenient branch (verified via grep). The
{:error, :state_mismatch} return shape is already handled by the
caller's existing mismatch case.
FOLLOW_UP.md updated to reflect the closure (moves from Skipped to
Fixed Batch 1; NITPICK BeamLabEU#6 stays Open pending Max's decision).
mdon added a commit to mdon/phoenix_kit that referenced this pull request May 5, 2026
… follow-up)
Closes NITPICK BeamLabEU#6 from CLAUDE_REVIEW.md on PR BeamLabEU#511, but as a code fix
rather than the doc-note the reviewer suggested. The picker was
rendering provider name in place of `conn.name` whenever
`conn.name == "default"` (a pre-BeamLabEU#511 carryover from when `default` was
system-privileged). PR BeamLabEU#511's own moduledoc explicitly says "Names are
pure user-chosen labels with no system semantics" — the picker
contradicting that is the actual bug.
Now always renders `conn.name` verbatim. Provider badge is also
unconditional (drop the `conn.name != "default"` guard) so users
always see which provider they're picking regardless of how the
connection is named.
Only call site of the substitution; no other surface depended on it.
Two test references to `name == "default"` are persistence assertions,
not picker rendering — unaffected.
FOLLOW_UP.md updated: NITPICK BeamLabEU#6 moves to Fixed (Batch 1); Open is now
None.
ddon pushed a commit that referenced this pull request May 12, 2026
Code (PR #537 review items addressed):
- #1 BUG-MEDIUM: wrap `Annotations.delete/1` in `Repo.transaction/1` so
comment-cascade + annotation-delete are atomic. Extracted into
`delete_in_transaction/1` to keep the body flat (credo depth).
- #2 BUG-MEDIUM: sweep stale `resource_type = "annotation"` claims
across 3 moduledocs (annotation.ex, v115.ex, etcher_adapter.ex). The
implementation anchors comments to the file with
`metadata.annotation_uuid` — docs now match reality.
- #5 BUG-LOW: narrow `delete_linked_comments` rescue to expected
exception classes ([DBConnection.OwnershipError, Postgrex.Error,
ArgumentError]) so logic bugs surface instead of being swallowed.
- #11 IMPROVEMENT-LOW: drop `normalize/1` — `Ecto.Changeset.cast/3`
handles both atom- and string-keyed maps natively; the helper added
silent failure-mode risk on typo'd keys.
- #12 IMPROVEMENT-LOW: drop in-repo `Code.ensure_loaded?(PhoenixKit.Annotations)`
guard in MediaBrowser — Annotations is a core module, can't be
missing.
- #19 NITPICK: drop `PhoenixKit.Modules.Storage` from
AnnotationComposer's `@compile no_warn_undefined` (it's core, not
optional — rename should fail loudly).
- #20 NITPICK: simplify `AnnotationComposerPosition.destroyed` guard.
- #21 NITPICK: fix misleading "Etcher's bootstrap uses `||` to preserve
pre-existing slots" comment — PhoenixKit's JS owns the slots.
- #8 IMPROVEMENT-MEDIUM: gettext-wrap ~17 user-facing strings in
AnnotationComposer (flash messages + heex literals + ARIA labels).
Credo / dialyzer:
- Alias `PhoenixKit.Annotations`, `PhoenixKit.Modules.Storage`,
`PhoenixKit.Modules.Storage.EtcherAdapter`, `Storage.File` so the
six "nested modules could be aliased" findings clear.
- Convert `first_attachment_thumbnail/1`'s single-clause `with` to
`case` (credo readability).
- Add PhoenixKitComments-targeted entries to .dialyzer_ignore.exs for
the annotations context + composer (optional sibling package,
guarded at runtime).
- mix.lock picks up `etcher 0.1.0` via deps.get.
mix precommit: compile → format → credo --strict → dialyzer all clean.
Deferred to original author (Alex): #3 (race), #4 (upload rollback),
#6 (authz), #7 (schema-as-source), #9 (geometry validation), #10
(configurable component id), #13/#14 (locale-aware date + traverse_errors),
plus cosmetics #15-18, #22, #23. Disposition table in CLAUDE_REVIEW.md
updated separately.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ddon pushed a commit that referenced this pull request May 12, 2026
Code (PR #538#1 — carry-over from PR #536 follow-up):
- V114 down SQL: switch the collision-suffix source from
`substring(uuid::text from 1 for 8)` (UUIDv7 timestamp prefix — same
millisecond ⇒ identical prefix ⇒ duplicate suffixed keys when two+
rows collide on (provider, name)) to `substring(uuid::text from 25
for 8)` (the post-variant random tail, 32 bits of entropy ⇒ 1-in-4B
collision probability per pair). Mirrored in `run_down!` in
`v114_test.exs` since the test duplicates the SQL.
- V114 moduledoc updated to spell out the suffix source and why the
timestamp prefix was wrong.
The fix is forward-compat: systems that already ran V114.down get the
old (potentially-collided) keys; fresh installs and any future
rollback get the corrected behavior.
Docs (PR #538#6):
- AGENTS.md TODO entry for `<.draggable_list>` test coverage widened
to call out the new `:sortable_handle` axis: three branches
(`:draggable=false`, `:draggable=true + sortable_handle=nil`,
`:draggable=true + sortable_handle=".pk-drag-handle"`).
Plus a one-line `mix format` normalization in V116 (multi-line
`execute(...)` collapsed to single line).
mix precommit: compile → format → credo --strict (0 findings) →
dialyzer (160 errors all skipped) clean.
Deferred to maintainer: #2 / #3 / #5 (cosmetics on deployed
migrations), #4 (DB-level self-loop CHECK — needs a V117), #7
(`sortable_handle` typo safety — design call on boolean shape vs
JS warning).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ddon pushed a commit that referenced this pull request Aug 9, 2026
1.7.237 ships SIX PRs, not the four I had reviewed. #689 (the migration squash)
and #690 (security-p1 + the #689 review fixes) merged before this session and
had no CHANGELOG entry at all; #694 had none either.
#689 already had a CLAUDE_REVIEW.md from an earlier pass. Appended a second
pass rather than redoing it: its five mechanical findings are fixed (verified
in #690), blocker #6 is still open and still needs a database, and blocker #7
— the module ecosystem being unable to resolve 2.0 — is DISSOLVED by shipping
as a patch release. Re-verified all seven pins in /workspace: every one is
`~> 1.7.x`, which accepts 1.7.237 and rejects 2.0.0.
That matters more than it sounds, because the first pass recommended 2.0.0 and
I bumped to 1.7.237 before reading it. The override was accidental, so the
trade is now written down: 1.7.237 breaks no module but lets a below-floor host
be dragged across the floor by a routine `mix deps.update`; 2.0.0 prevents that
but makes `mix deps.get` unsatisfiable for every host running a feature module.
I think 1.7.237 is right — a refused migration with a precise remedy beats a
dependency resolver refusing to resolve — but only if the requirement is
impossible to miss, so the CHANGELOG now LEADS with it instead of listing it.
#690 reviewed clean; no new defects. Verified the pg_has_role fix (immediate
query, parameterized, absent function falls through to queue) and specifically
checked that the bridge_version fix reached every raise site — it does, because
the :ensure_current path re-raises the existing struct.
CHANGELOG now covers #689 through #694.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
ddon pushed a commit that referenced this pull request Aug 10, 2026
Post-merge review of #700, which is billed as small docs work and contains two
commits that close release blockers: the hand-declared V165/V166 manifest
entries are corrected to Postgres' deparsed form (found by running verify
against a live PG 17.6 install, where s8 had been failing on exactly those four
wrong_shape findings), and the S1/S2 squash-equivalence references are
regenerated at chain v166, closing #689's blocker #6.
I verified the manifest diagnosis against Postgres' deparsing rules rather than
the commit message: the copied predicate came from an index whose status column
is varchar (v135.ex:8360, hence the (status)::text cast) while access_requests'
and comments' are text (v165.ex:112, v166.ex:56, hence no cast). chain_hash is
correctly untouched — it hashes v*.ex, not the manifest — and release_check
still passes.
One finding. #700's stated goal is zero dead links in the 2.0 hexdocs, and its
accounting is exactly right as far as it counts: 0 undefined references, and the
54 remaining "hidden" warnings are 28 module + 26 function, all deliberate. But
mix docs also emits two warnings of a third class it does not mention —
`references file "url"` — from a @doc that writes [links](url) as an
illustration of supported syntax. ExDoc reads it as a real link and publishes
<a href="url">, which 404s from the hexdocs page: a genuine dead link of exactly
the kind the commit set out to remove, which survived because it is a file
reference rather than an undefined one. Backticked, which also reads better
since the sentence is describing syntax.
mix docs is now 0 undefined, 0 broken file references, 54 hidden.
Two of the three caveats I had been repeating are closed by this PR: the
manifest body HAS now been checked against a live database, and the equivalence
evidence DOES now cover the current chain. Remaining: the module pin wave, and a
full mix test on a machine with PostgreSQL.
Review: dev_docs/pull_requests/2026/700-docs-references-and-squash-evidence/CLAUDE_REVIEW.md
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@timujinne@ddon