Feature/add live updates in ticket view#88
Conversation
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 36 minutes and 49 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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 have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe ticket detail page now includes real-time activity log polling. When a ticket ID is present, the page fetches activity logs from the server every 5 seconds and displays them with localized timestamps. The activity log section is rendered on the page with a loading indicator and updates dynamically as new logs are available. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/main/resources/static/js/ticket-detail.js`:
- Around line 160-176: The subscribeToActivityUpdates function allows
overlapping fetches and delays the first fetch; replace the setInterval pattern
with an await-driven loop that fetches immediately and only schedules the next
fetch after the previous one finishes to avoid concurrent requests and stale
renders. Inside subscribeToActivityUpdates, call
apiFetch(`/tickets/${ticketId}/logs`) once immediately, then run a loop (or
recursive setTimeout) that awaits each response before sleeping (5000ms) and
calls updateActivityLog(logs); keep a reference to the interval/stop flag so
window.addEventListener('beforeunload') can clear/stop the loop; ensure error
handling around apiFetch (console.error) still exists and that you reference
subscribeToActivityUpdates, apiFetch and updateActivityLog when making the
change.
- Around line 188-197: The render currently rebuilds the entire activity DOM
each poll via container.innerHTML = logs.map(...).join(''), which resets scroll;
preserve render stability by caching the last rendered payload (e.g., a
module-scoped lastRenderedLogs or lastRenderedKey) and compare it to the current
logs (use a stable serialisation like JSON.stringify(logs) or a
version/timestamp field) inside the polling handler before touching the DOM; if
unchanged, return early, otherwise update container.innerHTML and set the cache
to the new payload. Ensure you reference the existing container variable and the
logs array/parameter from the polling function when implementing the check.
In `@src/main/resources/static/pages/ticket-detail.html`:
- Around line 60-63: The activity log container with id "activityLog" is a
scrollable region but not keyboard focusable or exposed as a landmark; make it
reachable by adding keyboard focusability and an accessible label—set
tabindex="0" on the element with id "activityLog", add role="region" and either
aria-label="Aktivitetslogg" or aria-labelledby pointing to the <h2> to provide a
clear name, and ensure any focus styles remain visible so keyboard users can
scroll the container.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 77b3801d-fcf1-4fe9-a341-d093c184adb8
📒 Files selected for processing (2)
src/main/resources/static/js/ticket-detail.jssrc/main/resources/static/pages/ticket-detail.html
…bility improvements
This pull request adds real-time updates for the activity log on the ticket detail page by implementing polling in the frontend and updating the UI to display the activity log. It also improves localization of date formatting for comments and activity entries.
Real-time activity log updates:
ticket-detail.htmlto display the activity log, which updates every 5 seconds.ticket-detail.jsto fetch and update the activity log from the backend at regular intervals, with cleanup on page unload. [1] [2]Localization improvements:
sv-SE) for better localization. [1] [2]Summary by CodeRabbit