Skip to content

Commit ea3d258

Browse files
aster-voidclaude
andcommitted
modules/admin: fix migration page polling and scroll behavior
- Change getStatus from query to command to bypass caching for real-time polling - Only auto-scroll logs when user is already at bottom (preserves scroll position) - Update misleading comment about polling behavior 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 5754f44 commit ea3d258

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/lib/data/private/migration.remote.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { command, query } from "$app/server";
1+
import { command } from "$app/server";
22
import { requireUtCodeMember } from "$lib/server/database/auth.server";
33
import {
44
startDataMigration,
@@ -13,7 +13,8 @@ export const start = command(async (): Promise<{ started: boolean; message: stri
1313
return startDataMigration();
1414
});
1515

16-
export const getStatus = query(async (): Promise<MigrationState> => {
16+
// Use command instead of query to bypass caching for real-time polling
17+
export const getStatus = command(async (): Promise<MigrationState> => {
1718
await requireUtCodeMember();
1819
return getMigrationState();
1920
});

src/routes/(admin)/admin/migrate/+page.svelte

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,15 @@
2121
const isDisabled = $derived.by(() => isStarting || isRunning);
2222
2323
async function fetchStatus() {
24+
// Check if user is at bottom before fetch
25+
const wasAtBottom = logsContainer
26+
? logsContainer.scrollHeight - logsContainer.scrollTop <= logsContainer.clientHeight + 10
27+
: true;
28+
2429
migrationState = await getStatus();
2530
26-
// Auto-scroll logs to bottom
27-
if (logsContainer) {
31+
// Only auto-scroll if user was already at bottom
32+
if (logsContainer && wasAtBottom) {
2833
logsContainer.scrollTop = logsContainer.scrollHeight;
2934
}
3035
}
@@ -74,11 +79,9 @@
7479
}
7580
}
7681
77-
// Poll every 1s while running, cleanup on unmount
82+
// Poll every 1s to keep status in sync, cleanup on unmount
7883
$effect(() => {
7984
fetchStatus().catch(console.error);
80-
81-
// Always poll every 1s to catch running migrations
8285
pollInterval = setInterval(fetchStatus, 1000);
8386
8487
return () => {

0 commit comments

Comments
 (0)