worktrunk icon indicating copy to clipboard operation
worktrunk copied to clipboard

[Question] Is there a way to list all the ports interpolated in the wt.toml file?

Open EduardoSimon opened this issue 9 months ago • 7 comments

We have several ports configured, basically for next and supabase, something like:

env = "cd ./control_plane_ui && echo 'PORT={{ branch | hash_port }}\nNEXT_PUBLIC_SUPABASE_URL=http://127.0.0.1:{{ ('supabase-api-' ~ branch) | hash_port }}\nSUPABASE_API_PORT={{ ('supabase-api-' ~ branch) | hash_port }}\nSUPABASE_DB_PORT={{ ('db-' ~ branch) | hash_port }}\nSUPABASE_STUDIO_PORT={{ ('studio-' ~ branch) | hash_port }}' >> .env.local"

It would be ideal to be able to see the ports when running wt list, but I understand that would clutter the view.

How about inside wt config state?

EduardoSimon avatar Feb 08 '26 09:02 EduardoSimon

v interesting!

what would you like the view to look like? how about if we allowed arbitrary text in wt list; would they all fit?

we could def put this elsewhere, but maybe we can fit it in

or possibly there's a general solution to allowing status text, either in list or somewhere else

max-sixty avatar Feb 08 '26 14:02 max-sixty

I would love something like the custom format in docker CLI:

$ docker ps --format '{{.Names}}'
supabase_db_control_plane_ui
supabase_studio_control_plane_ui
supabase_pg_meta_control_plane_ui
supabase_rest_control_plane_ui
supabase_kong_control_plane_ui

so you can customize it for your needs.

Or just having it on the JSON output, so I can create an alias/script parsing that output.

andoniaf avatar Feb 08 '26 15:02 andoniaf

we could definitely do something like that

could you try wt list --output=json | jq $expr to try some cases?

(or maybe jq is actually sufficient for that case? would still need to add for the multiple urls case though)

maybe this is some notion of storing arbitrary state per worktree and then being able to display / query it?

max-sixty avatar Feb 08 '26 16:02 max-sixty

maybe this is some notion of storing arbitrary state per worktree and then being able to display / query it?

Yes! I was playing a bit with ideas (while Claude was working on other stuff 😅) and I saw I can do this for all worktrees:

$ wt step for-each -- echo '{{ branch }},{{ branch | hash_port }},{{ ("supabase-api-" ~ branch) | hash_port }},{{ ("db-" ~ branch) | hash_port }}'
◎ Running in main...
main,12107,14260,16406
◎ Running in auto/customizing-tool-parameters...
auto/customizing-tool-parameters,16066,16739,14573
◎ Running in log-alias...
log-alias,19471,18599,17463

but found no way to run it on a single branch.

For us maybe just having the option to run that in a single branch could be enough, but I like the idea of wt config state.

andoniaf avatar Feb 08 '26 17:02 andoniaf

Two draft PRs addressing this:

  • #1004 — wt step eval for evaluating template expressions on a single branch
  • #1006 — wt config state kv for storing/retrieving arbitrary per-branch data, also available in templates via {{ kv.key }}

Together these cover both computed values (wt step eval '{{ branch | hash_port }}') and stored values (wt config state kv set env staging → {{ kv.env }}).

This was written by Claude Code on behalf of @max-sixty

max-sixty avatar Feb 13 '26 22:02 max-sixty

feedback on those two PR would be v welcome!

max-sixty avatar Feb 19 '26 16:02 max-sixty

Both PRs linked by the maintainer are now merged:

  • wt step eval (PR #1004) — merged 2026-03-16
  • wt config state vars (PR #1006, commit 69edc3a3) — merged 2026-03-30

Together these provide two ways to access interpolated values: wt step eval '{{ branch | hash_port }}' for computed template values, and wt config state vars for storing/retrieving arbitrary per-branch variables in all template contexts.

worktrunk-bot avatar Mar 31 '26 06:03 worktrunk-bot