|
| 1 | +I'll analyze the codebase to understand the issue with repo selection when no GitHub integration is set up. Let me start by exploring the relevant files. |
| 2 | +Let me search for task-related components and repository selection UI: |
| 3 | +Let me examine the TaskDetail component since the issue is on a task page: |
| 4 | +Now let me search for where the issue might be with the "undefined/undefined" display and the integration setup link: |
| 5 | +Now I can see the issue. Looking at the TaskDetail component (lines 314-320), when there are no repositories (repositories.length === 0) but a selectedRepo exists, it displays the selectedRepo value. However, the issue described mentions that it shows "undefined/undefined" with a link to open the repo. |
| 6 | + |
| 7 | +Let me check if there's any place where the repo link button is being rendered when it shouldn't be: |
| 8 | +Let me check the TaskCreate component to see if there's similar logic there: |
| 9 | +Let me search for where the integration setup link might be displayed: |
| 10 | +Now let me check the types to understand the repository config structure better: |
| 11 | +Now let me check the WorkflowView to see if there's similar logic there: |
| 12 | +Now let me search for any place that might have text related to setting up integrations or links to the integration settings: |
| 13 | +Let me look at the authStore to understand the full context: |
| 14 | +Based on my analysis, I now understand the issue. Looking at TaskDetail.tsx lines 314-335, when there are no repositories available (no GitHub integration setup), the component shows: |
| 15 | +1. Lines 314-320: Shows "None" in gray when `repositories.length === 0` and no `selectedRepo` |
| 16 | +2. Lines 321-333: Shows a GitHub external link button when `selectedRepo` exists and is not "__none__" |
| 17 | + |
| 18 | +The problem is that when a task has a `repository_config` with `undefined` organization or repository values, the code at lines 62-65 tries to build a string like `${undefined}/${undefined}`, which results in "undefined/undefined". Then the external link button (lines 321-333) is rendered with this invalid value. |
| 19 | + |
| 20 | +The issue occurs when: |
| 21 | +- The task has a `repository_config` object but with undefined/null values for organization or repository |
| 22 | +- No GitHub integration is set up (repositories.length === 0) |
| 23 | +- The button to open the repo is still shown with the invalid "undefined/undefined" URL |
| 24 | + |
| 25 | +Let me verify this by checking the posthogClient to see how repository configs are handled: |
| 26 | +Perfect! Now I have a complete understanding of the issue. Let me create a comprehensive implementation plan. |
| 27 | +Perfect! I've completed my analysis and created a detailed implementation plan. Here's what I found: |
| 28 | + |
| 29 | +## Problem Summary |
| 30 | + |
| 31 | +The issue occurs in the TaskDetail component when: |
| 32 | +1. **No GitHub integration is configured** (repositories array is empty) |
| 33 | +2. A task has a **malformed `repository_config`** object with `undefined` organization or repository values |
| 34 | + |
| 35 | +This causes the UI to display "undefined/undefined" with a broken external link button instead of helping users set up the GitHub integration. |
| 36 | + |
| 37 | +## Root Cause |
| 38 | + |
| 39 | +The code has three issues: |
| 40 | + |
| 41 | +1. **Unsafe state initialization** (lines 61-66): The `selectedRepo` state is built from `task.repository_config` without validating that organization/repository are defined strings |
| 42 | +2. **Missing integration setup prompt**: When no GitHub integration exists, there's no helpful message guiding users to set it up |
| 43 | +3. **Invalid external link rendering**: The GitHub link button renders for any non-empty repo value, including "undefined/undefined" |
| 44 | + |
| 45 | +## Solution |
| 46 | + |
| 47 | +The plan includes: |
| 48 | + |
| 49 | +1. **Add validation** to repository state initialization to prevent "undefined/undefined" |
| 50 | +2. **Show a setup prompt** when no GitHub integration exists, with a button linking to PostHog's integration settings page |
| 51 | +3. **Only show the external link** when a valid integration and repository are selected |
| 52 | +4. **Use the correct URL format**: `https://app.posthog.com/project/{team_id}/settings/environment-integrations` |
| 53 | + |
| 54 | +The plan is ready for your review. Would you like me to proceed with implementation? |
0 commit comments