← 输入框|github.com|刷新
Skip to content

[web-console] Keep the pipeline page state when a pipeline is renamed - #7965

Open
Karakatiza666 wants to merge 1 commit into
mainfrom
fix-rename
Open

Karakatiza666 wants to merge 1 commit into
mainfrom
fix-rename

Conversation

@Karakatiza666

@Karakatiza666 Karakatiza666 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

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

  • Unit tests added/updated
  • Integration tests added/updated
  • Documentation updated
  • Changelog updated

Breaking Changes?

Mark if you think the answer is yes for any of these components:

Describe Incompatible Changes

Fix #7579

changeStream[tenantName][pipelineId] = { rows: [], headers: [], totalSkippedBytes: 0 }
}
// Delete callbacks get the name of the deleted pipeline
const dropChangeStreamHistory = async (tenantName: string, pipelineName: string) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
registerPipeline(api, tenantName, pipelineId, pipelineName)
const [t, id, name] = [tenantName, pipelineId, pipelineName]
untrack(() => registerPipeline(api, t, id, name))

@mythical-fred-oss

Copy link
Copy Markdown
Contributor

What I ran: bun install --frozen-lockfile, then vitest (chromium) on TabAdHocQuery, TabChangeStream, MonitoringPanel, renamePipeline and pageTitles. All 32 tests pass. pre-commit run --files <changed> passes.

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.ts
import { 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 start_paused moves to the new name), for the editor (open files and undo history survive) or for the metrics history. The TabChangeStream test only checks that the tab mounts.

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>

This branch has not been deployed

No deployments
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.

UI reloads when renaming a pipeline

1 participant