Skip to content

fix: address Sentry review findings from PR #144#147

Merged
anandgupta42 merged 1 commit intomainfrom
fix/sentry-review-144-enhance-prompt
Mar 15, 2026
Merged

fix: address Sentry review findings from PR #144#147
anandgupta42 merged 1 commit intomainfrom
fix/sentry-review-144-enhance-prompt

Conversation

@anandgupta42
Copy link
Contributor

What does this PR do?

Fixes 3 valid Sentry bot findings from PR #144 (AI-powered prompt enhancement):

  • Hardcoded IDs → Use unique MessageID.ascending() / SessionID.descending() instead of hardcoded "enhance-prompt" string for synthetic LLM calls
  • Missing concurrency guard → Add enhancingInProgress flag + finally cleanup to manual enhance handler, preventing race with auto-enhance on submit
  • Orphaned session on early return → When user edits prompt during auto-enhance, use their latest text and continue submission instead of silently returning (which left an orphaned session)

3 other Sentry findings were false positives (stream already consumed at L139-141, compaction circuit breaker already exists in compaction.ts).

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Issue for this PR

Closes #17639

How did you verify your code works?

  • All 48 enhance-prompt unit tests pass (bun test test/altimate/enhance-prompt.test.ts)
  • All 62 altimate test suite tests pass
  • TypeScript type checks pass (turbo typecheck)

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code where necessary
  • My changes generate no new warnings
  • New and existing tests pass locally

🤖 Generated with Claude Code

- Use unique `MessageID`/`SessionID` instead of hardcoded `"enhance-prompt"`
  string for synthetic LLM calls (prevents future API validation breakage)
- Add `enhancingInProgress` guard to manual enhance handler to prevent
  concurrent enhancement race with auto-enhance on submit
- Fix auto-enhance early `return` that orphaned sessions: now uses latest
  user text and continues submission instead of silently abandoning it

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@anandgupta42 anandgupta42 merged commit 4fada35 into main Mar 15, 2026
8 of 10 checks passed
anandgupta42 added a commit that referenced this pull request Mar 17, 2026
- Use unique `MessageID`/`SessionID` instead of hardcoded `"enhance-prompt"`
  string for synthetic LLM calls (prevents future API validation breakage)
- Add `enhancingInProgress` guard to manual enhance handler to prevent
  concurrent enhancement race with auto-enhance on submit
- Fix auto-enhance early `return` that orphaned sessions: now uses latest
  user text and continues submission instead of silently abandoning it

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@anandgupta42 anandgupta42 deleted the fix/sentry-review-144-enhance-prompt branch March 17, 2026 00:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant