Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ export function usePortsData() {
},
);

// Sort alphabetically by workspace name
groups.sort((a, b) => a.workspaceName.localeCompare(b.workspaceName));

return groups;
// Remove workspaces with no active ports and sort alphabetically
return groups
.filter((g) => g.ports.length > 0)
.sort((a, b) => a.workspaceName.localeCompare(b.workspaceName));
}, [allWorkspaceIds, allStaticPortsData?.ports, ports, workspaceNames]);

const totalPortCount = workspacePortGroups.reduce(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import type { DetectedPort, MergedPort, StaticPort } from "shared/types";
* Merge static port configuration with dynamically detected ports.
*
* Logic:
* 1. Start with all static ports (always shown, even when inactive)
* 2. For dynamic ports matching a static port number: merge process info, mark active
* 3. For dynamic ports not in static config: add as dynamic-only entries
* 1. Only show ports that are actively in use (detected by the port scanner)
* 2. For active ports matching a static port number: apply the label from config
* 3. For active ports not in static config: show as dynamic-only entries
* 4. Sort by port number
*/
export function mergePorts({
Expand All @@ -22,40 +22,23 @@ export function mergePorts({
(p) => p.workspaceId === workspaceId,
);

const dynamicByPort = new Map(workspaceDynamicPorts.map((p) => [p.port, p]));
const staticPortNumbers = new Set(staticPorts.map((p) => p.port));
const staticByPort = new Map(staticPorts.map((p) => [p.port, p]));
const merged: MergedPort[] = [];

for (const staticPort of staticPorts) {
const dynamic = dynamicByPort.get(staticPort.port);
for (const dynamic of workspaceDynamicPorts) {
const staticPort = staticByPort.get(dynamic.port);
merged.push({
port: staticPort.port,
port: dynamic.port,
workspaceId,
label: staticPort.label,
isActive: !!dynamic,
pid: dynamic?.pid ?? null,
processName: dynamic?.processName ?? null,
paneId: dynamic?.paneId ?? null,
address: dynamic?.address ?? null,
detectedAt: dynamic?.detectedAt ?? null,
label: staticPort?.label ?? null,
isActive: true,
pid: dynamic.pid,
processName: dynamic.processName,
paneId: dynamic.paneId,
address: dynamic.address,
detectedAt: dynamic.detectedAt,
});
}

for (const dynamic of workspaceDynamicPorts) {
if (!staticPortNumbers.has(dynamic.port)) {
merged.push({
port: dynamic.port,
workspaceId,
label: null,
isActive: true,
pid: dynamic.pid,
processName: dynamic.processName,
paneId: dynamic.paneId,
address: dynamic.address,
detectedAt: dynamic.detectedAt,
});
}
}

return merged.sort((a, b) => a.port - b.port);
}
2 changes: 1 addition & 1 deletion bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.