feat(tui): grey out project commands when no project is detected - #2437
Conversation
| command, | ||
| }: RouterScreenProps & { command: Command }) { | ||
| const navigate = useNavigate(); | ||
| const noProject = useProject(core, ctx.value(ProjectKey)).isError; |
There was a problem hiding this comment.
React query has a built-in retry mechanism for errors IIRC. So the items wouldn't be greyed out until the backoff finishes which could be multiple seconds. We should do something like:
const projectDetected = useQuery({
queryFn: async () => (await projectManager.resolve(...)) !== undefined,
});
const noProject = projectDetected.data === falsein a shared helper and use in both of our PRs
There was a problem hiding this comment.
Good call on the shared helper. Done in bb2fa42: useNoProjectDetected(core) in ProjectGate.tsx uses your resolve(...) !== undefined shape, and both RootScreen and the menu call it, so the root menu now does one lookup under the project-detected key.
On the retry: in our runtime it does not retry. query-core 5.102.8 uses config.retry ?? (isServer() ? 0 : 3), and isServer is typeof window === "undefined", which holds under Node and Bun. I measured the grey 60 ms after the first menu paint. Your shape still removes the dependency on that default, since a missing project is now data instead of an error.
* feat(tui): grey out project commands when no project is detected * refactor(tui): share one project-detected lookup between the root banner and the menu
* feat(tui): grey out project commands when no project is detected * refactor(tui): share one project-detected lookup between the root banner and the menu
* feat(tui): grey out project commands when no project is detected * refactor(tui): share one project-detected lookup between the root banner and the menu
* feat(tui): grey out project commands when no project is detected * refactor(tui): share one project-detected lookup between the root banner and the menu
What
The TUI command menu greys out commands that need a project when the cwd has no AgentCore project:
add,remove,deploy,invoke,status,build, and the command line onlyexport,dev,log,traces. Children inherit the state, so theaddsubmenu is greyed too. Greyed commands stay selectable and open the existing "No AgentCore project found" guidance.Router.projectHandlers(...)registers handlers and marks them as needing a project.compilepasses the mark down to descendants.isProjectRequired(command)reads it.createProjectHandlers(...).projectBoundHandlersthrough it, so the list of project commands has one source.RouterScreenresolves the project withuseProjectand mutes marked options when there is none.Stacked on #2433.
Why
Outside a project, the menu listed project commands the same way as commands that work anywhere, with no hint that they would fail.
How tested
bun test: 3573 pass, 0 fail. New tests cover the router mark and its inheritance, and the exact set of root commands marked.makeand drove the linux-arm64 binary in a pty. Outside a project the six project commands render grey andcreate/evaldo not. Inside a project nothing is grey. Selectingdeployoutside a project shows the not-found guidance.