Skip to content

fix(task): preserve task state and paging during polling - #2795

Merged
openai0229 merged 2 commits into
OtterMind:mainfrom
HandSonic:fix/task-state-races
Sep 11, 2026
Merged

openai0229 merged 2 commits into
OtterMind:mainfrom
HandSonic:fix/task-state-races

Conversation

@HandSonic

@HandSonic HandSonic commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

Related issue

N/A - no matching public issue was linked to this task lifecycle and pagination fix.

Summary

Unexpected executor cancellation exceptions could leave tasks marked RUNNING without a cancellation request. They now persist as FAILED unless the task cancellation token was set.

Task-center polling and pagination now merge records by ID and update time, preserve terminal states and newly loaded history, and reject responses invalidated by deletion or closing the panel. Slow pagination can finish while polling continues. Failed loads release loading state, show an error, and can be retried.

Affected surfaces

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

Verification

  • Commands and results:
    • yarn test:task-center: passed, including six tests of the actual store with a controlled network boundary.
    • yarn lint: ESLint and Stylelint passed.
    • yarn build:web:community --app_version=0.0.0: full prebuild, production build, and bundle verification passed. The final frontend source is byte-identical to the built and browser-tested version.
    • On the final head with Java 17: mvn -B -o -f chat2db-community-server/pom.xml -pl :chat2db-community-domain-core -am -Dmaven.test.skip=false -DskipTests=false '-Dtest=LocalCookieTest,LocalTaskManagerTest,TaskExecutorRegistryTest,RunningTaskTest,TaskServiceImplTest' -Dsurefire.failIfNoSpecifiedTests=false -Dmaven.test.failure.ignore=false package: 23 task-related tests passed, zero failures/errors/skips; package succeeded. No LocalCookie test was discovered by that selector.
    • git diff --check: passed.
  • Manual verification: Playwright CLI operated the production Community task center against an isolated local backend with controlled task API responses. Five scenarios passed: slow loading with concurrent polling; deletion plus cancelled confirmation while loading; reloading after deletion; closing/reopening during loading; and a visible load failure followed by successful retry. Final browser console had zero errors/warnings. No production data or database writes were used.
  • UI evidence: Local screenshots, request traces, and machine-readable scenario results were retained for maintainer review; no public artifact uploaded.

Risk and compatibility

  • Public API or stored data: No endpoint or storage-format changes. Unexpected executor errors now become failed tasks rather than remaining running.
  • Database or driver compatibility: N/A - no dialect, driver, or connection changes.
  • Network, privacy, or security: Existing task requests only. Delayed responses cannot restore locally deleted tasks or overwrite confirmed terminal states.
  • Community / Local / Pro boundary: Shared task behavior; edition selection and extension interfaces remain unchanged.
  • Backward compatibility: Missing update timestamps fall back to other existing task timestamps. Confirmed terminal states are retained. Loading failures remain retryable.

Reviewer map

  • Start here: src/store/importExport/index.ts, taskCenterUtils.ts, taskCenterStore.test.ts, then TaskRunner.run and the cancellation tests in LocalTaskManagerTest.
  • Failure condition: A slow load is discarded by normal polling, a deleted task returns, an old response clears a newer loading state, terminal progress regresses, or an unexpected cancellation leaves a task running.
  • Rollback or disable path: Revert the merged change; no migration is required.

Contributor declaration

  • I linked the Issue that defines this change. (N/A - no matching public issue.)
  • 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, or this PR contains no substantial AI-generated code.

AI assistance: OpenAI Codex assisted with review, the polling/pagination fix, regression tests, local validation, and integration with current main.

@HandSonic
HandSonic requested review from a team and openai0229 as code owners August 29, 2026 12:46
@openai0229 openai0229 moved this to In Review in Chat2DB Community Aug 29, 2026
@HandSonic
HandSonic force-pushed the fix/task-state-races branch from acb4118 to 3b2636b Compare September 3, 2026 08:35
@HandSonic
HandSonic force-pushed the fix/task-state-races branch from 3b2636b to 17f9893 Compare September 3, 2026 21:08
Keep completed task states and newly loaded history while polling.
Invalidate stale responses on deletion or close and surface retryable load failures.
@openai0229 openai0229 changed the title fix(task): guard terminal state and stale pages fix(task): preserve task state and paging during polling Sep 11, 2026
@openai0229
openai0229 merged commit c3e73f3 into OtterMind:main Sep 11, 2026
16 of 18 checks passed
@openai0229 openai0229 moved this from In Review to Done in Chat2DB Community Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants