Skip to content

feat(app): show where automations run and which session they wake - #66393

Merged
neriousy merged 8 commits into
devfrom
app-automations-ui
Nov 26, 2026
Merged

neriousy merged 8 commits into
devfrom
app-automations-ui

Conversation

@neriousy

@neriousy neriousy commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Issue for this PR

Carries over #60628 by @kitlangton, rebased on dev

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds an Automations view to the desktop/web app (sidebar entry + /automations route). 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 /automation in the saved folder.

on top of #60628:

  • rebased on dev, resolved conflicts in the titlebar (new nav prototype / pins / linux menu), mock server (jobList) and icons (new-icons.ts is gone, clock moved into catalog.ts)
  • dev added a shell automation 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)
  • cleaned up the view: the list is grouped by status (completed collapsed) instead of filter tabs, cron and dates read as text ("Weekdays at 9:00 AM", "in 14 hours"), and the inspector reads as when / do / last run with the folder, creator and server below. Dropped the chips, dots, avatars, refresh button and most icons

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 /automation command (automations config, on by default).

How did you verify your code works?

  • bun typecheck in packages/app
  • bun run test:e2e:built e2e/regression/automations.spec.ts: 5 passed, no retries. Extended the first test with a shell automation
  • settings, controller and layout unit tests pass
  • new e2e: the sidebar entry, New automation and the view stay hidden while the setting is off

Screenshots / recordings

experimental setting

Scheduled prompt Event watch (Code Mode)
scheduled prompt event watch
Shell command Paused, sends to a subagent
shell command paused subagent
Completed (expanded)
completed
Delete New automation
delete confirm new automation draft

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment thread packages/app/src/automations/source.ts Outdated
? [tab.directory]
: [ctx.data.session.get(tab.routeSessionId ?? tab.sessionId)?.location.directory],
),
...ctx.projects.used().map((p) => p.worktree),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

fixed in the latest push

  • outside /automations discovery 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 /automation in 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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 and projects.used() are only checked while the route is automations. Startup no longer sets up every project location.
  • List query: with enabled: offered || open, servers that don't offer /automation in any open folder aren't asked until the view opens. You're right that Automation.list filters 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, so loading() would stay true for those servers. That doesn't matter here: the view only uses loading() in route.tsx:91 and route.tsx:96, and on that route every query is enabled. Just don't reuse loading() 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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

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.

1 participant