Skip to content

Conversation

@jacob-local-kevin
Copy link
Contributor

Changes Performed:

Step 1: Add researchIssue Mutation to Todo Router

Files:

/src/server/api/routers/todos.ts

Details:

  1. Import the z object from the zod library for input validation. Import ResearchAgentActionType and callFunction from /src/server/agent/research.ts.
  2. Create a Zod schema for the input of the researchIssue mutation, including issueId as a string.
  3. Add a new mutation named researchIssue using protectedProcedure in the todoRouter. Validate the input using the defined Zod schema. Implement the resolver to call the research function and handle the creation of research items.
  4. Ensure that the todoRouter includes the newly added researchIssue mutation.

Exit Criteria

A new researchIssue mutation is successfully added to the todoRouter. The mutation includes proper input validation using Zod. Error handling is implemented to manage potential failures during research generation. The mutation interacts correctly with the research table in the database.

Step 2: Update Research Agent to Support researchIssue

Files:

/src/server/agent/research.ts

Details:

  1. Ensure that ResearchAgentActionType and any other required types or functions are imported.
  2. Add a new case or extend existing logic to handle the GenerateResearch action type. Define the GenerateResearch action within the ResearchAgentActionType enum if not already present.
  3. Implement a generateResearch function to perform the necessary research operations based on issueId.

Exit Criteria

The ResearchAgentActionType enum includes the GenerateResearch action type. The callFunction method can handle the GenerateResearch action. A new generateResearch function is implemented to perform the necessary research operations based on issueId.

Step 3: Include researchIssue Mutation in TRPC Client Configuration

Files:

/src/trpc/client.tsx

Details:

  1. Ensure that the AppRouter includes the new researchIssue mutation.
  2. Add the researchIssue mutation to the TRPC client configuration to enable frontend access.

Exit Criteria

The TRPC client (trpcClient) is aware of and can access the researchIssue mutation. No errors occur during the client setup related to the new mutation.

Step 4: Add Research Button and Handle Research Generation in Issue Component

Files:

/src/app/dashboard/[org]/[repo]/todos/components/Issue.tsx

Details:

  1. Import the trpc client and any necessary UI components such as buttons and loading indicators.
  2. Add a new button labeled "Research" that triggers the researchIssue mutation when clicked.
  3. Define a handleResearch function that calls the researchIssue mutation using TRPC. Manage loading states and handle success or error responses.
  4. Ensure that after successful research generation, the component refetches the latest research items to display them.
  5. Implement error handling and loading states using toast notifications.

Exit Criteria

A "Research" button is added to the "Research" section of the Issue component. Clicking the "Research" button triggers the researchIssue mutation. The component displays appropriate loading states while the mutation is in progress. Success and error notifications are shown based on the mutation outcome. Upon successful research generation, the component refetches and displays the new research items.

Step 5: Modify Todo Component to Handle Refetching of Research Items

Files:

/src/app/dashboard/[org]/[repo]/todos/Todo.tsx

Details:

  1. Ensure that the Todo component imports TRPC hooks to fetch and refetch research items.
  2. After the researchIssue mutation is successful, ensure that the Todo component refetches the relevant research items.
  3. If the Todo component manages state related to research items, ensure that it listens for updates and refetches data accordingly.
  4. Verify that the Todo component receives updated research items and displays them appropriately in the UI.

Exit Criteria

The Todo component successfully refetches and displays new research items after the researchIssue mutation is completed. Loading states and data consistency are maintained during and after refetching. No errors occur during the refetching process, and the UI updates reflect the latest research items.

Step 6: Update Research Table if Necessary

Files:

/src/server/db/tables/research.table.ts

Details:

  1. Examine the existing ResearchTable schema to ensure it supports all necessary fields for the researchIssue mutation.
  2. Verify that the table includes columns for todoId, issueId, type, question, and answer. If any additional fields are required, add them accordingly.
  3. If new columns are added, create and run a corresponding migration script to update the database schema.
  4. Ensure that all TypeScript types related to the ResearchTable are updated to reflect any schema changes.

Exit Criteria

