Skip to content

feat(web): make sidebar sections the place you act on projects - #2

Merged
BarretoDiego merged 2 commits into
mainfrom
feat/sidebar-project-grouping
Aug 22, 2026
Merged

BarretoDiego merged 2 commits into
mainfrom
feat/sidebar-project-grouping

Conversation

@BarretoDiego

Copy link
Copy Markdown
Owner

Problema

O seletor de projetos fazia três trabalhos não relacionados ao mesmo tempo: escopava a sidebar inteira para um projeto, era o único caminho para as configurações do projeto, e gastava uma linha inteira de largura para dizer o nome de um projeto que a lista abaixo já mostrava.

E a lista só conseguia mostrar projetos que por acaso tinham threads. Projeto parado era inalcançável; projeto terminado sumia dentro de uma única prateleira Settled compartilhada por tudo.

O que muda

O seletor sai. Um projeto é uma seção, e o header da seção carrega o que dá para fazer com ela:

seção ações
Projeto New thread · Project settings
Environment New project (já apontado para aquele environment)
Provider nenhuma — abrange vários projetos e envs, não há alvo

As ações leem o target da seção, não a primeira thread dela: seções agora existem antes de ter threads, já que todo projeto conhecido semeia uma. O projeto vazio é justamente o que mais precisa do botão de nova thread.

O chevron é sempre o último item. Ele é o único controle que toda seção tem, então ancora a borda direita e não se mexe enquanto as ações de hover aparecem e somem em volta. É um botão irmão (button dentro de button é inválido) e fica fora da árvore de acessibilidade, porque o header rotulado ao lado já expõe a mesma ação.

Settled

Agrupado por projeto, cada seção termina com a própria prateleira Settled — fechada por padrão, com contagem e um rodapé Show more. A prateleira global só renderiza quando nenhuma seção é dona do histórico, então nada é listado duas vezes.

A expansão é estado de componente de propósito: um arquivo é aberto para responder uma pergunta, e restaurar seis históricos desenrolados na inicialização enterraria o trabalho.

Decisões que valem revisar

  • O agrupamento padrão passa a ser environment → projeto. As ações vivem em headers de seção; sair com lista plana seria sair com uma sidebar sem onde colocá-las.
  • O escopo some junto com o seletor. Não tinha outra porta de entrada, então o estado, o filtro de threads e o filtro de rascunhos vão junto.
  • Mobile não foi tocado. Tem o próprio filtro de projeto na própria navegação; isso aqui é a sidebar de web e desktop.

Verificação

  • sidebarThreadGrouping.test.ts: 29 testes (11 novos cobrindo sementes, ordenação com trabalho vivo antes de histórico antes de vazio, histórico por seção, paginação, aninhamento e projeto só-com-histórico).
  • Sidebar.logic, Sidebar.snooze, CommandPalette.logic, ui/sidebar: 167 testes passando no total.
  • tsc --noEmit limpo em apps/web e packages/contracts; lint limpo nos arquivos tocados.
  • Sem imagens antes/depois: PR e merge combinados dentro do fork.

Written by Claude Opus 5 in Claude Code.

Adding a project always started by asking which environment to add it to,
even when the caller already knew. The sidebar is about to ask from an
environment section header, where re-asking would be the palette ignoring
where the click came from.

The open detail and the palette's open intent carry an optional
environmentId. When it is set, the flow skips straight to browsing sources
in that environment; when it is absent the picker behaves exactly as before.
The key is absent rather than undefined so the two cases stay
distinguishable under exactOptionalPropertyTypes.

Written by Claude Opus 5 in Claude Code.
The project selector was doing three unrelated jobs at once: it scoped the
whole sidebar to one project, it was the only route to project settings, and
it took a row of sidebar width to say the name of a project the list below
already showed. Meanwhile the list itself could only show projects that
happened to have threads, so a quiet project was unreachable and a finished
one disappeared into a single Settled shelf shared by everything.

The selector is gone. A project is a section, and the section header carries
what you can do with it:

- Project sections get New thread and Project settings.
- Environment sections get New project, pointed at that environment.
- Provider sections span projects and environments, so they get nothing
  rather than a guess.

Actions read off the section's target rather than off its first thread,
because sections now exist before they have threads: every known project
seeds one. The collapse arrow is always the last item, so it stays a fixed
landmark while hover-only actions come and go around it. It is a sibling
button (a button inside a button is invalid) and stays out of the a11y tree,
since the labelled header button already exposes the same action.

Settled threads follow the same idea. Grouped by project, each section ends
with its own Settled shelf, closed by default with a count and a Show more
tail; the global shelf only renders when no section owns history, so nothing
is ever listed twice. Expansion is component state on purpose: an archive is
opened to answer one question, and restoring six unrolled histories on
startup would bury the work.

The default grouping becomes environment then project. The actions above
live on section headers, so shipping with a flat list would ship a sidebar
with nowhere to put them.

Scoping goes away with the selector. It had no other entry point, so the
state, the thread filter and the draft filter go with it.

Mobile keeps its own project filter in its own navigation; this is the web
and desktop sidebar only.

Written by Claude Opus 5 in Claude Code.
@BarretoDiego
BarretoDiego merged commit 3b0fd41 into main Aug 22, 2026
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