Repository navigation
[web-console] Keep the pipeline page state when a pipeline is renamed - #7965
Karakatiza666 wants to merge 1 commit into
Conversation
| changeStream[tenantName][pipelineId] = { rows: [], headers: [], totalSkippedBytes: 0 } | ||
| } | ||
| // Delete callbacks get the name of the deleted pipeline | ||
| const dropChangeStreamHistory = async (tenantName: string, pipelineName: string) => { |
There was a problem hiding this comment.
bug (medium): a deleted pipeline's id stays in pipelineNames, and its start_paused callback stays registered. If you delete pipeline A and then create a new A, findPipelineId('A') returns the old id first. As a result, hasSelectedRelations('A') returns false for the new pipeline, so start skips pause/unpause and the change stream misses the initial changes. A later delete of the new A also leaves its history in place. I reproduced this with a test (see the PR comment). The fix needs this change plus the untrack on line 420:
delete pipelineNames[tenantName][pipelineId]
const registered = startPausedCallbacks[tenantName]?.[pipelineId]
if (registered) {
pipelineActionCallbacks.remove(registered.pipelineName, 'start_paused', registered.callback)
delete startPausedCallbacks[tenantName][pipelineId]
}| } | ||
|
|
||
| $effect.pre(() => { | ||
| registerPipeline(api, tenantName, pipelineId, pipelineName) |
There was a problem hiding this comment.
bug (medium): registerPipeline reads pipelinesRelations[tenantName], which is $state, so this effect tracks it. The effect therefore re-runs on every relation change. Worse, when the delete callback deletes the entry, the still-mounted (deleted) tab re-runs the effect and registers the deleted pipeline again. That cancels any cleanup in dropChangeStreamHistory.
| registerPipeline(api, tenantName, pipelineId, pipelineName) | |
| const [t, id, name] = [tenantName, pipelineId, pipelineName] | |
| untrack(() => registerPipeline(api, t, id, name)) |
|
What I ran: bug (medium): delete, then recreate under the same name, breaks the change stream. Details are in the inline comments. This test fails on the PR head and passes with both inline fixes applied: TabChangeStream.recreate.svelte.spec.tsimport { describe, expect, it, vi } from 'vitest'
import { page } from 'vitest/browser'
import { render } from 'vitest-browser-svelte'
import type { ExtendedPipeline } from '#lib/services/pipelineManager.ts'
import { usePipelineActionCallbacks } from '#lib/compositions/pipelines/usePipelineActionCallbacks.svelte.ts'
vi.mock('#lib/compositions/usePipelineManager.svelte.ts', () => ({
usePipelineManager: () => ({ relationEgressStream: async () => new Error('no stream in test') })
}))
import TabChangeStream, { hasSelectedRelations } from './TabChangeStream.svelte'
const pipelineProp = (id: string, name: string) => ({
current: {
id, name, status: 'Running',
programInfo: { schema: { inputs: [{ name: 't1', fields: [] }], outputs: [] } }
} as unknown as ExtendedPipeline
})
describe('TabChangeStream.svelte: delete and recreate under the same name', () => {
it('tracks the selected relations of the new pipeline', async () => {
const first = render(TabChangeStream, { pipeline: pipelineProp('id-old', 'p-recreate') })
await page.getByRole('checkbox').first().click()
expect(hasSelectedRelations('p-recreate')).toBe(true)
for (const cb of usePipelineActionCallbacks().getAll('', 'delete')) await cb('p-recreate')
await first.unmount()
render(TabChangeStream, { pipeline: pipelineProp('id-new', 'p-recreate') })
await page.getByRole('checkbox').first().click()
expect(hasSelectedRelations('p-recreate')).toBe(true) // fails on PR head
})
})Missing tests (medium): the PR has no rename tests for logs (the stream reconnects under the new name and keeps its rows), for the change stream (the selected relations survive and Commit message (low): the subject is longer than 72 characters and GitHub truncates it. The body, "refactors that improve readability…", does not explain the id-vs-name change. Please reuse the PR description as the body. |
…ding the page on rename Also, refactors that improve readability and deduplicate some checks and procedures Signed-off-by: Karakatiza666 <bulakh.96@gmail.com>
401fce7 to
a26e61c
Compare
Renaming a pipeline on the pipeline page reset everything on the page: the ad-hoc query text and results, the code editor's open files and undo history, the logs, the change stream selections and the performance graphs.
The cause was that the web console used the pipeline name as the pipeline's identity. A rename changed that identity, so per-pipeline state was looked up under a new key and components were recreated. Now per-pipeline state is keyed by the pipeline id, which a rename does not change. The name is still used for API calls and display. The page also keeps the loaded pipeline when it navigates to the new URL.
The commit also simplifies the code in the ad-hoc query, logs and change stream tabs, and guards the stream callbacks of the logs and change stream tabs against a pipeline that was deleted while a stream was open.
Each user loses their saved interaction panel tab once, because its local storage key now uses the id.
Linked Issue
Describe Manual Test Plan
New unit tests: the pipeline page keeps the loaded pipeline across the rename navigation, the ad-hoc query text survives a rename and runs under the new name, and the change stream tab mounts. Both rename tests fail without the fix.
Checklist
Breaking Changes?
Mark if you think the answer is yes for any of these components:
Describe Incompatible Changes
Fix #7579