The ResearchTable schema fully supports all data requirements for the new researchIssue mutation. Any necessary additional columns are added, and corresponding migrations are successfully executed. TypeScript type definitions are updated to maintain type safety and consistency across the codebase.

@jacob-ai-bot fix error

Error Message:

Command failed: __NEXT_TEST_MODE=1 SKIP_ENV_VALIDATION=1 npm run build --verbose && npx tsc --noEmit
npm verbose cli /Users/kleneway/.nvm/versions/node/v20.10.0/bin/node /Users/kleneway/.nvm/versions/node/v20.10.0/bin/npm
npm info using [email protected]
npm info using [email protected]
npm verbose title npm run build
npm verbose argv "run" "build" "--loglevel" "verbose"
npm verbose logfile logs-max:10 dir:/Users/kleneway/.npm/_logs/2024-09-16T20_48_06_079Z-
npm verbose logfile /Users/kleneway/.npm/_logs/2024-09-16T20_48_06_079Z-debug-0.log
npm verbose cli /Users/kleneway/.nvm/versions/node/v20.10.0/bin/node /Users/kleneway/.nvm/versions/node/v20.10.0/lib/node_modules/npm/bin/npm-cli.js
npm info using [email protected]
npm info using [email protected]
npm verbose title npm run build:1-next
npm verbose argv "run" "build:1-next"
npm verbose logfile logs-max:10 dir:/Users/kleneway/.npm/_logs/2024-09-16T20_48_06_311Z-
npm verbose logfile /Users/kleneway/.npm/_logs/2024-09-16T20_48_06_311Z-debug-0.log
Failed to compile.

./src/app/dashboard/[org]/[repo]/todos/Todo.tsx
Error: 
  x Expected ',', got ';'
     ,-[/private/tmp/tmp-49525-q7H9RLiDxPoj/src/app/dashboard/[org]/[repo]/todos/Todo.tsx:183:1]
 183 |       </div>
 184 |     </div>
 185 |   );
 186 | };
     :  ^
 187 | 
 188 | export default Todo;
     `----

Caused by:
    Syntax Error

Import trace for requested module:
./src/app/dashboard/[org]/[repo]/todos/Todo.tsx
./src/app/dashboard/[org]/[repo]/todos/page.tsx

./src/server/agent/research.ts
Error: 
  x the name `githubIssue` is bound more than once in this parameter list
     ,-[/private/tmp/tmp-49525-q7H9RLiDxPoj/src/server/agent/research.ts:254:1]
 254 | };
 255 | 
 256 | async function callFunction(
 257 |   githubIssue: string | number,
     :   ^^^^^^^^^^^^^^|^^^^^^^^^^^^^
     :                 `-- previous definition here
 258 |   args: { query: string },
 259 |   githubIssue: string,
     :   ^^^^^^^^^|^^^^^^^^^
     :            `-- used as parameter more than once
 260 |   sourceMap: string,
 261 |   rootDir: string,
 262 |   codebaseContext: ContextItem[],
     `----

Import trace for requested module:
./src/server/agent/research.ts
./src/server/db/tables/research.table.ts
./src/server/db/db.ts
./src/app/api/chat/route.ts


> Build failed because of webpack errors
npm verbose cwd /private/tmp/tmp-49525-q7H9RLiDxPoj
npm verbose os Darwin 23.4.0
npm verbose node v20.10.0
npm verbose npm  v10.8.2
npm verbose exit 1
npm verbose code 1
ERROR: "build:1-next" exited with 1.
npm verbose cwd /private/tmp/tmp-49525-q7H9RLiDxPoj
npm verbose os Darwin 23.4.0
npm verbose node v20.10.0
npm verbose npm  v10.8.2
npm verbose exit 1
npm verbose code 1

@jacob-local-kevin
Copy link
Contributor Author

JACoB here...

I'm busy working on this error.

I'll continue to comment on this pull request with status as I make progress.

@jacob-local-kevin
Copy link
Contributor Author

Unfortunately, I ran into trouble working on this.

Here is some error information:

errors.reduce is not a function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant