feat: Add maglev config file upload with drag-and-drop for auto-populating GTFS-RT feeds#35
Conversation
…ansit branding - Add maglev config file upload with drag-and-drop for auto-populating GTFS-RT feeds - Implement multi-feed support with feed selection/deselection, performance tracking, and feed switching UI - Add URL history management with localStorage persistence and datalist dropdowns - Restructure ProtobufPanel with conditional config vs. manual URL input flows - Add arrivals-and-departures-for-location API endpoint - Add JSON schema for maglev config validation - Replace favicon with Open Transit logo
|
Warning Review limit reached
More reviews will be available in 48 minutes and 33 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 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 configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThis PR introduces three major features: batch ID comparison in ComparatorPanel with parallel fetching and localStorage persistence, ID-based filtering throughout the logging pipeline (KeyLogViewer, database, and API), and Maglev configuration file support for ProtobufPanel to manage multiple GTFS-RT feeds via JSON config. It includes database schema migration, API extensions, new endpoint definition, and significant UI refactoring. ChangesMulti-feature enhancement: batch comparison, ID filtering, and config-driven feeds
🎯 4 (Complex) | ⏱️ ~60 minutes 🚥 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: 6
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/lib/components/ProtobufPanel.svelte (1)
686-692:⚠️ Potential issue | 🟠 Major | ⚡ Quick winUse config-feed headers for pagination requests in config mode.
loadMoreEntitiesalways usespbState.headers, so config-driven feeds lose their per-feed auth headers on pagination calls.Suggested fix
const currentOffset = (pbState.feedData[entityType] as unknown[])?.length || 0; + const activeFeed = + pbState.configFeeds.length > 0 && pbState.activeDisplayFeedId + ? pbState.configFeeds.find((f) => f.id === pbState.activeDisplayFeedId) + : undefined; + const requestHeaders = activeFeed + ? buildFeedHeaders(activeFeed) + : pbState.headers.filter((h) => h.key && h.value); const response = await fetch('/api/protobuf', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ url, - headers: pbState.headers.filter((h) => h.key && h.value), + headers: requestHeaders, offset: {🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/lib/components/ProtobufPanel.svelte` around lines 686 - 692, The pagination request always uses pbState.headers, causing config-driven feeds to drop per-feed auth headers; update the loadMoreEntities function to choose headers from the active feed config when in config mode (e.g., use the feed-specific headers stored on the config object) and fall back to pbState.headers otherwise, then pass those selected headers into the fetch call that posts to '/api/protobuf' (the block building the POST body including url, headers, offset). Ensure you reference the same header-filtering logic (filter(h => h.key && h.value)) when using the config feed headers so pagination requests include the correct auth headers for each feed.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/lib/components/ComparatorPanel.svelte`:
- Around line 505-517: The selectBatchId function leaves cmpState.error set when
switching from a failed batch to a successful one; update selectBatchId (the
function handling cmpState.selectedBatchId and reading cmpState.batchResults) so
that when a result exists but result.error is falsy you explicitly clear
cmpState.error (e.g., set to null/undefined/empty string), and also ensure you
clear cmpState.error when no result is found to avoid showing stale errors.
In `@src/lib/components/ProtobufPanel.svelte`:
- Around line 82-87: When switching to a newly uploaded/selected config feed
that may have no cached results, clear the stale view state by resetting
pbState.feedData (and any UI selection state if needed) before calling
switchToFeed; update the block that currently sets
pbState.configFeeds/pbState.configFileName and calls
selectAllFeeds()/switchToFeed(feeds[0].id!) to explicitly set pbState.feedData =
undefined (or an empty object) so previous feed data is not shown, and apply the
same reset in the other similar section (the code around switchToFeed in the
128-141 area).
- Around line 253-269: The code currently overwrites backend pagination/limited
flags by hardcoding limited: { tripUpdates: false, vehiclePositions: false,
alerts: false } when building pbState.feedResults for a feed (see
pbState.feedResults and the object keyed by feedId); instead, preserve and merge
the backend-provided limited/pagination flags from the fetched tripData,
vehicleData, and alertData objects (and their hasMore/limited properties) into
the feed entry so the UI can correctly show “has more” state, and then set
pbState.paginationState.hasMore to the merged results (e.g.,
mergedHasMore.tripUpdates / vehiclePositions / alerts) after aggregating; apply
the same merge logic in the other similar spots mentioned (around the manual
aggregate path and the other ranges noted).
- Around line 508-516: The interval callback in pbState.refreshTimer can start a
new fetch while previous one is still running; add a reentrancy guard (e.g.,
pbState.isRefreshing or similar) and make the interval callback async so you
await the in-flight fetch before clearing the flag; before calling
fetchSingleConfigFeed, fetchAllConfigFeeds, or fetchAllFeedsManual check the
flag and return early if true, set the flag true immediately before awaiting the
fetch call and set it false in a finally block to ensure the flag is cleared on
success or error; use the existing symbols pbState.refreshTimer,
pbState.refreshInterval, fetchSingleConfigFeed, fetchAllConfigFeeds, and
fetchAllFeedsManual to locate and update the code.
In `@src/lib/components/ProtobufViewer.svelte`:
- Around line 510-517: The width utilities on the "Total Entities" div are
invalid Tailwind classes (max-w-35, min-w-30) and overflow-hidden is redundant
with truncate; update the class list in the div (in ProtobufViewer.svelte) to
use Tailwind arbitrary-width syntax (e.g. max-w-[35ch] and min-w-[30ch] or other
desired units) and remove the explicit overflow-hidden token so the classes
become something like "max-w-[35ch] min-w-[30ch] truncate text-right text-sm
whitespace-nowrap text-gray-500 dark:text-gray-400" while keeping the title and
inner span (reference the div containing the Total Entities label and
entityCount).
In `@static/config.schema.json`:
- Around line 90-142: Add validation so a feed item requires at least one
GTFS-RT URL and prevents sending only one auth half: add an "anyOf" at the feed
object level requiring one of "trip-updates-url", "vehicle-positions-url", or
"service-alerts-url"; and add a dependency rule so "realtime-auth-header-name"
implies "realtime-auth-header-value" and vice versa (use "dependentRequired" or
"dependencies" for "realtime-auth-header-name" -> ["realtime-auth-header-value"]
and "realtime-auth-header-value" -> ["realtime-auth-header-name"]). Update the
schema where the feed object's "properties" are declared (referencing the
property names "trip-updates-url", "vehicle-positions-url",
"service-alerts-url", "realtime-auth-header-name", and
"realtime-auth-header-value").
---
Outside diff comments:
In `@src/lib/components/ProtobufPanel.svelte`:
- Around line 686-692: The pagination request always uses pbState.headers,
causing config-driven feeds to drop per-feed auth headers; update the
loadMoreEntities function to choose headers from the active feed config when in
config mode (e.g., use the feed-specific headers stored on the config object)
and fall back to pbState.headers otherwise, then pass those selected headers
into the fetch call that posts to '/api/protobuf' (the block building the POST
body including url, headers, offset). Ensure you reference the same
header-filtering logic (filter(h => h.key && h.value)) when using the config
feed headers so pagination requests include the correct auth headers for each
feed.
🪄 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 Plus
Run ID: c5371c80-53c2-41f0-88fe-2a4f51b77865
⛔ Files ignored due to path filters (2)
open-transit-logo.pngis excluded by!**/*.pngstatic/favicon.pngis excluded by!**/*.png
📒 Files selected for processing (9)
src/lib/components/ComparatorPanel.sveltesrc/lib/components/KeyLogViewer.sveltesrc/lib/components/ProtobufPanel.sveltesrc/lib/components/ProtobufViewer.sveltesrc/lib/endpoints.tssrc/lib/panelState.svelte.tssrc/lib/server/db.tssrc/routes/api/keylog/+server.tsstatic/config.schema.json
…prove feed data management, and update config schema for required fields
Summary by CodeRabbit
New Features
Refactor