Skip to content

refactor(task): rebuild Community async task system - #2659

Closed
openai0229 wants to merge 28 commits into
mainfrom
refactor/local-one-shot-task-architecture
Closed

openai0229 wants to merge 28 commits into
mainfrom
refactor/local-one-shot-task-architecture

Conversation

@openai0229

@openai0229 openai0229 commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Related issue

Closes #2658

Summary

This PR replaces the legacy Community task implementation with one asynchronous task system shared by query-result export, table-data export, SQL export, SQL-file import, and data-file import.

The backend now owns task lifecycle transitions, ordered events, bounded execution, cooperative cancellation, artifacts, restart reconciliation, and user-exit failure reasons. Task snapshots and per-task event streams are stored under the isolated task-v2 directory, intentionally without migrating legacy task data.

The frontend provides a compact task center with active/completed indicators, paged newest-first logs, progress, download, delete, and artifact cleanup. Export tasks emit periodic progress logs, and Excel exports split across sheets before reaching format limits.

Community desktop navigation and workspace actions now live in the title bar with consistent Lucide controls, theme-colored active states, a default AI panel, width-based panel persistence, native macOS fullscreen synchronization, and safer JCEF development readiness checks. Dashboard initialization and legacy workspace-layout hydration are handled at their owning boundaries.

Desktop exit requests are correlated by operation ID. Restart preparation occurs only after the user confirms exit, overlapping requests cannot replace the pending action, and cancellation clears the native request without consuming the restart gate. Running tasks are still marked failed with the user-exit reason before the confirmed process exit.

Affected surfaces

  • Frontend / Web
  • Backend / API / Storage
  • Database plugin / Driver
  • JCEF / Desktop packaging
  • CI / Build / Release
  • Documentation only

Verification

  • yarn build:web:community: passed, including the Community prebuild suite, task-center tests, application-exit tests, production build, and bundle verification.
  • Targeted ESLint for all changed title-bar, layout, dashboard, persistence, and exit-coordination files: passed with zero warnings.
  • mvn ... -Dmaven.test.skip=false -DskipTests=false test: passed for the 10-module reactor covering tools, domain API/core, SPI, storage, web, and JCEF; JCEF ran 54 tests and web ran 59 tests with no failures.
  • bash -n script/dev-community-jcef.sh: passed.
  • git diff --check: passed.
  • Earlier packaged-desktop smoke testing covered task-center interaction, export progress, multi-sheet export, artifact download/delete, repeated Finder reveal, and the title-bar/navigation layout. The post-merge review fixes are covered by automated tests and production compilation.

Risk and compatibility

  • Task API and storage compatibility are intentionally not preserved. New records live under task-v2; legacy task JSON is neither migrated nor deleted.
  • Database export plugin contracts now use TaskExecutionContext instead of AsyncContext. Implementations were updated across supported Community plugins, but plugin-specific export paths remain the broadest regression surface.
  • Development CORS handling is relaxed only for isolated frontend testing; release behavior remains restricted.
  • The task implementation and local JSON persistence remain Community-scoped. Enterprise, Pro, Local, and Gateway task persistence are unchanged.
  • Desktop exit confirmation now requires a matching operation ID from the paired frontend and JCEF backend in this build.

Reviewer map

  • Task lifecycle: TaskServiceImpl, LocalTaskManager, TaskRunner, TaskExecutionContextImpl, FileTaskStorage, and TaskController.
  • Task UI: the frontend task store and TaskCenter components.
  • Desktop layout: CommunityTitleBarActions, AppTitleBar, CustomLayout, workspace persistence, and MainJFrame fullscreen events.
  • Exit lifecycle: ApplicationExitCoordinator, RestartAppHandler, confirm/cancel handlers, and useApplicationExit.
  • Failure conditions: non-terminal tasks after execution, duplicate/missing events, cancellation not reaching JDBC, artifacts surviving deletion, log pagination gaps, a canceled restart blocking later restarts, or mismatched exit requests executing.

Contributor declaration

  • I linked the Issue that defines this change.
  • I tested the affected behavior and reported the actual results above.
  • I did not include credentials, private data, or generated build output.
  • I disclosed substantial AI assistance below.

AI assistance: Substantial AI assistance was used for architecture design, implementation, tests, debugging, and review. The contributor manually reviewed and tested the resulting behavior.

@openai0229 openai0229 moved this to In Review in Chat2DB Community Aug 7, 2026
@openai0229 openai0229 added edition/community Chat2DB Community area/backend Community backend and domain services area/frontend Ownership: Community frontend components and UI code area/import-export Data or schema import and export area/jcef JCEF desktop runtime and native packaging java Pull requests that update java code javascript Pull requests that update javascript code labels Aug 7, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Reviewed 301a174.

Findings: 0 critical, 0 high, 1 medium.

Merge recommendation: non-blocking follow-up requested for the tracked-task recovery parameter mismatch.

Coverage limit: this PR changes 276 files; review prioritized the GitHub-provided patches for task lifecycle, cancellation, storage, artifacts, controller routing, task-center pagination, polling, and exit coordination. No tests or runtime checks were run.

``

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • awmgmcpg

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

Generated by AI Pull Request Reviewer for #2659 · 24.6 AIC · ⌖ 2.84 AIC · ⊞ 17.3K

const results = await Promise.all(
missingTaskIds.map(async (taskId) => {
try {
return await loadDetails({ id: taskId });

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[medium] This recovery request uses { id: taskId }, but getTaskDetails was changed in this PR to accept TaskIdParams and /api/tasks/get validates a taskId field. When a previously tracked task is no longer in the current visible page (for example, it completes after enough newer tasks were created), this call is rejected, the catch converts it to an unresolved ID, and polling can continue indefinitely without showing the task terminal state. Change the loader contract and invocation to pass { taskId }, matching the fixed endpoint request object.

@openai0229

Copy link
Copy Markdown
Contributor Author

This PR has been split into focused review units:

The four branches were merged in a temporary integration worktree. The resulting Git tree is 4410af5b6767d758b2fecf16bb45b5ec95411175, exactly matching this PR head 2b29eca, with an empty tree diff.

Closing this PR as superseded so review can continue on the focused PRs.

@openai0229 openai0229 closed this Aug 18, 2026
@openai0229 openai0229 moved this from In Review to Done in Chat2DB Community Aug 18, 2026
@openai0229
openai0229 deleted the refactor/local-one-shot-task-architecture branch September 23, 2026 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/backend Community backend and domain services area/frontend Ownership: Community frontend components and UI code area/import-export Data or schema import and export area/jcef JCEF desktop runtime and native packaging edition/community Chat2DB Community java Pull requests that update java code javascript Pull requests that update javascript code

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

refactor(task): rebuild Community asynchronous task architecture

1 participant