Use Codex workspace labels for project names#9
Conversation
📝 WalkthroughWalkthroughThis PR introduces workspace root label support by adding a Changes
Sequence DiagramsequenceDiagram
participant Server as Server/index.ts
participant FS as File System
participant API as /api/agents Endpoint
participant Client as Web Client (App.tsx)
participant UI as UI Render
Server->>FS: Read electron-workspace-root-labels.json
FS-->>Server: Return labels map
Note over Server: Parse labels & handle errors gracefully
Server->>Server: buildAgentDescriptor with projectLabels
Server->>API: Generate /api/agents response
API-->>Client: Return agents with projectLabels
Client->>Client: Create projectLabelsByPath mapping
Client->>Client: Resolve group labels via projectLabelsByPath.get()
Client-->>UI: Render with custom project labels
Note over UI: Display custom label or fallback to basename
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
apps/web/src/App.tsx (1)
589-599: Optionally trim/skip empty project label entries to preserve fallbacks.If a label is empty/whitespace, the map will store it and suppress the basename fallback. Trimming and skipping empty labels avoids blank group names and keeps lookups consistent.
♻️ Optional refinement
const projectLabelsByPath = useMemo(() => { const labels = new Map<string, string>(); for (const descriptor of agentDescriptors) { for (const [projectPath, label] of Object.entries(descriptor.projectLabels)) { - if (!labels.has(projectPath)) { - labels.set(projectPath, label); - } + const normalizedPath = projectPath.trim(); + const normalizedLabel = label.trim(); + if (!normalizedPath || !normalizedLabel || labels.has(normalizedPath)) { + continue; + } + labels.set(normalizedPath, normalizedLabel); } } return labels; }, [agentDescriptors]);Also applies to: 616-618, 655-665
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/web/src/App.tsx` around lines 589 - 599, The projectLabelsByPath builder currently saves empty or whitespace-only labels from descriptor.projectLabels which suppresses the basename fallback; update the loop in projectLabelsByPath to trim each label and only set it when trimmedLabel is non-empty (skip storing empty/whitespace labels), and apply the same trim-and-skip change to the other equivalent label-collection blocks that iterate agentDescriptors/descriptors and assign project labels so fallbacks remain usable (look for the same pattern around the other label-aggregation code).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/server/src/index.ts`:
- Line 9: CodexGlobalStateSchema currently calls .passthrough(), which lets
unknown keys through; remove that and make the schema strict so unknown
properties are rejected (or stripped) by replacing .passthrough() with .strict()
on the z.object used to define CodexGlobalStateSchema; update any downstream
assumptions if they relied on unknown keys, but keep use of the
"electron-workspace-root-labels" property intact (refer to
CodexGlobalStateSchema and any usages such as parsing logic that calls
parse/parseAsync).
---
Nitpick comments:
In `@apps/web/src/App.tsx`:
- Around line 589-599: The projectLabelsByPath builder currently saves empty or
whitespace-only labels from descriptor.projectLabels which suppresses the
basename fallback; update the loop in projectLabelsByPath to trim each label and
only set it when trimmedLabel is non-empty (skip storing empty/whitespace
labels), and apply the same trim-and-skip change to the other equivalent
label-collection blocks that iterate agentDescriptors/descriptors and assign
project labels so fallbacks remain usable (look for the same pattern around the
other label-aggregation code).
In Codex desktop app you can rename a project. This respects the renamed project name in Farfield. Also ensured that it works for users that don't have Codex desktop app installed.
Disclaimer: Code written with AI (Codex 5.3).