Skip to content

Conversation

bcpeinhardt
Copy link
Contributor

This PR:

  • Adds the tasks-docker template to the embeded template examples
  • Makes the tasks-docker template the leading template on the starter-templates page
  • Makes the tasks-docker template the leading template on the featured templates list (in EmptyTemplates)

closes #19718

Screen.Recording.2025-10-03.at.4.24.43.PM.mov

const sortVisibleTemplates = (templates: TemplateExample[]) => {
// The docker template should be the first template in the list,
// as it's the easiest way to get started with Coder.
const dockerTemplateId = "docker";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previously, the docker template was being moved to the front of the list in the frontend. We simply swapped that for the tasks-docker template.

Copy link
Member

Choose a reason for hiding this comment

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

Just to make sure I'm understanding the product goal: are we okay with dropping the old Docker template entirely, or would we still want it to be second in the list? We still have the Docker template as the second one for the empty templates component

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The docker template is just no longer the very first template displayed. It's still in the list we're sorting it's just ordered based on its name rather than being manually pulled to the front.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Product wise I think these are meant to be different lists. The EmptyTemplates component is only ever seen when your deployment has no templates pushed, whereas the starter-templates page is more likely to be encountered by a typical developer looking to make a quick template.
But also I'm okay with simply making the docker template second here too.

//go:embed templates/kubernetes-devcontainer
//go:embed templates/nomad-docker
//go:embed templates/scratch
//go:embed templates/tasks-docker
Copy link
Contributor Author

@bcpeinhardt bcpeinhardt Oct 3, 2025

Choose a reason for hiding this comment

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

We currently embed the starter template in the binary. This is where we add the tasks-docker template to the list (the examples/templates/tasks-docker directory contains its contents copied from https://github.com/coder/registry/tree/main/registry/coder-labs/templates/tasks-docker).

@bcpeinhardt bcpeinhardt force-pushed the bcpeinhardt/add-run-coder-tasks-on-docker-to-starter-templates branch from 6974c83 to b865e8a Compare October 3, 2025 21:52
@bcpeinhardt bcpeinhardt marked this pull request as draft October 3, 2025 21:52
USAGE:
  coder templates init [flags] [directory]

  Get started with a templated template.

OPTIONS:
      --id aws-devcontainer|aws-linux|aws-windows|azure-linux|digitalocean-linux|docker|docker-devcontainer|docker-envbuilder|gcp-devcontainer|gcp-linux|gcp-vm-container|gcp-windows|kubernetes|kubernetes-devcontainer|nomad-docker|scratch
          Specify a given example template by ID.

———
Run `coder --help` for a list of global options.
@bcpeinhardt bcpeinhardt marked this pull request as ready for review October 3, 2025 22:06
Copy link
Member

@Parkreiner Parkreiner left a comment

Choose a reason for hiding this comment

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

Looks good to me overall. The StarterTemplate page has some Emotion styling still, but I have a PR that removes that, so it's not a big deal to take care of that here


![Tasks](../../.images/tasks-screenshot.png)

This is a fantastic starting point for working with AI agents with Coder Tasks. Try prompts such as:
Copy link
Member

Choose a reason for hiding this comment

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

Nit: I feel like "fantastic" feels too qualitative and feels kinda like AI output

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Haha I copied this source directly from the existing template in the registry, It should probably stay the same until we integrate registry into the core product, but I agree it feels like an AI wrote this.

const sortVisibleTemplates = (templates: TemplateExample[]) => {
// The docker template should be the first template in the list,
// as it's the easiest way to get started with Coder.
const dockerTemplateId = "docker";
Copy link
Member

Choose a reason for hiding this comment

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

Just to make sure I'm understanding the product goal: are we okay with dropping the old Docker template entirely, or would we still want it to be second in the list? We still have the Docker template as the second one for the empty templates component

import { docs } from "utils/docs";

// Those are from https://github.com/coder/coder/tree/main/examples/templates
const featuredExampleIds = [
Copy link
Member

@Parkreiner Parkreiner Oct 6, 2025

Choose a reason for hiding this comment

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

Nothing wrong with this file, but it looks like it'd be pretty easy to swap in Tailwind here.

If we get rid of the styles object, we should be able to add className="max-w-[50%] h-80 overflow-hidden opacity-85 [&_img]:max-w-full" to the div, and that should be equivalent

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm down to look at doing this together 😎

@aslilac
Copy link
Member

aslilac commented Oct 6, 2025

why are we unpinning the regular docker template?

@bcpeinhardt
Copy link
Contributor Author

why are we unpinning the regular docker template?

The ticket ask was to pin the Tasks on Docker Template first. I can update the PR to keep the Docker template pinned in the second slot. From the code I sort of thought the idea was to have one pinned template at a time and the rest organized by name. I think maybe the better solution though is to have the set of "featured templates" apply to the starter-templates page as well as the EmptyTemplates component.

@aslilac
Copy link
Member

aslilac commented Oct 6, 2025

agreed. having a simple template front and center that doesn't require spending a bunch of cloud provider money is a great way to ease into the product.

@david-fraley
Copy link
Collaborator

@bcpeinhardt Agree with your approach and thoughts here. Having the Tasks On Docker first makes for a super easy entry point to Tasks, but it wasn't the intention to have the Docker template fall to the wayside. Having it be the 2nd in the list is what I was hoping for! I like the idea of a "featured templates" section!
cc @aslilac

bcpeinhardt and others added 2 commits October 14, 2025 16:03
Addresses review feedback to keep the regular 'docker' template
as the second featured template after 'tasks-docker'.

Sorting order is now:
1. tasks-docker (easiest entry point)
2. docker (keeps original docker template featured)
3. All others sorted alphabetically

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link
Member

@aslilac aslilac left a comment

Choose a reason for hiding this comment

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

this sort algorithm feels like too much now imo. I really liked your idea of just breaking things up into a "featured" section and everything else.

even if we don't do that yet, in utils/starterTemplates.ts there's a function that this templates value we end up with is coming from, and that does some processing already. I think we could update that function to pull this logic out of React and consolidate things.

Comment on lines +31 to +36
if (a.id === tasksDockerTemplateId) {
return -1;
}
if (b.id === tasksDockerTemplateId) {
return 1;
}
Copy link
Member

Choose a reason for hiding this comment

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

this is technically an unstable sort because you're not handling a.id === b.id. there shouldn't ever be duplicates, but it's worth thinking about the ramifications.

Comment on lines 37 to 39
if (a.id === dockerTemplateId) {
return -1;
}
Copy link
Member

Choose a reason for hiding this comment

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

I also worry that it's super unclear why this sort works the way it does. I kinda wish templates just didn't include the docker or tasks-docker templates at all so that it could have a normal sort, and that things sorted "manually" were just in an obvious order, rather than having a complicated looking algorithm that takes up more lines of code than hardcoding the order would.

this pattern was already too clever for it's own good, but with this additional case now it's even more so.

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.

Tasks on Docker Template Should Appear First in the Start Templates List

4 participants