Repository navigation
feat(app): show where automations run and which session they wake - #66393
Conversation
There was a problem hiding this comment.
I couldn't run this one: there are no Playwright browsers here, so I didn't run the e2e spec or open the view. typecheck:tsc in packages/app passes, the controller and layout unit tests pass, and I read the code against the server's automation and command handlers.
Public API: unchanged. The plugin's AppIconName union gains "clock", which is additive. The rest is app-internal and uses the existing /api/experimental/automation routes.
Main concern: AutomationSourceProvider wraps the whole AppLayout. On every launch it calls command.list for every used project and open tab on every connected server, and every one of those requests makes the server set up that project. It also polls the automation list on every connected server, including ones with automations off. Details are inline. Scoping this to what's actually needed would make it safe to keep in the global shell.
| ? [tab.directory] | ||
| : [ctx.data.session.get(tab.routeSessionId ?? tab.sessionId)?.location.directory], | ||
| ), | ||
| ...ctx.projects.used().map((p) => p.worktree), |
There was a problem hiding this comment.
This provider wraps the whole AppLayout, so at startup this list (every projects.used() worktree and every tab's directory, on every connected server) feeds the effect below, which calls command.list for each directory. On the server each of those requests goes through the location middleware and sets up that project (config, plugins and so on). new-session/workspace/controller.ts warns about exactly this for vcs.sync. The first automationList query also runs for every connected server, whatever offered says, so servers with automations off get a request that fails with 403 on each launch.
Could discovery be limited to directories that are already loaded (the active route or draft, the home selection), or only fan out once the user opens /automations? And could the list query be disabled (enabled: offered, or after a cached capability check) for servers that don't expose /automation?
There was a problem hiding this comment.
fixed in the latest push
- outside
/automationsdiscovery only asks about folders that are already open (the active session or draft, the home selection, the last target). tabs and used projects are only checked while the view is open - the list query is disabled (
enabled: offered || open) for servers that don't offer/automationin any open folder
fwiw the unfiltered list doesn't 403 when automations are off, it drops rows whose folders have them off (Automation.list), but yeah it was still a request we didn't need
There was a problem hiding this comment.
The latest push (e1ece2586) fixes both points. I read pr/head:packages/app/src/automations/source.ts.
- Discovery: outside
/automations, only these folders are checked: the active session or draft, the home selection and the last target. Tabs andprojects.used()are only checked while the route isautomations. Startup no longer sets up every project location. - List query: with
enabled: offered || open, servers that don't offer/automationin any open folder aren't asked until the view opens. You're right thatAutomation.listfilters rows instead of returning 403. I was wrong about that. - Loading state: in TanStack v5, a disabled query that has no data still counts as
isPending, soloading()would stay true for those servers. That doesn't matter here: the view only usesloading()inroute.tsx:91androute.tsx:96, and on that route every query is enabled. Just don't reuseloading()anywhere outside the view. - Removing
refresh: nothing calls it any more. - One trade-off: the sidebar or titlebar entry (
available()) now depends on open folders, the home-dir fallback, or list data a disabled query still has cached. With no open folder, the home-dir fallback covers it while the global config has automations on, which is the default. If a user turned the global config off but has automations in a project that isn't open, they won't see the entry until they open that project. I think that's fine.
I only read the diff. I didn't run typecheck or the e2e tests. The local repo/ checkout is still on the previous commit, and I changed nothing in it.
There was a problem hiding this comment.
small correction: reverted the enabled: offered || open part. automations are global per server, so the list is fetched once per server again and the entry shows whenever there are rows. only the empty state / new automation still needs an open folder offering /automation. the discovery scoping stays
There was a problem hiding this comment.
Agreed, that's the right call. In 5f0605c3c there's one list request per connected server at launch. A server keeps polling while it has rows or an open folder offers /automation, and stops while it has neither. available() is still entries().length > 0 || enabled().length > 0. Discovery is still limited to open folders. One request per server at launch is fine.
One small catch: if a server's first response is empty and no open folder offers /automation, its query never refetches. Opening /automations doesn't help either, because the observer belongs to the provider and doesn't remount with the view. So an automation created elsewhere on that server (CLI, another client, or a folder you haven't opened in the app) won't show up until a reload, or until you open a folder that offers /automation. To fix it, keep polling while the view is open:
refetchInterval: (query: { state: { data?: AutomationInfo[] } }) =>
query.state.data?.length || offered || open ? interval : false,I only read the diff at pr/head. I didn't run anything or change the checkout.
There was a problem hiding this comment.
The new commits put Automations behind the experimental general.automations setting. It's on in dev builds and off in releases, and with it off the provider fetches nothing, so release users don't get the extra requests. With the setting on, though (the default in dev), the earlier point still applies: the app asks each server for its command list for every used project and open tab, and polls every connected server. That thread stays open.
I couldn't open the view or run the e2e specs because there's no browser here. tsc -b in packages/app passes. The new hidden-while-off e2e test is small and clear.
Public API: unchanged. The new setting is client-only, stored with the other app settings.
There was a problem hiding this comment.
I couldn't open the view or run the e2e specs because there's no browser here. I read the new commits, and tsc -b in packages/app passes at the new head.
The earlier fan-out concern is mostly addressed: outside /automations, the provider only asks about folders that are already loaded, and it checks every tab and used project only while the view is open. One small leftover: the automation list is still requested once from every connected server, so servers with automations off answer it with a 403. Gating the query on offered would avoid that, but it's minor. The view rework (rows grouped by status, readable cron and date text) looks fine, and I have nothing blocking.
Public API: unchanged. general.automations is a client-only app setting.
8006a3f to
6301e04
Compare
There was a problem hiding this comment.
This push rebases onto dev and doesn't change the automations work: the automations files and their e2e spec match the previous head, and the only other differences come from dev. tsc -b in packages/app passes. I still couldn't open the view or run the e2e specs because there's no browser here. Nothing new to flag.
Public API: unchanged.
There was a problem hiding this comment.
This push merges dev. Its only change since the last review is a test file from dev (#66620), and the automations work is the same as before. Nothing new to flag.
Public API: unchanged.
Issue for this PR
Carries over #60628 by @kitlangton, rebased on dev
Type of change
What does this PR do?
Adds an Automations view to the desktop/web app (sidebar entry +
/automationsroute). It lists what each connected server reports from/api/experimental/automation, shows where each one runs, its trigger, who created it and who gets woken, and lets you pause, resume or delete it. New automation opens a draft with/automationin the saved folder.on top of #60628:
jobList) and icons (new-icons.tsis gone,clockmoved intocatalog.ts)shellautomation action since, so the inspector now shows the command and says no session is woken (the server only stores the exit code + output as last output)Behind a new experimental setting, Settings → Experimental → Automations (
general.automations): on in dev builds, off in releases, same as tab groups. With it off nothing is synced or polled and every entry point stays hidden. With it on the entry is always there, an empty server just shows "No automations yet". New automation only shows where an open folder offers the/automationcommand (automationsconfig, on by default).How did you verify your code works?
bun typecheckinpackages/appbun run test:e2e:built e2e/regression/automations.spec.ts: 5 passed, no retries. Extended the first test with a shell automationScreenshots / recordings
Checklist