Skip to content

feat(audit-log): dashboard audit log system with slideover UI#144

Draft
Copilot wants to merge 32 commits intomainfrom
copilot/create-log-system-for-changes
Draft

feat(audit-log): dashboard audit log system with slideover UI#144
Copilot wants to merge 32 commits intomainfrom
copilot/create-log-system-for-changes

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 11, 2026

Adds a persistent audit trail for guild settings changes — tracks who modified what, when, with before/after values. Surfaces this via an Activity Log slideover in the dashboard (based on the Nuxt UI dashboard NotificationsSlideover pattern).

Database

  • New AuditLog Prisma model with composite index on (guild_id, created_at DESC) and FK to guilds
  • Single squashed SQL migration creating the final audit_log table directly

Server

  • GET /api/guilds/[guild]/audit-logs — paginated, auth-gated (defineWrappedResponseHandler, no caching to enforce auth on every request), rate-limited
  • PATCH /api/guilds/[guild]/settings — now records audit entries on write, capturing old/new values per key via pre-mutation snapshot. Section derived from key prefix using majority-vote across all changed keys (permissions*, selfmod*/noMentionSpam* → moderation, channels*, roles*, etc.). Audit write is fire-and-forget to avoid blocking the settings response.

Shared

  • AuditLogChange / AuditLogEntry types, AuditLogQuerySchema (valibot with unknown() → transform(Number) coercion for query string params), PrismaJson.AuditLogChanges

Frontend

  • useAuditLog composable — lazy fetch with reactive function-based cache key, returns entries + total
  • AuditLogSlideover.vue — section-specific icons, relative timestamps, member name + avatar display, change key badges (capped at 3 + overflow), loading/empty states, lazy fetch (immediate: false) with auto-refresh on slideover open via watch
  • Recent Activity section in General.vue showing last 5 audit log entries inline (audit log only, no moderation cases)
  • Integrated into manage.vue navbar (bell icon, N shortcut)
// Section derivation from settings keys (majority-vote)
channelsLogsModeration → "channels"
selfmodLinksEnabled    → "moderation"
permissionsRoles      → "permissions"
rolesAdmin            → "roles"

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 11, 2026

Deploy Preview for wolfstar-rocks-et34281 ready!

Name Link
🔨 Latest commit 94a3d8d
🔍 Latest deploy log https://app.netlify.com/projects/wolfstar-rocks-et34281/deploys/69e63a34fa2f4c000898f92b
😎 Deploy Preview https://deploy-preview-144.wolfstar.rocks
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 82 (no change from production)
Accessibility: 100 (no change from production)
Best Practices: 100 (no change from production)
SEO: 94 (no change from production)
PWA: 90 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

Copilot AI and others added 7 commits April 11, 2026 19:43
- Add AuditLogChange and AuditLogEntry interfaces in shared/types/audit-log.ts
- Add AuditLogQuerySchema valibot schema in shared/schemas/audit-log.ts
- Add AuditLogChanges type to PrismaJson namespace
- Export new modules from barrel files

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: RedStar071 <76824516+RedStar071@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: RedStar071 <76824516+RedStar071@users.noreply.github.com>
Add a composable for fetching guild audit log data from the API.
Uses useRouteParams for guild ID and useLazyAsyncData for data fetching,
with an optional immediate parameter to control fetch timing.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: RedStar071 <76824516+RedStar071@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: RedStar071 <76824516+RedStar071@users.noreply.github.com>
- Add DashboardAuditLog model to Prisma schema
- Add shared types (AuditLogChange, AuditLogEntry) and valibot schemas
- Create GET /api/guilds/[guild]/audit-logs endpoint
- Modify PATCH settings endpoint to record audit log entries
- Create useAuditLog composable
- Create AuditLogSlideover Vue component
- Integrate into manage.vue with Activity Log button

Agent-Logs-Url: https://github.com/wolfstar-project/wolfstar.rocks/sessions/ece5c6cc-9c86-4ee6-895a-4df3200df49f

Co-authored-by: RedStar071 <76824516+RedStar071@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: RedStar071 <76824516+RedStar071@users.noreply.github.com>
Copilot AI changed the title [WIP] Add logging system for modifications and notifications feat(audit-log): dashboard audit log system with slideover UI Apr 11, 2026
Copilot AI requested a review from RedStar071 April 11, 2026 20:08
@sentry
Copy link
Copy Markdown

