Persona folder navigation can apply stale API responses to the active folder
Both the persona selector and management store start asynchronous folder requests without associating completed responses with the current navigation. Navigate from A to B, let B finish first, then let A finish: stale A responses can overwrite the visible lists. In the selector the breadcrumb remains B; in the manager currentFolderId remains B while the lists and breadcrumb can describe A. An older request can also clear loading while a newer request is pending. Mutation refreshes use the same navigation path.
Correction to the original risk wording: edit, delete and move actions continue to bind to the displayed row and its own persona_id. This is inconsistent visible context that can mislead a user deciding what to do with that actual row, not evidence of an operation being rebound to a different object or ordinary editing moving it into B.
Please associate each navigation load with a monotonically increasing request token in each state owner, commit only the latest response, and guard stale failures and loading updates as well. Keep the existing API and ordinary single-navigation behavior. The existing feedback contains source and controlled-ordering evidence; no real browser/platform acceptance is claimed here.
Confirmed on current master@42972e9. Both navigation implementations have a last-completion-wins race, and the management store can become more internally inconsistent than the issue text suggests.
Code evidence and state flow
dashboard/src/components/shared/PersonaSelector.vue::handleNavigate()setscurrentFolderId, then awaitsloadPersonasInFolder(folderId). That loader writescurrentPersonasanditemsLoadingwithout checking which folder is still active.BaseFolderItemSelector.vuemaintains its own current folder/breadcrumb immediately, so a late A response can display A's personas under B's breadcrumb.dashboard/src/stores/personaStore.ts::navigateToFolder()setscurrentFolderId, startspersonaApi.folders()andpersonaApi.list()inPromise.all, then writes both result arrays and callsupdateBreadcrumb(folderId). If A resolves after B, the store can end ascurrentFolderId === BwhilecurrentFolders/currentPersonasand evenbreadcrumbPathdescribe A.- Both implementations set their loading flag to
falsein every request'sfinally. An older A request can therefore hide the loading state while newer B is still pending. - Mutation actions such as
refreshCurrentFolder(),movePersonaToFolder(),deletePersona(), andreorderItems()all re-enternavigateToFolder(), so this is not limited to fast manual clicks; a mutation refresh can race with navigation too. - I found no frontend regression test covering out-of-order folder responses.
Confirmed chain: navigate A → navigate B → B completes and renders correctly → A completes later → unguarded assignments overwrite B's visible data (and may clear B's loading indicator) while the selected folder ID remains B.
Suggested change
Use a monotonically increasing navigation generation in each owner of navigation state. Capture the requested folder and only let the latest generation commit data, breadcrumb, errors, or loading state:
let navigationGeneration = 0;
async function navigateToFolder(folderId) {
const generation = ++navigationGeneration;
loading.value = true;
currentFolderId.value = folderId;
try {
const result = await load(folderId);
if (generation !== navigationGeneration) return;
currentItems.value = result;
updateBreadcrumb(folderId);
} finally {
if (generation === navigationGeneration) loading.value = false;
}
}
For the Pinia store, keep both API results in local variables and perform a single guarded commit after Promise.all; do not update folders and personas independently. Apply the same generation guard to rejected requests so a stale failure cannot clear or replace the active folder's state.
An AbortController can additionally save network work if the generated Axios client accepts a signal, but cancellation alone should not be the correctness mechanism—responses can complete just as cancellation is requested. The generation check is still needed. On component unmount, increment the generation (and abort if available) to prevent late writes to disposed state.
It would also be worth extracting this small latest-request coordinator so PersonaSelector and personaStore do not drift, but that is optional; keeping ownership local is preferable to introducing a large new abstraction.
Observable result
Rapid A→B navigation will always leave B's personas, subfolders, breadcrumb, and loading state together. Stale responses may finish in the background but cannot expose edit/move/delete actions for the wrong folder. Normal single navigation, mutation refresh, and API payloads remain unchanged; the only extra work is an integer comparison per completion.
Regression coverage
Use deferred promises to make ordering deterministic:
- start A, then B; resolve B first and A last; assert all visible/store fields still describe B;
- resolve stale A while B is pending; assert loading remains true until B settles;
- reject stale A after B succeeds; assert B data and error state are untouched;
- reject active B; assert loading clears once and the selected folder/error behavior is the documented one;
- race
refreshCurrentFolder()/move/delete refresh against a user navigation and assert the newest navigation wins; - unmount/close the selector with a request pending and assert its completion performs no state commit;
- repeat the A/B test for both
PersonaSelector.vueand the Pinia manager path, since they currently have separate implementations.
If the existing lightweight dashboard test setup cannot mount Vue components, extract the generation/commit decision into a small TypeScript helper and test that helper with controlled deferred promises, then retain one manual component smoke check.
Reproduced. The core issue is real, with two corrections.
Confirmed — components/shared/PersonaSelector.vue: loadPersonasInFolder() (L162-175) writes currentPersonas unconditionally (L167) and clears itemsLoading in finally with no token check (L173); handleNavigate() (L178-181) never associates a response with the folder it was requested for. Running the real script block with A at 150ms and B at 20ms:
B resolved first: currentFolderId="B" breadcrumb="FolderB" personas=[persona_B1]
A resolved last: currentFolderId="B" breadcrumb="FolderB" personas=[persona_A1]
Correction 1 — stores/personaStore.ts navigateToFolder() (L113-137) lacks the same guard, but the symptom differs: currentFolderId is written synchronously at L116 at the start of each call, so a late response does not rewrite it. Only currentFolders (L125), currentPersonas (L129) and breadcrumbPath (via L133) get overwritten:
currentFolderId = "B" breadcrumbPath = [A] currentFolders = sub_of_A currentPersonas = persona_A1
So it isn't "breadcrumb says B, content is A" — it's three states disagreeing. Still worth fixing, but the assertion direction matters if a test is written.
Correction 2 — stale rows are indeed clickable (PersonaManager.vue L107/L116/L137, no ownership check), but every action binds to the row's own id and never consults currentFolderId: edit → personaForm.persona_id, delete → persona.persona_id, move → item.persona_id plus the folder picked in the dialog, which initialises to item.folder_id (L142-144). I also ran the real PersonaService.update_persona against PersonaForm L263's ?? props.currentFolderId fallback: it does send folder_id: "B", and the service drops it (L104-114 assembles only six fields). So there's no path to operating on the wrong object; the risk is a user making a wrong decision about the right object.
One more symptom — the loading flag clears early. With a third request still in flight:
after B resolved, C in flight: loading = true
after the STALE A resolved, C in flight: loading = false
The list renders under v-if="!itemsLoading", so the previous folder's rows appear during that gap.
On the fix — the pattern already exists in this repo (ConversationWorkspacePage.vue L111-112 / L340 / L370 / L394 / L403-406; ConversationPage.vue L676-682 / L811 / L843). Note that personaApi.list() (api/v1.ts L1695-1702) does not accept an AxiosRequestConfig, so threading an AbortController requires an API change; a monotonic token does not.
Verified against a local clone with controlled delays in stubs, not a browser session — so "the user sees A's cards" is inferred from the render conditions.
补充修正我上一条评论中的风险表述。根据后续复现结果,我重新核对了当前 master@42972e9:
dashboard/src/views/persona/PersonaManager.vue的查看、编辑、删除和移动入口都把当前卡片对象或其persona_id继续向下传递;删除最终调用deletePersona(persona.persona_id),移动也使用事件中的persona_id。dashboard/src/components/shared/PersonaForm.vue::initializeForm()虽然会以currentFolderId作为新建/缺省时的folder_id,但编辑已有 persona 时优先使用persona.folder_id。astrbot/dashboard/services/persona_service.py::update_persona()当前组装的update_kwargs不包含folder_id,文件夹移动由单独接口处理。
因此,已确认的用户风险应准确表述为:竞态会让 B 文件夹页面展示 A 的卡片和不一致的面包屑/加载状态,用户可能基于错误上下文对那张卡片所代表的真实对象作出错误决定;现有调用链并不会仅因 currentFolderId === B 就把操作改写到另一条 persona,或在普通编辑时把它移到 B。
此前关于单调 generation、原子提交 folders/personas/breadcrumb、只允许最新请求清理 loading,以及覆盖 A/B 乱序、陈旧失败、mutation refresh 和卸载场景的修改与测试建议不变。回归断言应聚焦“陈旧响应不能进入可见状态”,而不是断言现有行操作会错误绑定对象。感谢补充的受控时序验证。