Skip to content

Conversation

@gayanMatch
Copy link

Description

Refactored chatStore to use a single task: Task | null instead of tasks: { [key: string]: Task } dictionary pattern.

Changes:

  • taskstask (single object)
  • activeTaskIdtaskId
  • Removed taskId parameter from all store methods
  • Updated 25 files with new pattern
  • Added null guards for TypeScript strict mode

This fixes the "ghost chatStore" bug where stale task references caused data issues.

What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

@a7m-1st
Copy link
Collaborator

a7m-1st commented Jan 17, 2026

oh thats quite fast ! Thanks @gayanMatch do give me 1 - 2 days to confirm.
Can you also update the test cases if its not much hassle? It will make the review much easier and ensure the bugs are fixed.

@a7m-1st a7m-1st self-requested a review January 17, 2026 14:50
@gayanMatch
Copy link
Author

gayanMatch commented Jan 19, 2026

oh thats quite fast ! Thanks @gayanMatch do give me 1 - 2 days to confirm. Can you also update the test cases if its not much hassle? It will make the review much easier and ensure the bugs are fixed.

Hi @a7m-1st.
Done! Updated all 8 test files (chatStore.test.ts, 4 integration tests, and 3 component tests) to use the new single-task pattern - all 114 tests pass. Also merged latest main branch changes (DOMPurify security fix, model config checking, privacy UI) while keeping the single-task pattern.

@a7m-1st
Copy link
Collaborator

a7m-1st commented Jan 19, 2026

Thanks for the update @gayanMatch, let me review today 🙌

Copy link
Collaborator

@a7m-1st a7m-1st left a comment

Choose a reason for hiding this comment

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

After testing LGTM, thanks for the very detailed and quick PR. No issues found while testing, just enhanced the console error type as throwing Error instead, and reenabled a test case. Here is what it looks like now:

The ghost chatStore is still getting created (most likely after a replayed project somewhere in the code is calling projectStore.createChatStore() ):

"1768872539549-9660": {
      "taskId": null,
      "nextTaskId": null,
      "task": null,
      "updateCount": 0
  },

But I think we can keep it as it is now as it doesn't affect the system. This is the final output of my tasks for instance (new proj, replayed proj, new active proj)