sentry Bot commented Apr 11, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 45 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.34%. Comparing base (3e5e8a9) to head (94a3d8d).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
app/utils/audit-log.ts 0.00% 16 Missing and 8 partials ⚠️
app/components/guild/settings/General.vue 50.00% 10 Missing and 2 partials ⚠️
app/components/LoadingSpinner.vue 45.45% 6 Missing ⚠️
app/components/ActivitySection.vue 83.33% 2 Missing ⚠️
app/composables/useAuditLog.ts 94.44% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #144      +/-   ##
==========================================
- Coverage   67.17%   65.34%   -1.83%     
==========================================
  Files          77       83       +6     
  Lines        1916     2037     +121     
  Branches      577      625      +48     
==========================================
+ Hits         1287     1331      +44     
- Misses        498      559      +61     
- Partials      131      147      +16     
Files with missing lines Coverage Δ
shared/schemas/audit-log.ts 100.00% <100.00%> (ø)
app/composables/useAuditLog.ts 94.44% <94.44%> (ø)
app/components/ActivitySection.vue 83.33% <83.33%> (ø)
app/components/LoadingSpinner.vue 45.45% <45.45%> (ø)
app/components/guild/settings/General.vue 80.21% <50.00%> (-10.96%) ⬇️
app/utils/audit-log.ts 0.00% <0.00%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 11, 2026

Merging this PR will not alter performance

✅ 44 untouched benchmarks


Comparing copilot/create-log-system-for-changes (94a3d8d) with main (f9ee8fa)

Open in CodSpeed

@github-actions
Copy link
Copy Markdown
Contributor

Contribution Guidelines Review

Thanks for this detailed PR — the audit log feature is well-described and the title follows Conventional Commits format correctly. ✅

There's one item from the contribution guidelines that needs attention before this can be marked ready:

📸 Missing screenshots for frontend changes

The guidelines state:

Where frontend changes are made, please include before and after screenshots in your pull request description.

This PR introduces AuditLogSlideover.vue and integrates a bell icon + N shortcut into the manage.vue navbar — both are visible frontend changes. Please add before/after screenshots (or a short screen recording) to the PR description showing:

  • The navbar before and after the bell icon was added
  • The audit log slideover UI (open/loading/empty states)

✅ Everything else looks good

Check Status
PR title format (type(scope): description)
Lowercase title
Detailed PR description with clear sections
Draft state (appropriate while in progress)

Once screenshots are added and the PR is marked ready for review, this should be good to go!

Generated by Contribution Guidelines Checker for issue #144 · ● 233.2K ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/contribution-guidelines-checker.md@1f672aef974f4246124860fc532f82fe8a93a57e

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review — Audit Log System (draft)

This is a solid feature addition with a clean architecture. CI shows lint ✅ · unit tests ✅ · component tests ✅ — but 🧹 Unused code check ❌ is failing (needs investigation before merge). Browser tests, accessibility audits and benchmarks were still running at review time.

Since this is a draft I'm not blocking merge, but there are two runtime-breaking bugs that must be addressed before this is ready.


🐛 Must fix (runtime errors)

# File Issue
1 server/database/schema.prisma Model named AuditLog generates prisma.auditLog, but all code calls prisma.dashboardAuditLog. Also @@Map("audit_log") disagrees with the migration's dashboard_audit_log table. Fix: rename model to DashboardAuditLog and change @@map`` to "dashboard_audit_log".
2 shared/schemas/audit-log.ts number() rejects string query params — every request to GET /audit-logs?limit=50 will return 400. Use coerce(number(), Number) (see inline comment).

⚠️ Should address

# File Issue
3 server/api/guilds/[guild]/settings.patch.ts deriveSection classifies the whole batch by keys[0] only — mixed-section saves are mislabelled.
4 app/composables/useAuditLog.ts Cache key is a static string evaluated once at setup — pass a getter () => \guild:...`` so Nuxt can react to guild navigation.
5 app/components/guild/AuditLogSlideover.vue Entries list lacks aria-live="polite" — screen reader users won't know when content refreshes.

💡 Nice-to-have

# File Suggestion
6 AuditLogSlideover.vue Replace hand-rolled formatRelativeTime with useTimeAgo from VueUse — it's already in the project and stays reactive as time passes.

🧹 CI failure

The unused code check is failing — likely caused by the new AuditLogQuery type export or another export not yet consumed. Run pnpm knip locally and add any genuinely unused exports to the knip ignore list, or wire them up properly.

Generated by WolfStar Code Quality Reviewer for issue #144 · ● 778.1K

Comment thread shared/schemas/audit-log.ts Outdated
Comment thread server/database/schema.prisma
Comment thread server/api/guilds/[guild]/settings.patch.ts Outdated
Comment thread app/composables/useAuditLog.ts Outdated
Comment thread app/components/AuditLogSlideover.vue Outdated
Comment thread app/components/AuditLogSlideover.vue Outdated
@github-actions
Copy link
Copy Markdown
Contributor

Contribution Guidelines Review 🔍

Hi @RedStar071! Thanks for working on this — an audit log system is a great addition to the dashboard. Here's a quick review against the contribution guidelines.

✅ What looks good

  • PR title follows Conventional Commits format (feat(audit-log): ...), uses lowercase ✓
  • Description is well-structured with clear sections (Database, Server, Shared, Frontend) ✓
  • Commit messages don't need to follow the format since they'll be squashed on merge ✓

🔧 A couple of things to address

1. Missing before/after screenshots

The guidelines require:

Where frontend changes are made, please include before and after screenshots in your pull request description.

This PR adds a new AuditLogSlideover.vue component and integrates it into manage.vue — please add screenshots of the UI before and after your changes to the PR description.

2. PR is still in draft

The PR is currently marked as a draft, which typically means it isn't ready for review or merge yet. When the implementation is complete and the checklist below is done, mark it as "Ready for review".


📋 Pre-submission checklist

Before marking ready for review, please confirm:

  • pnpm lint:fix passes
  • pnpm typecheck passes
  • pnpm test passes
  • pnpm build succeeds
  • Before/after screenshots added to the PR description

Once those are addressed, this will be in great shape! Feel free to ping when it's ready. 🚀

Generated by Contribution Guidelines Checker for issue #144 · ● 227K ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/contribution-guidelines-checker.md@1f672aef974f4246124860fc532f82fe8a93a57e

@github-actions
Copy link
Copy Markdown
Contributor

Contribution Guidelines Review 👋

Thanks for this detailed PR! The implementation looks well-structured and the description clearly explains the changes across the database, server, shared, and frontend layers. A few contribution process items to address before this is ready for review:

❌ Missing screenshots for frontend changes

The contribution guidelines require:

"Where frontend changes are made, please include before and after screenshots in your pull request description."

This PR introduces a new AuditLogSlideover.vue component and integrates it into the manage.vue navbar, but the description doesn't include any screenshots. Please add before/after screenshots showing:

  • The new bell icon in the navbar
  • The slideover panel open with audit log entries
  • Loading/empty states (if possible)

i️ PR is still in draft

The PR is currently marked as a draft. Once the implementation is complete and CI checks pass (build, lint, typecheck, tests), please mark it as ready for review.

✅ What looks good

  • PR title: feat(audit-log): dashboard audit log system with slideover UI — correct Conventional Commits format, lowercase ✓
  • Description: Well-structured with clear sections explaining the changes ✓
  • Scope: audit-log is descriptive and appropriate ✓

Once screenshots are added and the draft status is removed, this will be much closer to ready. Let us know if you have any questions!

Generated by Contribution Guidelines Checker for issue #144 · ● 233.1K ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/contribution-guidelines-checker.md@1f672aef974f4246124860fc532f82fe8a93a57e

github-actions[bot]

This comment was marked as outdated.

- Create reusable ActivitySection.vue component for section lifecycle
- Migrate audit log and moderation cases sections in General.vue
- Encapsulates heading, badge, refresh, loading, empty, list, and view-all
@github-actions
Copy link
Copy Markdown
Contributor

Hey @RedStar071 👋 Thanks for this contribution — the audit log system looks like a well-thought-out addition!

I ran a quick check against the contribution guidelines. Here's where things stand:

✅ Looks good

  • PR title follows Conventional Commits format (feat(audit-log): ..., lowercase) ✓
  • Description is thorough — covers Database, Server, Shared, and Frontend changes ✓
  • Screenshot included for the new UI ✓

⏳ Before marking ready

This PR is currently in draft state, so I'm holding off on the contribution-ready label for now. Before moving it to "Ready for review", please confirm the pre-submit checklist from the contributing guide:

  • pnpm lint:fix — linting passes
  • pnpm typecheck — no type errors
  • pnpm test — all tests pass
  • pnpm build — production build succeeds

Once those are green and you mark the PR as ready, feel free to ping for another look and the label can be added then. 🚀

Generated by Contribution Guidelines Checker for issue #144 · ● 368.2K ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/contribution-guidelines-checker.md@1f672aef974f4246124860fc532f82fe8a93a57e

github-actions[bot]

This comment was marked as outdated.

@github-actions
Copy link
Copy Markdown
Contributor

Thanks for this contribution! The implementation looks substantial and well thought-out. Before this PR can move forward, there are a few contribution process items to address. 👇

PR Template

The description doesn't follow the PR template. Please update it to include the required sections:

  • 🔗 Linked issue — Is there an open issue this addresses? If so, include Fixes #<number> or Closes #<number>. If not, consider opening one first so the feature can be discussed before the implementation is merged.
  • 🧭 Context — A brief explanation of why this change is needed and the background behind it.
  • 📚 Description — A description of what changed in your own words.

The technical detail in the current description is great — it just needs to be restructured into the template format.

Own words, please

From CONTRIBUTING.md § Using AI:

Never let an LLM speak for you. When you write a comment, issue, or PR description, use your own words. AI-generated summaries tend to be long-winded, dense, and often inaccurate. The goal is not to sound impressive, but to communicate clearly.

The current description reads as AI-generated. Please rewrite it in your own voice — even a few plain sentences explaining what this does and why you built it is far more valuable than a detailed AI summary.

Draft status

This PR is currently marked as a draft. When it's ready for review, please mark it as ready and ensure CI checks pass (lint, typecheck, build, tests).


Once those are addressed, re-request review and a maintainer will take a look. Thanks again for contributing! 🙌

Generated by Contribution Guidelines Checker for issue #144 · ● 291.1K ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/contribution-guidelines-checker.md@1f672aef974f4246124860fc532f82fe8a93a57e

github-actions[bot]

This comment was marked as outdated.

@RedStar071
Copy link
Copy Markdown
Member

@copilot apply changes based on the comments in this thread

…refs, fix duplicate template, lazy fetch, squash migrations, clean types

- Remove orphaned moderation cases section from General.vue (references deleted composables)
- Fix AuditLogSlideover.vue: remove duplicate loading/empty blocks, use immediate: false + watch
- Switch audit-logs.get.ts from defineWrappedCachedResponseHandler to defineWrappedResponseHandler
- Clean up redundant imports/exports in types.ts
- Squash two migrations into single audit_log migration

Agent-Logs-Url: https://github.com/wolfstar-project/wolfstar.rocks/sessions/69b7b2a0-6ced-4466-bb1b-a712aef12174

Co-authored-by: RedStar071 <76824516+RedStar071@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 15, 2026

@copilot apply changes based on the comments in this thread

Applied all review fixes in 0b5b4f2:

  • CRITICAL: Removed orphaned moderation cases section from General.vue (referenced deleted composables/functions causing build failure)
  • audit-logs.get.ts: Switched from defineWrappedCachedResponseHandlerdefineWrappedResponseHandler to prevent cached responses bypassing auth
  • AuditLogSlideover.vue: Removed duplicate loading/empty template blocks; changed to immediate: false + watch(isNotificationsSlideoverOpen) for lazy fetch on open
  • types.ts: Cleaned up redundant import/export pattern — single import type for local use + separate export type re-exports
  • Migrations: Squashed two migrations (create dashboard_audit_log → drop + create audit_log) into a single migration that creates the final audit_log table directly with FK constraint

autofix-ci Bot and others added 3 commits April 15, 2026 17:08
- Extract audit-log helpers to app/utils/audit-log.ts (auto-imported)
- Add member avatar and action description to General.vue entries
- Widen entry spacing to match AuditLogSlideover rhythm
- Fix badge overflow text to show '+N more' consistently
- Left-align Server Info buttons on mobile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants