fix: preserve subagent session picker order (#78623) · openclaw/openclaw@7917632
steipete
·
2026-05-12
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -6,7 +6,7 @@ Docs: https://docs.openclaw.ai
|
6 | 6 | |
7 | 7 | ### Fixes |
8 | 8 | |
9 | | -- Control UI/sessions: nest subagent sessions under their parent session in the session picker dropdown using a visual `└─ ` prefix, making the parent-child relationship clear. Fixes #77628. |
| 9 | +- Control UI/sessions: nest subagent sessions under their parent session in the session picker dropdown using a visual `└─ ` prefix, making the parent-child relationship clear. Fixes #77628. (#78623) Thanks @chinar-amrutkar. |
10 | 10 | |
11 | 11 | ### Changes |
12 | 12 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -676,7 +676,23 @@ describe("resolveSessionOptionGroups", () => {
|
676 | 676 | }); |
677 | 677 | |
678 | 678 | expect(labels).toContain("Spock"); |
679 | | -expect(labels).toContain("└─ subagent:f4ac7ef1-1234-5678-9abc-def012345678"); |
| 679 | +expect(labels).toContain("└─ f4ac7ef1-1234-5678-9abc-def012345678"); |
| 680 | +}); |
| 681 | + |
| 682 | +it("preserves sibling row order when nesting subagent sessions", () => { |
| 683 | +const parentKey = "agent:main:main"; |
| 684 | +const newerSubagentKey = "agent:main:subagent:newer"; |
| 685 | +const olderSubagentKey = "agent:main:subagent:older"; |
| 686 | +const labels = labelsForSessionOptions({ |
| 687 | +sessionKey: parentKey, |
| 688 | +sessions: [ |
| 689 | +row({ key: newerSubagentKey, label: "Newer", spawnedBy: parentKey }), |
| 690 | +row({ key: olderSubagentKey, label: "Older", spawnedBy: parentKey }), |
| 691 | +row({ key: parentKey, label: "Spock" }), |
| 692 | +], |
| 693 | +}); |
| 694 | + |
| 695 | +expect(labels).toEqual(["Spock", "└─ Newer", "└─ Older"]); |
680 | 696 | }); |
681 | 697 | }); |
682 | 698 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -731,16 +731,32 @@ export function resolveSessionOptionGroups(
|
731 | 731 | |
732 | 732 | for (const group of groups.values()) { |
733 | 733 | const options = group.options; |
734 | | -for (let i = options.length - 1; i >= 0; i--) { |
735 | | -const parentKey = options[i].parentKey; |
736 | | -if (parentKey) { |
737 | | -const parentIdx = options.findIndex((o) => o.key === parentKey); |
738 | | -if (parentIdx !== -1) { |
739 | | -const [child] = options.splice(i, 1); |
740 | | -options.splice(parentIdx + 1, 0, child); |
| 734 | +const optionKeys = new Set(options.map((option) => option.key)); |
| 735 | +const childrenByParent = new Map<string, SessionOptionEntry[]>(); |
| 736 | +for (const option of options) { |
| 737 | +if (option.parentKey && optionKeys.has(option.parentKey)) { |
| 738 | +const siblings = childrenByParent.get(option.parentKey); |
| 739 | +if (siblings) { |
| 740 | +siblings.push(option); |
| 741 | +} else { |
| 742 | +childrenByParent.set(option.parentKey, [option]); |
741 | 743 | } |
742 | 744 | } |
743 | 745 | } |
| 746 | +if (childrenByParent.size > 0) { |
| 747 | +const reordered: SessionOptionEntry[] = []; |
| 748 | +for (const option of options) { |
| 749 | +if (option.parentKey && optionKeys.has(option.parentKey)) { |
| 750 | +continue; |
| 751 | +} |
| 752 | +reordered.push(option); |
| 753 | +const children = childrenByParent.get(option.key); |
| 754 | +if (children) { |
| 755 | +reordered.push(...children); |
| 756 | +} |
| 757 | +} |
| 758 | +options.splice(0, options.length, ...reordered); |
| 759 | +} |
744 | 760 | } |
745 | 761 | |
746 | 762 | for (const group of groups.values()) { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。