Skip to content

fix(site): display tasks link when no templates contain an AI task #19184

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 5, 2025

Conversation

DanielleMaywood
Copy link
Contributor

Fixes #19059

We now remove the call to HasTemplateVersionsWithAITask, and set tasks-tab-visible to the opposite of HideAITasks. As this was the only usage of HasTemplateVersionsWithAITask, the query has been removed. If required, it can always be added back in the future.

Fixes #19059

We now remove the call to `HasTemplateVersionsWithAITask`, and set
`tasks-tab-visible` to the opposite of `HideAITasks`. As this was the
only usage of `HasTemplateVersionsWithAITask`, the query has been
removed. If required, it can always be added back in the future.
@DanielleMaywood DanielleMaywood changed the title fix(site): show Tasks link when no templates have an AI task fix(site): display tasks link when no templates contain an AI task Aug 5, 2025
@DanielleMaywood DanielleMaywood marked this pull request as ready for review August 5, 2025 15:28
@DanielleMaywood
Copy link
Contributor Author

@coderabbitai review

Copy link

coderabbitai bot commented Aug 5, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

coderabbitai bot commented Aug 5, 2025

📝 Walkthrough

Walkthrough

This change removes all code related to dynamically checking the database for the presence of AI task templates to control the visibility of the Tasks tab. Instead, the Tasks tab visibility is now determined solely by the HideAITasks configuration flag. The frontend placeholder for no task templates now includes a documentation link.

Changes

Cohort / File(s) Change Summary
Backend: Remove AI task template existence check
coderd/database/dbauthz/dbauthz.go, coderd/database/dbmetrics/querymetrics.go, coderd/database/dbmock/dbmock.go, coderd/database/querier.go, coderd/database/queries.sql.go, coderd/database/queries/templateversions.sql
Removed the HasTemplateVersionsWithAITask method and related SQL, interface, mock, and metrics code throughout the backend.
Backend: Test cleanup
coderd/database/dbauthz_test.go
Removed the test for the deleted HasTemplateVersionsWithAITask method.
Backend: Site logic
site/site.go
Removed the goroutine and logic that checked for AI task templates in the database; Tasks tab visibility now depends only on the HideAITasks option.
Frontend: Tasks page placeholder
site/src/pages/TasksPage/TasksPage.tsx
Updated the placeholder to include a documentation link when no task templates are found.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Frontend
    participant Backend

    User->>Frontend: Load site
    Frontend->>Backend: (No longer queries for AI task templates)
    Frontend->>Frontend: Show Tasks tab if !HideAITasks
    Frontend->>User: Display Tasks tab and placeholder with docs link if no templates
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Assessment against linked issues

