Skip to content

JACoB PR for Issue Bug: Generate Research Button State Incorrect When Switching Todos#121

Draft
jacob-local-kevin[bot] wants to merge 1 commit intomainfrom
jacob-issue-120-1728589395687
Draft

JACoB PR for Issue Bug: Generate Research Button State Incorrect When Switching Todos#121
jacob-local-kevin[bot] wants to merge 1 commit intomainfrom
jacob-issue-120-1728589395687

Conversation

@jacob-local-kevin
Copy link
Contributor

Summary:

Description

There is a bug in the Todo frontend within the dashboard. When a user clicks the Generate Research button for a specific todo and then navigates to a different todo, the Generate Research button remains grayed out and indicates that research is still being generated. This behavior persists because the generate state is managed by a single boolean value, affecting all todos instead of individually.

Steps to Reproduce

  1. Navigate to the dashboard containing the Todo list.
  2. Select a todo item and click the Generate Research button.
  3. While the research is being generated (button is grayed out), switch to a different todo item.
  4. Observe the state of the Generate Research button on the new todo.

Current Behavior

  • After initiating research generation for one todo, switching to another todo causes the Generate Research button on the new todo to remain grayed out and display that research is being generated, even though no generation process has been started for the new todo.

Expected Behavior

  • The Generate Research button should only be disabled and show a loading state for the specific todo that is generating research. Switching to a different todo should show the Generate Research button in its normal state, allowing the user to initiate research generation independently for each todo.

Proposed Solution

  • Refactor the generate state from a single boolean value to a map of boolean values, where each boolean corresponds to the generate state of an individual todo. This ensures that the loading state is managed separately for each todo item.

Additional Information

  • Environment: Frontend dashboard application
  • Component Affected: Todo List Component

@jacob-ai-bot

Plan:

  1. Identify the parent component (Todo.tsx) that renders TodoItem components.
  2. Update Todo.tsx to use useState for a generateStates map.
  3. Implement handleGenerateResearch function in Todo.tsx.
  4. Modify TodoItem.tsx to accept isGenerating and onGenerateResearch props.
  5. Update the Generate Research button in TodoItem.tsx to use these props.
  6. Test the implementation thoroughly.
  7. Optionally update CSS for button states.

@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 npm@10.8.2
npm info using node@v20.10.0
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-10-10T19_43_27_348Z-
npm verbose logfile /Users/kleneway/.npm/_logs/2024-10-10T19_43_27_348Z-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 npm@10.8.2
npm info using node@v20.10.0
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-10-10T19_43_27_607Z-
npm verbose logfile /Users/kleneway/.npm/_logs/2024-10-10T19_43_27_607Z-debug-0.log


===== TS errors =====

[Test Mode] ./src/app/dashboard/[org]/[repo]/todos/Todo.tsx:114:51
Type error: Argument of type '{ todoId: number; org: string; repo: string; }' is not assignable to parameter of type '{ org: string; repo: string; issueId: number; todoId: number; githubIssue: string; }'.
  Type '{ todoId: number; org: string; repo: string; }' is missing the following properties from type '{ org: string; repo: string; issueId: number; todoId: number; githubIssue: string; }': issueId, githubIssue

  112 |     setGenerateStates((prev) => ({ ...prev, [todoId]: true }));
  113 |     try {
> 114 |       await trpcClient.todos.researchIssue.mutate({ todoId, org, repo });
      |                                                   ^
  115 |     } catch (error) {
  116 |       console.error("Error generating research:", error);
  117 |     } finally {

[Test Mode] ./src/app/dashboard/[org]/[repo]/todos/Todo.tsx:181:13
Type error: Type '{ selectedTodo: Todo; selectedIssue: Issue | null; isLoadingIssue: boolean; onTodoUpdate: (todo: Todo) => void; org: string; repo: string; isGenerating: boolean; onGenerateResearch: () => Promise<...>; }' is not assignable to type 'IntrinsicAttributes & IssueProps'.
  Property 'isGenerating' does not exist on type 'IntrinsicAttributes & IssueProps'.

  179 |             org={org}
  180 |             repo={repo}
> 181 |             isGenerating={!!generateStates[selectedTodo.id]}
      |             ^
  182 |             onGenerateResearch={() => handleGenerateResearch(selectedTodo.id)}
  183 |           />
  184 |         ) : (

===== TS errors =====


Failed to compile.

./src/app/dashboard/[org]/[repo]/todos/Todo.tsx:114:51
Type error: Argument of type '{ todoId: number; org: string; repo: string; }' is not assignable to parameter of type '{ org: string; repo: string; issueId: number; todoId: number; githubIssue: string; }'.
  Type '{ todoId: number; org: string; repo: string; }' is missing the following properties from type '{ org: string; repo: string; issueId: number; todoId: number; githubIssue: string; }': issueId, githubIssue

  112 |     setGenerateStates((prev) => ({ ...prev, [todoId]: true }));
  113 |     try {
> 114 |       await trpcClient.todos.researchIssue.mutate({ todoId, org, repo });
      |                                                   ^
  115 |     } catch (error) {
  116 |       console.error("Error generating research:", error);
  117 |     } finally {
npm verbose cwd /private/tmp/tmp-43813-lj50bRVFicmt
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-43813-lj50bRVFicmt
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.

5 similar comments
@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

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

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

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

JACoB here...

I'm busy working on this error.

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

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.

0 participants