Skip to content

refactor: consolidate PollSettings/PollWithOptions types, remove dead code, add CI - #19

Merged
jnahian merged 5 commits into
mainfrom
claude/audit-fix-quality
Jun 10, 2026
Merged

jnahian merged 5 commits into
mainfrom
claude/audit-fix-quality

Conversation

@jnahian

@jnahian jnahian commented Jun 10, 2026

Copy link
Copy Markdown
Owner

Fixes #14

Low-risk code-quality cleanups from the codebase audit (27 files, +232/−359). The larger deduplication refactor (close-poll flow ×4, submission parsing ×2, results rendering ×3) is intentionally deferred to a follow-up after the bug-fix PRs (#15#18) merge, to avoid conflicts.

Type consolidation

  • PollWithOptions is now Prisma.PollGetPayload<{ include: typeof pollInclude }> derived from a single shared pollInclude constant — the hand-written interface and all six as unknown as PollWithOptions casts are gone, so schema drift is caught by the compiler.
  • New src/types/pollSettings.ts: one PollSettings interface (replacing three competing definitions) and a getSettings() helper applying the documented defaults (allowVoteChange: true, liveResults: true) in one place. Replaces 13 inline poll.settings as {...} casts across actions, jobs, and blocks. Behavior preserved.

Dead code / dependencies

  • Deleted never-called buildResultsDM, renderTextBar, renderResultsText, and the getButtonEmoji pass-through alias (grep-verified unreferenced)
  • Removed unused uuid/@types/uuid; moved prisma CLI to devDependencies; lockfile refreshed
  • Replaced a pointless dynamic import in pollCreationSubmission.ts with the existing static import
  • POLL_TYPE_LABELS (previously defined 4×) centralized in src/constants.ts

CI

New .github/workflows/ci.yml on PRs and pushes to main: npm cinpx prisma generatenpx tsc --noEmit (dummy DATABASE_URL for prisma.config.ts).

Docs

CLAUDE.md updated: removed the dead buildResultsDM reference, documented the list_results_/edit_scheduled_/repost_poll_/schedule_repost_ action prefixes, and refreshed the Key Types section.

Validation: npx tsc --noEmit passes with zero errors.

https://claude.ai/code/session_01BHGzHCWjWcXS5XFG6GetiL


Generated by Claude Code

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@jnahian, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 15 minutes and 51 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: acd6098b-f5ba-4660-88e6-de7f306c7f4b

📥 Commits

Reviewing files that changed from the base of the PR and between a7156c9 and e00555e.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (26)
  • .github/workflows/ci.yml
  • CLAUDE.md
  • package.json
  • src/actions/addOptionAction.ts
  • src/actions/closePollAction.ts
  • src/actions/editPollAction.ts
  • src/actions/listActions.ts
  • src/actions/repostAction.ts
  • src/actions/shareResultsAction.ts
  • src/actions/templateActions.ts
  • src/actions/voteAction.ts
  • src/blocks/pollMessage.ts
  • src/blocks/resultsDM.ts
  • src/commands/askify.ts
  • src/constants.ts
  • src/jobs/autoCloseJob.ts
  • src/jobs/reminderJob.ts
  • src/jobs/scheduledPollJob.ts
  • src/jobs/startupRecovery.ts
  • src/services/pollService.ts
  • src/types/pollSettings.ts
  • src/utils/barChart.ts
  • src/utils/emojiPrefix.ts
  • src/views/pollCreationModal.ts
  • src/views/pollCreationSubmission.ts
  • src/views/pollEditSubmission.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/audit-fix-quality

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@jnahian
jnahian marked this pull request as ready for review June 10, 2026 16:42
Copilot AI review requested due to automatic review settings June 10, 2026 16:42
@jnahian jnahian self-assigned this Jun 10, 2026
@jnahian
jnahian enabled auto-merge June 10, 2026 16:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR applies a set of low-risk code-quality cleanups by consolidating poll-related types (PollWithOptions, PollSettings), removing verified-dead code, centralizing duplicated constants, and adding a CI workflow that type-checks the project on PRs and main pushes.

Changes:

  • Replaced hand-written/cast-heavy poll payload types with Prisma.PollGetPayload derived from a single pollInclude, and centralized poll settings parsing/defaults via getSettings().
  • Removed unused helpers (buildResultsDM, renderTextBar, renderResultsText, getButtonEmoji) and deduplicated POLL_TYPE_LABELS into src/constants.ts.
  • Added GitHub Actions CI to run npm ci, prisma generate, and tsc --noEmit.

Reviewed changes

Copilot reviewed 26 out of 27 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/views/pollEditSubmission.ts Replaces local PollSettings with shared type import.
src/views/pollCreationSubmission.ts Removes dynamic import and uses shared PollSettings + static updatePollMessageTs import.
src/views/pollCreationModal.ts Uses centralized POLL_TYPE_LABELS for poll-type select labels.
src/utils/emojiPrefix.ts Removes unused getButtonEmoji alias.
src/utils/barChart.ts Removes unused text-rendering helpers.
src/types/pollSettings.ts Adds shared PollSettings + getSettings() defaulting helper.
src/services/pollService.ts Consolidates PollWithOptions using pollInclude + removes unsafe casts.
src/jobs/startupRecovery.ts Uses getSettings() instead of inline settings casts.
src/jobs/scheduledPollJob.ts Uses getSettings() instead of inline settings casts.
src/jobs/reminderJob.ts Uses getSettings() instead of inline settings casts.
src/jobs/autoCloseJob.ts Uses getSettings() instead of inline settings casts.
src/constants.ts Adds centralized POLL_TYPE_LABELS.
src/commands/askify.ts Uses centralized POLL_TYPE_LABELS instead of local maps.
src/blocks/resultsDM.ts Switches to shared PollSettings type import.
src/blocks/pollMessage.ts Uses shared PollSettings + centralized POLL_TYPE_LABELS; removes dead buildResultsDM.
src/actions/voteAction.ts Uses getSettings() instead of inline settings cast.
src/actions/templateActions.ts Uses getSettings() when building template config.
src/actions/shareResultsAction.ts Uses getSettings() instead of inline settings cast.
src/actions/repostAction.ts Uses getSettings() instead of inline settings cast.
src/actions/listActions.ts Uses getSettings() instead of inline settings casts.
src/actions/editPollAction.ts Uses getSettings() instead of inline settings cast.
src/actions/closePollAction.ts Uses getSettings() instead of inline settings cast.
src/actions/addOptionAction.ts Uses getSettings() instead of inline settings cast.
package.json Removes unused deps (uuid, @types/uuid) and moves prisma CLI to devDependencies.
package-lock.json Lockfile refresh reflecting dependency cleanup/reclassification.
CLAUDE.md Updates docs to reflect new types, settings helper, and action ID prefixes.
.github/workflows/ci.yml Adds CI workflow for install → prisma generate → typecheck.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/actions/templateActions.ts Outdated
options: poll.options.map((o) => o.label),
...(description ? { description } : {}),
settings,
settings: settings as TemplateConfig['settings'],
@jnahian
jnahian disabled auto-merge June 10, 2026 17:09
claude added 3 commits June 10, 2026 17:19
Re-applies getSettings()/shared types over main's atomic claims,
fresh-poll re-fetch, and unique-voter threading; drops the dead
buildResultsDM and countUniqueVoters helpers from both sides.

https://claude.ai/code/session_01BHGzHCWjWcXS5XFG6GetiL
Re-applies getSettings()/shared constants over the new ownership checks
and mrkdwn escaping; keeps buildResultsDM deleted.

https://claude.ai/code/session_01BHGzHCWjWcXS5XFG6GetiL
Keeps the dead buildResultsDM deleted; resilience changes merge cleanly
over the consolidated types.

https://claude.ai/code/session_01BHGzHCWjWcXS5XFG6GetiL
@jnahian
jnahian merged commit ac1bc45 into main Jun 10, 2026
2 checks passed
@jnahian
jnahian deleted the claude/audit-fix-quality branch June 10, 2026 17:26
Sign up for free to 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.

Code quality: consolidate PollSettings/PollWithOptions types, remove dead code, add CI type-check

3 participants