Skip to content

πŸ™Œ OpenHands: AI-Driven Development

feat(backends): show full organization names in the backend selector (#18667)

Alonadf9800fd764e
diff --git a/__tests__/components/backends/backend-selector.test.tsx b/__tests__/components/backends/backend-selector.test.tsx
index f4150ab9b3..a9fd35839a 100644
--- a/__tests__/components/backends/backend-selector.test.tsx
+++ b/__tests__/components/backends/backend-selector.test.tsx
@@ -377,6 +377,50 @@ describe("BackendSelector", () => {
expect(getCurrentCloudApiKey).not.toHaveBeenCalled();
});
+ it("labels org rows with only the org name when the cloud backend is the only backend", async () => {
+ // Arrange: a lone cloud backend (as in a Canvas locked to one cloud)
+ // whose org names differ only at the end.
+ const backend = {
+ ...SEED_CLOUD_PRODUCTION,
+ id: "cloud",
+ authMode: "cookie" as const,
+ };
+ setRegisteredBackends([backend]);
+ setActiveSelection({ backendId: backend.id, orgId: "org-sec" });
+ vi.mocked(getCloudOrganizations).mockResolvedValue({
+ items: [
+ { id: "org-eng", name: "Platform Business Unit - Engineering" },
+ { id: "org-sec", name: "Platform Business Unit - Security" },
+ ],
+ currentOrgId: "org-sec",
+ });
+
+ renderWithProviders(<BackendSelector />, true);
+ const getInput = () =>
+ screen
+ .getByTestId("backend-selector")
+ .querySelector("input") as HTMLInputElement;
+ await waitFor(() => {
+ expect(getInput().value).toBe("Platform Business Unit - Security");
+ });
+
+ // Act
+ await openDropdown();
+
+ // Assert: the open trigger still names the active org, and each row
+ // shows the org name without the backend name.
+ expect(getInput()).toHaveAttribute(
+ "placeholder",
+ "Platform Business Unit - Security",
+ );
+ expect(
+ screen.getByText("Platform Business Unit - Engineering"),
+ ).toBeInTheDocument();
+ expect(
+ screen.getByText("Platform Business Unit - Security"),
+ ).toBeInTheDocument();
+ });
+
it("labels an org as 'Personal Workspace' when /me reports user_id === org.id", async () => {
const personalOrgId = "0b93b5f2-5396-49f2-8d98-61f906184270";
vi.mocked(getCloudOrganizations).mockResolvedValue({
diff --git a/__tests__/components/ui/dropdown.test.tsx b/__tests__/components/ui/dropdown.test.tsx
index edec8ba496..507904a041 100644
--- a/__tests__/components/ui/dropdown.test.tsx
+++ b/__tests__/components/ui/dropdown.test.tsx
@@ -180,6 +180,21 @@ describe("Dropdown", () => {
});
});
+ describe("Full label on hover", () => {
+ it("should expose the full label as a title on the trigger and each option", async () => {
+ const user = userEvent.setup();
+ render(<Dropdown options={mockOptions} defaultValue={mockOptions[1]} />);
+
+ expect(screen.getByRole("combobox")).toHaveAttribute("title", "Option 2");
+
+ await user.click(screen.getByTestId("dropdown-trigger"));
+
+ mockOptions.forEach(({ label }) => {
+ expect(screen.getByText(label)).toHaveAttribute("title", label);
+ });
+ });
+ });
+
describe("Clear button", () => {
it("should not render clear button by default", () => {
render(<Dropdown options={mockOptions} />);
diff --git a/src/components/features/backends/backend-selector.tsx b/src/components/features/backends/backend-selector.tsx
index f9793be675..a09d11f2dd 100644
--- a/src/components/features/backends/backend-selector.tsx
+++ b/src/components/features/backends/backend-selector.tsx
@@ -70,6 +70,9 @@ function buildOptions(
const locals = registered.filter((b) => b.kind === "local");
const clouds = registered.filter((b) => b.kind === "cloud");
+ // With a single backend (e.g. a Canvas locked to one cloud) the backend
+ // name tells the rows nothing, so give the org name the full width.
+ const showBackendName = registered.length > 1;
for (const b of locals) {
options.push({
@@ -100,7 +103,7 @@ function buildOptions(
const orgLabel = isPersonal ? personalWorkspaceLabel : org.name;
options.push({
value: makeOptionValue(b.id, org.id),
- label: `${b.name} – ${orgLabel}`,
+ label: showBackendName ? `${b.name} – ${orgLabel}` : orgLabel,
// All org rows for the same cloud backend share that backend's
// single connectivity verdict β€” there is no per-org probe.
prefix,
@@ -379,7 +382,9 @@ export function BackendSelector({
void handleSelectBackend(item.value);
}}
placeholder={
- noBackendSelected ? noBackendLabel : active.backend.name
+ noBackendSelected
+ ? noBackendLabel
+ : (activeOption?.label ?? active.backend.name)
}
loading={someCloudLoading}
options={options}
diff --git a/src/ui/dropdown/dropdown-input.tsx b/src/ui/dropdown/dropdown-input.tsx
index 59e8cb3791..5cca60163c 100644
--- a/src/ui/dropdown/dropdown-input.tsx
+++ b/src/ui/dropdown/dropdown-input.tsx
@@ -3,6 +3,8 @@ import { formControlInlineInputClassName } from "#/utils/form-control-classes";
interface DropdownInputProps {
placeholder?: string;
+ /** Full selected label, shown on hover when the input truncates it. */
+ title?: string;
isDisabled: boolean;
getInputProps: (props?: object) => object;
/** When false, placeholder hint keeps upright type (e.g. backend selector). */
@@ -12,6 +14,7 @@ interface DropdownInputProps {
export function DropdownInput({
placeholder,
+ title,
isDisabled,
getInputProps,
italicPlaceholder = true,
@@ -21,12 +24,13 @@ export function DropdownInput({
<input
{...getInputProps({
placeholder,
+ title,
disabled: isDisabled,
className: cn(
"outline-none bg-transparent text-contrast not-italic",
fitContent
? "w-auto field-sizing-content whitespace-nowrap text-sm"
- : "flex-1 min-w-0",
+ : "flex-1 min-w-0 text-ellipsis",
italicPlaceholder &&
"placeholder:italic placeholder:text-tertiary-alt",
!italicPlaceholder && "placeholder:text-tertiary-alt",
diff --git a/src/ui/dropdown/dropdown-menu.tsx b/src/ui/dropdown/dropdown-menu.tsx
index 39e18bcae7..47bdb13f85 100644
--- a/src/ui/dropdown/dropdown-menu.tsx
+++ b/src/ui/dropdown/dropdown-menu.tsx
@@ -38,8 +38,9 @@ export function DropdownMenu({
return (
<div
className={cn(
- "absolute z-50 overflow-hidden text-contrast",
- fitContent ? "min-w-full w-max" : "w-full",
+ "absolute z-50 overflow-hidden text-contrast min-w-full w-max",
+ // Let long labels widen the menu past a narrow trigger, up to a cap.
+ !fitContent && "max-w-[min(26rem,calc(100vw-2rem))]",
openUpward ? "bottom-full mb-1" : "mt-1",
"bg-tertiary rounded-md context-menu-box-shadow p-1",
"max-h-60 overflow-auto",
@@ -74,7 +75,9 @@ export function DropdownMenu({
{option.prefix}
</span>
) : null}
- <span className="min-w-0 truncate">{option.label}</span>
+ <span className="min-w-0 truncate" title={option.label}>
+ {option.label}
+ </span>
</li>
))}
</ul>
diff --git a/src/ui/dropdown/dropdown.tsx b/src/ui/dropdown/dropdown.tsx
index 348eba5624..393c38db1b 100644
--- a/src/ui/dropdown/dropdown.tsx
+++ b/src/ui/dropdown/dropdown.tsx
@@ -197,6 +197,7 @@ export function Dropdown({
) : null}
<DropdownInput
placeholder={placeholder}
+ title={liveSelectedOption?.label}
isDisabled={isDisabled}
getInputProps={getInputPropsWithCursorFix}
italicPlaceholder={italicPlaceholder}