mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-28 05:16:23 -06:00
fix(ui): serialize agent file tab selection (#105366)
This commit is contained in:
committed by
GitHub
parent
9d042e252c
commit
aa840f0f5c
@@ -505,11 +505,14 @@ export function renderAgentFiles(params: {
|
||||
${files.map((file) => {
|
||||
const isActive = active === file.name;
|
||||
const label = file.name.replace(/\.md$/i, "");
|
||||
// File reads are serialized; changing the active tab mid-read would
|
||||
// expose an editor whose content request was never accepted.
|
||||
return html`
|
||||
<button
|
||||
class="agent-tab ${isActive ? "active" : ""} ${file.missing
|
||||
? "agent-tab--missing"
|
||||
: ""}"
|
||||
?disabled=${params.agentFilesLoading}
|
||||
@click=${() => params.onSelectFile(file.name)}
|
||||
>
|
||||
${label}${file.missing
|
||||
|
||||
@@ -437,6 +437,50 @@ describe("renderAgents", () => {
|
||||
});
|
||||
|
||||
describe("renderAgentFiles", () => {
|
||||
it("does not accept another file selection while a file request is loading", () => {
|
||||
const container = document.createElement("div");
|
||||
const onSelectFile = vi.fn();
|
||||
|
||||
render(
|
||||
renderAgentFiles({
|
||||
agentId: "alpha",
|
||||
agentFilesList: {
|
||||
agentId: "alpha",
|
||||
workspace: "/tmp/workspace",
|
||||
files: [
|
||||
{
|
||||
name: "AGENTS.md",
|
||||
path: "/tmp/workspace/AGENTS.md",
|
||||
missing: false,
|
||||
},
|
||||
{
|
||||
name: "HEARTBEAT.md",
|
||||
path: "/tmp/workspace/HEARTBEAT.md",
|
||||
missing: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
agentFilesLoading: true,
|
||||
agentFilesError: null,
|
||||
agentFileActive: "AGENTS.md",
|
||||
agentFileContents: { "AGENTS.md": "# Instructions" },
|
||||
agentFileDrafts: { "AGENTS.md": "# Instructions" },
|
||||
agentFileSaving: false,
|
||||
onLoadFiles: () => undefined,
|
||||
onSelectFile,
|
||||
onFileDraftChange: () => undefined,
|
||||
onFileReset: () => undefined,
|
||||
onFileSave: () => undefined,
|
||||
}),
|
||||
container,
|
||||
);
|
||||
|
||||
const heartbeatTab = expectAgentTab(container, "HEARTBEAT");
|
||||
expect(heartbeatTab.disabled).toBe(true);
|
||||
heartbeatTab.click();
|
||||
expect(onSelectFile).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("renders the upgraded markdown preview structure with file metadata", () => {
|
||||
const container = document.createElement("div");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user