|
1 |
| -# OAuth Flow Debugging Logs |
2 |
| - |
3 |
| -## OAuth Flow Issues |
4 |
| - |
5 |
| -1. Client ID and Client Secret not being properly passed through the OAuth flow |
6 |
| - - ConnectWorkspace component now saves these in sessionStorage |
7 |
| - - OAuthCallback component retrieves them during the OAuth flow |
8 |
| - |
9 |
| -2. Team ID not available at the time of OAuth callback |
10 |
| - - Added logic to wait for team context to load before proceeding |
11 |
| - - Added timeout to prevent indefinite loading |
12 |
| - |
13 |
| -3. Slack API Client URL Formation |
14 |
| - - Fixed base URL path in SlackApiClient to properly handle team-scoped integrations |
15 |
| - - Added proper error handling for API responses |
16 |
| - |
17 |
| -## API Response Conversion |
18 |
| - |
19 |
| -1. Backend failing to properly convert SQLAlchemy models to Pydantic schemas |
20 |
| - - Added conversion functions for ServiceResource, IntegrationShare, and ResourceAccess |
21 |
| - - Updated error handling for null responses |
22 |
| - |
23 |
| -2. Resource Sync Button |
24 |
| - - Fixed issues with the sync resources button not working properly |
25 |
| - - Added proper URL formation in the API client |
26 |
| - |
27 |
| -## Team-Based Integration Model |
28 |
| - |
29 |
| -1. Transitioning from legacy Slack integration to team-based model |
30 |
| - - Each team now has its own integration |
31 |
| - - OAuth callback requires team context |
32 |
| - - Client credentials collected on a per-team basis instead of environment variables |
33 |
| - |
34 |
| -## Error Debugging (April 15-18) |
35 |
| - |
36 |
| -1. Authorization Error (April 17): |
37 |
| - - Error: Failed to complete OAuth handshake with Slack |
38 |
| - - Status: 400 |
39 |
| - - Details: Invalid client_secret parameter |
40 |
| - - Resolution: Fixed parameter passing from frontend to backend |
41 |
| - |
42 |
| -2. OAuth Token Expiration (April 17): |
43 |
| - - Error: Failed to fetch channel list |
44 |
| - - Status: 401 |
45 |
| - - Details: Token expired or revoked |
46 |
| - - Resolution: Added reconnection flow in IntegrationDetail component |
47 |
| - |
48 |
| -3. URL Construction Issue (April 15): |
49 |
| - - Error: Duplicate path segment in URL |
50 |
| - - URL: https://api.example.com/api/slack/slack/oauth-callback |
51 |
| - - Fixed URL: https://api.example.com/api/slack/oauth-callback |
52 |
| - |
53 |
| -4. Reconnection Error (April 18): |
54 |
| - - Error: Failed to reconnect Slack workspace |
55 |
| - - Status: 409 |
56 |
| - - Details: Workspace already connected to team "Engineering" |
57 |
| - - WorkspaceID: W0123456789 |
58 |
| - - AttemptedTeamID: team_67890 |
59 |
| - - Resolution: Need to implement uniqueness constraints |
60 |
| - |
61 |
| -## Next Steps |
62 |
| - |
63 |
| -1. Implement uniqueness constraints for (team_id, slack_workspace_id) |
64 |
| -2. Create detailed API and UI implementation plans |
65 |
| -3. Add proper error handling for duplicate workspace connections |
66 |
| -4. Implement reconnection flow for expired or revoked tokens |
| 1 | +# Strategy for Integrating "Select Channels for Analysis" UI into Team-Based Integration |
| 2 | + |
| 3 | +## Overview |
| 4 | +This document outlines a strategy for implementing the "Select Channels for Analysis" functionality within the team-based integration model, leveraging existing components from the legacy Slack implementation while maintaining proper team context. |
| 5 | + |
| 6 | +## Current State Analysis |
| 7 | + |
| 8 | +### Legacy Implementation |
| 9 | +The current "Select Channels for Analysis" functionality is implemented in: |
| 10 | +- `frontend/src/components/slack/ChannelList.tsx`: The main component for channel selection |
| 11 | +- `frontend/src/pages/slack/ChannelAnalysisPage.tsx`: The page for running channel analysis |
| 12 | + |
| 13 | +Key features of the legacy implementation: |
| 14 | +1. Fetches channels from Slack workspace |
| 15 | +2. Provides UI for filtering and selecting channels (pagination, search, type filters) |
| 16 | +3. Marks channels for analysis |
| 17 | +4. Manages bot installation status for selected channels |
| 18 | +5. Synchronizes channel data with Slack API |
| 19 | + |
| 20 | +### Team-Based Integration Model |
| 21 | +The new team-based integration model uses: |
| 22 | +- `frontend/src/components/integration/IntegrationDetail.tsx`: Main component for viewing integration details |
| 23 | +- `frontend/src/components/integration/ResourceList.tsx`: Component for displaying integration resources (channels, users) |
| 24 | + |
| 25 | +The team-based model currently: |
| 26 | +1. Displays integration details and status |
| 27 | +2. Shows resources as a simple list without selection functionality |
| 28 | +3. Provides a "Sync Resources" action to update resources |
| 29 | +4. Uses React context for integration data management (`useIntegration`) |
| 30 | + |
| 31 | +## Technical Requirements |
| 32 | + |
| 33 | +1. Enable selection of specific channels for analysis within a team-owned Slack integration |
| 34 | +2. Maintain team context throughout the channel selection and analysis process |
| 35 | +3. Support channel filtering and search functionality |
| 36 | +4. Handle bot installation status for selected channels |
| 37 | +5. Ensure proper synchronization with Slack API |
| 38 | +6. Manage transitions between different UI states (loading, error, success) |
| 39 | +7. Implement proper pagination and sorting |
| 40 | +8. Preserve existing integration management features |
| 41 | + |
| 42 | +## Implementation Strategy |
| 43 | + |
| 44 | +### 1. Create new components for channel selection within team context |
| 45 | + |
| 46 | +#### A. New Component: `TeamChannelSelector` |
| 47 | +Create a new component specifically for selecting channels within a team-owned integration: |
| 48 | + |
| 49 | +``` |
| 50 | +frontend/src/components/integration/TeamChannelSelector.tsx |
| 51 | +``` |
| 52 | + |
| 53 | +This component will: |
| 54 | +- Be based on the existing `ChannelList` component |
| 55 | +- Accept team context and integration ID as props |
| 56 | +- Use the integration context for data fetching and state management |
| 57 | +- Show only channels from the specific team-owned integration |
| 58 | +- Maintain the same filtering and search capabilities |
| 59 | +- Connect to team-scoped API endpoints |
| 60 | + |
| 61 | +#### B. New Component: `ChannelAnalysisSettings` |
| 62 | +Create a component for configuring analysis parameters: |
| 63 | + |
| 64 | +``` |
| 65 | +frontend/src/components/integration/ChannelAnalysisSettings.tsx |
| 66 | +``` |
| 67 | + |
| 68 | +This will: |
| 69 | +- Provide date range selection |
| 70 | +- Toggle options (include threads, include reactions) |
| 71 | +- Similar to the form section in the existing `ChannelAnalysisPage` |
| 72 | + |
| 73 | +#### C. New Page: `TeamChannelAnalysisPage` |
| 74 | +Create a new page for running analysis within team context: |
| 75 | + |
| 76 | +``` |
| 77 | +frontend/src/pages/integration/TeamChannelAnalysisPage.tsx |
| 78 | +``` |
| 79 | + |
| 80 | +This will: |
| 81 | +- Be similar to the existing `ChannelAnalysisPage` |
| 82 | +- Maintain team context |
| 83 | +- Use team-scoped API endpoints |
| 84 | + |
| 85 | +### 2. Extend the Integration Context |
| 86 | + |
| 87 | +Update `IntegrationContext.tsx` and `integrationService.ts` to include: |
| 88 | + |
| 89 | +- Channel selection state management |
| 90 | +- Methods for selecting/deselecting channels for analysis |
| 91 | +- Methods for running analysis on selected channels |
| 92 | +- Methods for fetching analysis results |
| 93 | + |
| 94 | +Example additions: |
| 95 | +```typescript |
| 96 | +// New methods for IntegrationContext |
| 97 | +const selectChannelsForAnalysis = async ( |
| 98 | + integrationId: string, |
| 99 | + channelIds: string[] |
| 100 | +): Promise<boolean> => { |
| 101 | + // Implementation |
| 102 | +} |
| 103 | + |
| 104 | +const analyzeChannel = async ( |
| 105 | + integrationId: string, |
| 106 | + channelId: string, |
| 107 | + options: AnalysisOptions |
| 108 | +): Promise<AnalysisResult> => { |
| 109 | + // Implementation |
| 110 | +} |
| 111 | +``` |
| 112 | + |
| 113 | +### 3. Enhance the backend API endpoints |
| 114 | + |
| 115 | +Extend the team-based integration API to support: |
| 116 | +- Marking channels for analysis within team context |
| 117 | +- Running analysis on selected channels |
| 118 | +- Managing bot installation for selected channels |
| 119 | +- Retrieving analysis results with proper team scoping |
| 120 | + |
| 121 | +Example endpoints: |
| 122 | +``` |
| 123 | +POST /api/v1/integrations/{integrationId}/resources/channels/select |
| 124 | +POST /api/v1/integrations/{integrationId}/resources/channels/{channelId}/analyze |
| 125 | +GET /api/v1/integrations/{integrationId}/resources/channels/{channelId}/analysis/{analysisId} |
| 126 | +``` |
| 127 | + |
| 128 | +### 4. Update the routing and navigation |
| 129 | + |
| 130 | +Enhance the application routing to include: |
| 131 | +- Path to channel selection for team integrations |
| 132 | +- Path to channel analysis for team integrations |
| 133 | +- Proper navigation between these views |
| 134 | + |
| 135 | +Example routes: |
| 136 | +```typescript |
| 137 | +<Route path="/dashboard/integrations/:integrationId/channels" element={<TeamChannelSelectorPage />} /> |
| 138 | +<Route path="/dashboard/integrations/:integrationId/channels/:channelId/analyze" element={<TeamChannelAnalysisPage />} /> |
| 139 | +<Route path="/dashboard/integrations/:integrationId/channels/:channelId/analysis/:analysisId" element={<TeamAnalysisResultPage />} /> |
| 140 | +``` |
| 141 | + |
| 142 | +### 5. Enhance the UI for resource management |
| 143 | + |
| 144 | +Update `IntegrationDetail.tsx` and `ResourceList.tsx` to: |
| 145 | +- Add action buttons for channel selection and analysis |
| 146 | +- Provide visual indicators for channels marked for analysis |
| 147 | +- Include proper navigation to channel selection and analysis pages |
| 148 | + |
| 149 | +### 6. Data Migration and Backward Compatibility |
| 150 | + |
| 151 | +Consider: |
| 152 | +- Migrating existing channel selection data to the team-based model |
| 153 | +- Maintaining backward compatibility with existing analysis results |
| 154 | +- Providing a smooth transition path for users |
| 155 | + |
| 156 | +## Implementation Phases |
| 157 | + |
| 158 | +### Phase 1: Core Components and Structure |
| 159 | +1. Create the `TeamChannelSelector` component (simplified version) |
| 160 | +2. Enhance integration context with basic channel selection functionality |
| 161 | +3. Update `ResourceList` to include action buttons for channel management |
| 162 | +4. Implement basic routing for new channel selection views |
| 163 | + |
| 164 | +### Phase 2: Complete UI Implementation |
| 165 | +1. Enhance `TeamChannelSelector` with full filtering and search capabilities |
| 166 | +2. Create the `ChannelAnalysisSettings` component |
| 167 | +3. Implement `TeamChannelAnalysisPage` for running analysis |
| 168 | +4. Update navigation and links throughout the application |
| 169 | + |
| 170 | +### Phase 3: API Integration and Data Flow |
| 171 | +1. Connect UI components to backend API endpoints |
| 172 | +2. Implement proper error handling and loading states |
| 173 | +3. Add data validation and synchronization |
| 174 | +4. Test the complete flow from selection to analysis |
| 175 | + |
| 176 | +### Phase 4: Refinement and Optimization |
| 177 | +1. Improve performance for large channel lists |
| 178 | +2. Enhance UX for channel selection process |
| 179 | +3. Add additional features like bulk selection |
| 180 | +4. Implement proper documentation and user guidance |
| 181 | + |
| 182 | +## Technical Considerations |
| 183 | + |
| 184 | +### State Management |
| 185 | +- Use React context for managing integration and channel selection state |
| 186 | +- Consider using reducers for complex state transitions |
| 187 | +- Implement proper caching for channel data |
| 188 | + |
| 189 | +### Performance |
| 190 | +- Optimize for large channel lists with pagination and virtualization |
| 191 | +- Implement efficient filtering and searching on the client side |
| 192 | +- Consider using web workers for heavy computations |
| 193 | + |
| 194 | +### Security |
| 195 | +- Ensure proper team scoping for all API requests |
| 196 | +- Validate permissions for channel access and analysis |
| 197 | +- Implement proper error handling for unauthorized actions |
| 198 | + |
| 199 | +### UX Considerations |
| 200 | +- Maintain consistent UI patterns with existing components |
| 201 | +- Provide clear feedback during long-running operations |
| 202 | +- Implement progressive loading for large data sets |
| 203 | + |
| 204 | +## Conclusion |
| 205 | + |
| 206 | +This strategy provides a comprehensive approach to implementing the "Select Channels for Analysis" functionality within the team-based integration model. By leveraging existing components from the legacy implementation while enhancing them with team context awareness, we can provide a seamless experience for users transitioning to the new model. |
| 207 | + |
| 208 | +The phased implementation approach allows for incremental development and testing, ensuring that each component functions correctly before moving on to the next phase. |
0 commit comments