{
    "activeProjectId": "1768872489046-8424",
    "projects": {
        "1768872489046-8424": {
            "id": "1768872489046-8424",
            "name": "new project",
            "createdAt": 1768872489046,
            "updatedAt": 1768872604484,
            "chatStores": {
                "1768872489046-2335": {
                    "taskId": "1768872489053-8129",
                    "nextTaskId": null,
                    "task": {
                        "messages": [],
                        "summaryTask": "",
                        "taskInfo": [],
                        "attaches": [],
                        "taskRunning": [],
                        "taskAssigning": [],
                        "fileList": [],
                        "webViewUrls": [],
                        "activeAsk": "",
                        "askList": [],
                        "progressValue": 0,
                        "isPending": false,
                        "activeWorkSpace": "workflow",
                        "hasMessages": true,
                        "activeAgent": "",
                        "status": "pending",
                        "taskTime": 0,
                        "tokens": 0,
                        "elapsed": 0,
                        "hasWaitComfirm": true,
                        "cotList": [],
                        "hasAddWorker": false,
                        "nuwFileNum": 0,
                        "delayTime": 0,
                        "selectedFile": null,
                        "snapshots": [],
                        "snapshotsTemp": [],
                        "isTakeControl": false,
                        "isTaskEdit": false,
                        "streamingDecomposeText": ""
                    },
                    "updateCount": 0
                },
                "1768872603789-1292": {
                    "taskId": "1768872603795-2468",
                    "nextTaskId": null,
                    "task": {
                        "messages": [
                        ],
                        "summaryTask": "Eigent Bags Token Verification & Brief Report|Investigate the purported “bags coin” link",
                        "taskInfo": [
                        ],
                        "attaches": [],
                        "taskRunning": [
                        ],
                        "taskAssigning": [
                        ],
                        "fileList": [],
                        "webViewUrls": [
                            {
                                "url": "https://www.google.com",
                                "processTaskId": "1768872603795-2468.1"
                            }
                        ],
                        "activeAsk": "",
                        "askList": [],
                        "progressValue": 0,
                        "isPending": true,
                        "activeWorkSpace": "workflow",
                        "hasMessages": true,
                        "activeAgent": "",
                        "status": "running",
                        "taskTime": 1768872922370,
                        "tokens": 2810,
                        "elapsed": 0,
                        "hasWaitComfirm": false,
                        "cotList": [],
                        "hasAddWorker": false,
                        "nuwFileNum": 0,
                        "delayTime": 0,
                        "selectedFile": null,
                        "snapshots": [],
                        "snapshotsTemp": [
                        ],
                        "isTakeControl": false,
                        "isTaskEdit": false,
                        "streamingDecomposeText": ""
                    },
                    "updateCount": 0
                }
            },
            "chatStoreTimestamps": {
                "1768872489046-2335": 1768872489046,
                "1768872603789-1292": 1768872603795
            },
            "activeChatId": "1768872603789-1292",
            "queuedMessages": [],
            "metadata": {
                "status": "active",
                "historyId": 30150,
                "tags": []
            }
        },
        "1768583228280-3226": {
            "id": "1768583228280-3226",
            "name": "Replay Project div — 3:00 PM",
            "description": "Replayed project from div",
            "createdAt": 1768872539549,
            "updatedAt": 1768872584273,
            "chatStores": {
                "1768872539549-9660": {
                    "taskId": null,
                    "nextTaskId": null,
                    "task": null,
                    "updateCount": 0
                },
                "1768872539553-3876": {
                    "taskId": "1768872539553-5917",
                    "nextTaskId": null,
                    "task": {
                        "type": "replay",
                        "messages": [
                        ],
                        "summaryTask": "",
                        "taskInfo": [],
                        "attaches": [],
                        "taskRunning": [],
                        "taskAssigning": [],
                        "fileList": [],
                        "webViewUrls": [],
                        "activeAsk": "",
                        "askList": [],
                        "progressValue": null,
                        "isPending": false,
                        "activeWorkSpace": "workflow",
                        "hasMessages": true,
                        "activeAgent": "",
                        "status": "pending",
                        "taskTime": 1768872540488,
                        "tokens": 0,
                        "elapsed": 0,
                        "hasWaitComfirm": false,
                        "cotList": [],
                        "hasAddWorker": false,
                        "nuwFileNum": 0,
                        "delayTime": 0.2,
                        "selectedFile": null,
                        "snapshots": [],
                        "snapshotsTemp": [],
                        "isTakeControl": false,
                        "isTaskEdit": false,
                        "streamingDecomposeText": ""
                    },
                    "updateCount": 0
                }
            },
            "chatStoreTimestamps": {
                "1768872539549-9660": 1768872539549,
                "1768872539553-3876": 1768872539553
            },
            "activeChatId": "1768872539553-3876",
            "queuedMessages": [],
            "metadata": {
                "status": "active",
                "historyId": "1768583228280-3226",
                "tags": [
                    "replay"
                ]
            }
        }
    }
}

@gayanMatch
Copy link
Author

test/integration/chatStore/deadWorkforce.test.tsx
Comment on lines 189 to 191

Thanks for the review and fixes! Good catch on the error type and re-enabling the test. Appreciate you testing thoroughly glad the ghost chatStore doesn't affect functionality. 🙏

@a7m-1st
Copy link
Collaborator

a7m-1st commented Jan 20, 2026

If its all good @bytecraftii then perhaps @Wendong-Fan can you help us merging it?
It will make nodejs development way easier.

@a7m-1st a7m-1st added frontend enhancement New feature or request labels Jan 20, 2026
@a7m-1st a7m-1st linked an issue Jan 20, 2026 that may be closed by this pull request
@gayanMatch
Copy link
Author

If its all good @bytecraftii then perhaps @Wendong-Fan can you help us merging it? It will make nodejs development way easier.

Hi @bytecraftii , @Wendong-Fan could you please merge this PR if it looks good?

@a7m-1st a7m-1st requested a review from Wendong-Fan January 21, 2026 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request frontend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ENHANCE] simplify (refactor) chatStore design

3 participants