Objective Addressed Explanation
Always show the link to /tasks in the top navbar (#19059)
If no tasks-compatible templates are configured, show a CTA with a link to the tasks documentation (#19059)
Ensure the existing env CODER_HIDE_AI_TASKS is still respected (#19059)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes detected.

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 760dc8b and 6b14b89.

📒 Files selected for processing (9)
  • coderd/database/dbauthz/dbauthz.go (0 hunks)
  • coderd/database/dbauthz/dbauthz_test.go (0 hunks)
  • coderd/database/dbmetrics/querymetrics.go (0 hunks)
  • coderd/database/dbmock/dbmock.go (0 hunks)
  • coderd/database/querier.go (0 hunks)
  • coderd/database/queries.sql.go (0 hunks)
  • coderd/database/queries/templateversions.sql (0 hunks)
  • site/site.go (1 hunks)
  • site/src/pages/TasksPage/TasksPage.tsx (3 hunks)
💤 Files with no reviewable changes (7)
  • coderd/database/queries/templateversions.sql
  • coderd/database/querier.go
  • coderd/database/dbauthz/dbauthz_test.go
  • coderd/database/queries.sql.go
  • coderd/database/dbmetrics/querymetrics.go
  • coderd/database/dbauthz/dbauthz.go
  • coderd/database/dbmock/dbmock.go
🧰 Additional context used
🧠 Learnings (12)
📚 Learning: applies to enterprise/audit/table.go : if a feature touches audit logs, update enterprise/audit/tabl...
Learnt from: CR
PR: coder/coder#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-28T00:33:10.063Z
Learning: Applies to enterprise/audit/table.go : If a feature touches audit logs, update enterprise/audit/table.go.

Applied to files:

  • site/site.go
📚 Learning: applies to enterprise/audit/table.go : if audit errors occur after database changes, update enterpri...
Learnt from: CR
PR: coder/coder#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-28T00:33:07.777Z
Learning: Applies to enterprise/audit/table.go : If audit errors occur after database changes, update enterprise/audit/table.go.

Applied to files:

  • site/site.go
📚 Learning: applies to enterprise/audit/table.go : if audit errors occur after database changes, update enterpri...
Learnt from: CR
PR: coder/coder#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-28T00:33:07.155Z
Learning: Applies to enterprise/audit/table.go : If audit errors occur after database changes, update enterprise/audit/table.go and run make gen again.

Applied to files:

  • site/site.go
📚 Learning: applies to site/src/**/*.tsx : mui components are deprecated - migrate away from these when encounte...
Learnt from: CR
PR: coder/coder#0
File: site/CLAUDE.md:0-0
Timestamp: 2025-07-21T14:33:50.957Z
Learning: Applies to site/src/**/*.tsx : MUI components are deprecated - migrate away from these when encountered

Applied to files:

  • site/src/pages/TasksPage/TasksPage.tsx
📚 Learning: applies to site/src/**/*.tsx : use shadcn/ui components first - check site/src/components for existi...
Learnt from: CR
PR: coder/coder#0
File: site/CLAUDE.md:0-0
Timestamp: 2025-07-21T14:33:50.957Z
Learning: Applies to site/src/**/*.tsx : Use shadcn/ui components first - check site/src/components for existing implementations

Applied to files:

  • site/src/pages/TasksPage/TasksPage.tsx
📚 Learning: applies to site/src/**/*.tsx : prefer tailwind utilities over custom css when possible...
Learnt from: CR
PR: coder/coder#0
File: site/CLAUDE.md:0-0
Timestamp: 2025-07-21T14:33:50.957Z
Learning: Applies to site/src/**/*.tsx : Prefer Tailwind utilities over custom CSS when possible

Applied to files:

  • site/src/pages/TasksPage/TasksPage.tsx
📚 Learning: applies to site/src/**/*.tsx : replace emotion `css` prop with tailwind classes...
Learnt from: CR
PR: coder/coder#0
File: site/CLAUDE.md:0-0
Timestamp: 2025-07-21T14:33:50.957Z
Learning: Applies to site/src/**/*.tsx : Replace Emotion `css` prop with Tailwind classes

Applied to files:

  • site/src/pages/TasksPage/TasksPage.tsx
📚 Learning: applies to site/src/**/*.{ts,tsx} : use es modules (import/export) syntax, not commonjs (require)...
Learnt from: CR
PR: coder/coder#0
File: site/CLAUDE.md:0-0
Timestamp: 2025-07-21T14:33:50.957Z
Learning: Applies to site/src/**/*.{ts,tsx} : Use ES modules (import/export) syntax, not CommonJS (require)

Applied to files:

  • site/src/pages/TasksPage/TasksPage.tsx
📚 Learning: applies to site/**/*.tsx : all user-facing frontend code is developed in typescript using react and ...
Learnt from: CR
PR: coder/coder#0
File: .cursorrules:0-0
Timestamp: 2025-07-21T14:32:43.064Z
Learning: Applies to site/**/*.tsx : All user-facing frontend code is developed in TypeScript using React and lives in the `site/` directory.

Applied to files:

  • site/src/pages/TasksPage/TasksPage.tsx
📚 Learning: applies to site/src/**/*.tsx : leverage custom color tokens: content-primary, surface-secondary, etc...
Learnt from: CR
PR: coder/coder#0
File: site/CLAUDE.md:0-0
Timestamp: 2025-07-21T14:33:50.957Z
Learning: Applies to site/src/**/*.tsx : Leverage custom color tokens: content-primary, surface-secondary, etc.

Applied to files:

  • site/src/pages/TasksPage/TasksPage.tsx
📚 Learning: applies to site/**/*.ts : all user-facing frontend code is developed in typescript using react and l...
Learnt from: CR
PR: coder/coder#0
File: .cursorrules:0-0
Timestamp: 2025-07-21T14:32:43.064Z
Learning: Applies to site/**/*.ts : All user-facing frontend code is developed in TypeScript using React and lives in the `site/` directory.

Applied to files:

  • site/src/pages/TasksPage/TasksPage.tsx
📚 Learning: applies to site/src/**/*.{ts,tsx} : never mutate props, state, or values returned by hooks. always c...
Learnt from: CR
PR: coder/coder#0
File: site/CLAUDE.md:0-0
Timestamp: 2025-07-21T14:33:50.957Z
Learning: Applies to site/src/**/*.{ts,tsx} : Never mutate props, state, or values returned by Hooks. Always create new objects or use the setter from useState.

Applied to files:

  • site/src/pages/TasksPage/TasksPage.tsx
🔇 Additional comments (4)
site/src/pages/TasksPage/TasksPage.tsx (3)

16-16: LGTM! Good addition of Link component import.

The Link component import aligns with the PR objective to provide better user guidance through documentation links.


64-64: LGTM! Proper use of docs utility.

The docs utility import is correctly used for generating documentation URLs.


144-147: Excellent UX improvement with documentation link.

The replacement of static text with a clickable documentation link significantly enhances user experience when no task templates are available. The implementation correctly:

  • Uses proper link attributes (target="_blank", rel="noreferrer")
  • Points to the appropriate AI tasks documentation
  • Maintains the existing text flow while making "Learn about Tasks" actionable

This change perfectly complements the backend simplification by providing direct access to documentation rather than relying on database-driven UI state.

site/site.go (1)

559-559: Excellent simplification of tasks tab visibility logic.

The change from database-driven to configuration-driven visibility determination is a significant architectural improvement that:

  • Eliminates unnecessary complexity: Removes database query and related infrastructure
  • Improves performance: No more concurrent database operations for UI state
  • Increases reliability: Removes dependency on database availability for basic UI rendering
  • Maintains correctness: The !h.opts.HideAITasks logic properly inverts the hide flag to determine visibility

This change perfectly aligns with the PR objective of always showing the Tasks tab based on configuration rather than dynamic database content, with the frontend now handling the empty state gracefully through documentation links.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch danielle/tasks/button-not-visible

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Member

@johnstcn johnstcn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Backend changes look good to me!
Deferring to Bruno on the copy changes.

Copy link
Collaborator

@BrunoQuaresma BrunoQuaresma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@DanielleMaywood DanielleMaywood merged commit cc609cb into main Aug 5, 2025
36 of 38 checks passed
@DanielleMaywood DanielleMaywood deleted the danielle/tasks/button-not-visible branch August 5, 2025 18:30
@github-actions github-actions bot locked and limited conversation to collaborators Aug 5, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Show Tasks tab when no AI tasks are configured
3 participants