Skip to content

fix: add a return block at the end of sessionResetsAt#21

Merged
calebephrem merged 2 commits into
open-devhub:mainfrom
calebephrem:main
Jun 17, 2026
Merged

fix: add a return block at the end of sessionResetsAt#21
calebephrem merged 2 commits into
open-devhub:mainfrom
calebephrem:main

Conversation

@calebephrem

Copy link
Copy Markdown
Member
  • add a return block at the end of sessionResetsAt, fixes the syntax error
  • also update base prompt to only show server information only when explicitly asked

@beetle-ai

beetle-ai Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Summary by Beetle

This PR addresses a critical syntax error and optimizes the base system prompt for token efficiency. The first commit fixes a malformed function export in the chat context utility that was causing build/runtime errors, while the second commit refines the base prompt to reduce unnecessary token usage by making server information responses more contextual.

📁 File Changes Summary (Consolidated across all commits):

File Status Changes Description
src/utils/chat-context.js Modified +5/-4 Fixed syntax error where sessionResetsAt function was missing its closing brace and return statement, causing sessionTimeRemaining to be incorrectly nested. Properly separated the two functions with correct indentation and return values.
src/commands/ai/askai.js Modified +7/-4 Updated base system prompt to make server info responses conditional ("ONLY when explicitly asked" instead of always providing). Improved code formatting for MIME type detection logic with better line breaks for readability. Reordered imports alphabetically (sessionResetsAt moved after SESSION_TOKEN_BUDGET).
CHANGELOG.md Modified +1/-0 Added changelog entry documenting the removal of large instruction block to reduce token usage.

Total Changes: 3 files changed, +13 additions, -8 deletions

🗺️ Walkthrough:

graph TD
A["User sends /askai command"] --> B["Load BASE_SYSTEM_PROMPT"]
B --> C{"Server info requested?"}
C -->|"Explicitly asked"| D["Include DevHub details"]
C -->|"Not asked"| E["Skip server info"]
D --> F["Build conversation context"]
E --> F
F --> G["Check session budget"]
G --> H["sessionResetsAt called"]
H --> I["Returns session.startedAt + duration"]
I --> J["sessionTimeRemaining called"]
J --> K["Calculates remaining time"]
K --> L["Process AI request"]
style H fill:#90EE90
style I fill:#90EE90
style B fill:#FFE4B5
style C fill:#FFE4B5
Loading

🎯 Key Changes:

  • Critical Bug Fix: Resolved export error in chat-context.js where sessionResetsAt function was missing its closing brace, causing sessionTimeRemaining to be incorrectly nested inside it
  • Token Optimization: Modified base system prompt to only provide DevHub server information when explicitly requested, reducing token consumption on every AI interaction
  • Code Quality: Improved code formatting and readability in MIME type detection logic with proper line breaks
  • Import Organization: Alphabetically ordered imports in askai.js for better maintainability

📊 Impact Assessment:

  • Security: ✅ No security implications. Changes are limited to function structure fixes and prompt optimization. No authentication, authorization, or data handling modifications.
  • Performance: ✅ Positive impact. Reducing the base system prompt by making server info conditional will decrease token usage per request, leading to faster response times and lower API costs. The bug fix ensures proper function execution without runtime overhead from malformed code.
  • Maintainability: ✅ Improved. The syntax error fix makes the code structure clearer with proper function separation and indentation. Alphabetically ordered imports and improved formatting in MIME detection enhance code readability. The conditional prompt logic is more maintainable and easier to adjust in the future.
  • Testing: ⚠️ Needs attention. While the changes are straightforward, consider adding:
  • Unit tests for sessionResetsAt and sessionTimeRemaining to prevent similar syntax errors
  • Integration tests to verify the conditional server info prompt works as expected
  • Token usage metrics to validate the optimization impact
  • Regression tests to ensure the bug fix doesn't break existing session management functionality
⚙️ Settings

Severity Threshold: Medium — Balanced feedback — medium and high severity issues only.Change in Settings
Custom Rules: Define your own review rules — Set Custom Rules
PR Summary: Configure PR summary — Change in Settings

📖 User Guide
  • Once repos are connected, PR analysis is automatically enabled. You can disable analysis for this repo from beetleai.dev/analysis
  • Comment @beetle on any PR to start analysis manually
  • Comment @beetle stop to stop any ongoing analysis

Follow us: Beetle · X · LinkedIn

@beetle-ai

beetle-ai Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

✅ You're good to merge this PR! No issues found. Great job!

Settings
⚙️ Settings

Severity Threshold: Medium — Balanced feedback — medium and high severity issues only.Change in Settings
Custom Rules: Define your own review rules — Set Custom Rules
PR Summary: Configure PR summary — Change in Settings

📖 User Guide
  • Once repos are connected, PR analysis is automatically enabled. You can disable analysis for this repo from beetleai.dev/analysis
  • Comment @beetle on any PR to start analysis manually
  • Comment @beetle stop to stop any ongoing analysis

@calebephrem calebephrem merged commit e374e54 into open-devhub:main Jun 17, 2026
1 of 2 checks passed
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.

1 participant