feat(mobile): start a session in a project from the sessions drawer

Project rows carried an active-project dot and a session count, neither of
which answers a question the user has while browsing the drawer, and there
was no way to start a session in a project's root directory: the only
per-row action was creating a worktree.

Drop both indicators and put a "+" beside the worktree button instead. It
opens a draft already carrying the project and its directory, the same
contract as the desktop sidebar's per-project "+", so the current
directory is not switched out from under the session behind the drawer.
Project rows in search results lose the count the same way and gain the
same button; dropping it there also drops a per-project session scan that
ran on every keystroke.

Testing: package type-check and lint; drove the mobile surface in a
browser against an isolated server (rows render the button, counts gone).
This commit is contained in:
Bohdan Triapitsyn
2026-09-09 17:41:14 +03:00
parent 0ddd994f98
commit d4a0bf3ee1
13 changed files with 62 additions and 39 deletions
+50 -27
View File
@@ -269,6 +269,31 @@ const NewWorktreeIconButton: React.FC<{
);
};
/** Starts a session draft already pointed at this project — the mobile twin of
the desktop sidebar's per-project "+". */
const NewSessionIconButton: React.FC<{
label: string;
onClick: () => void;
className?: string;
}> = ({ label, onClick, className }) => (
<button
type="button"
className={cn(
'flex size-9 shrink-0 items-center justify-center rounded-full text-[var(--surface-mutedForeground)] transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]',
className,
)}
aria-label={label}
title={label}
onClick={(event) => {
event.stopPropagation();
onClick();
}}
style={{ touchAction: 'manipulation' }}
>
<Icon name="add" className="size-4" />
</button>
);
// Width of the swipe-revealed action area (rename + archive + delete buttons).
const ROW_ACTIONS_WIDTH = 144;
const ROW_SWIPE_SNAP_MS = 180;
@@ -1387,6 +1412,15 @@ export const MobileSessionsSheet: React.FC<MobileSessionsSheetProps> = ({ open,
onOpenChange(false);
};
// Same contract as the desktop sidebar's per-project "+": the draft carries
// the project and its directory, so the app's current directory is not
// switched out from under the session that is still open behind the drawer.
const handleNewSessionInProject = (project: ProjectMeta) => {
setActiveProjectIdOnly(project.id);
openNewSessionDraft({ selectedProjectId: project.id, directoryOverride: project.path });
onOpenChange(false);
};
const filteredNodes = React.useMemo(() => {
if (!normalizedQuery) return projectNodes;
return projectNodes.filter((node) => {
@@ -1418,18 +1452,10 @@ export const MobileSessionsSheet: React.FC<MobileSessionsSheetProps> = ({ open,
);
}, [normalizedQuery, pinnedSessionIds, projectsMeta, sessionOrderRanks, sessions]);
const searchProjectMatches = React.useMemo(() => {
if (!normalizedQuery) return [] as Array<ProjectMeta & { sessionCount: number }>;
return rankByQuery(projectsMeta, normalizedQuery, (project) => [project.label, project.path])
.map((project) => ({
...project,
sessionCount: sessions.filter((session) => {
if (getParentId(session)) return false;
const directory = normalizePath(getSessionDirectory(session));
return projectMatchesExactDirectory(project, directory);
}).length,
}));
}, [normalizedQuery, projectsMeta, sessions]);
const searchProjectMatches = React.useMemo<ProjectMeta[]>(() => {
if (!normalizedQuery) return [];
return rankByQuery(projectsMeta, normalizedQuery, (project) => [project.label, project.path]);
}, [normalizedQuery, projectsMeta]);
const hasNoMatches =
normalizedQuery && searchSessionMatches.length === 0 && searchProjectMatches.length === 0;
@@ -1592,16 +1618,15 @@ export const MobileSessionsSheet: React.FC<MobileSessionsSheetProps> = ({ open,
<span className="block min-w-0 flex-1 truncate typography-ui-label text-foreground">
{project.label}
</span>
<span className="shrink-0 typography-micro text-muted-foreground tabular-nums">
{project.sessionCount}
</span>
</button>
{project.isGitRepo ? (
<NewWorktreeIconButton
className="mr-2"
onClick={() => handleNewWorktree(project.id)}
/>
<NewWorktreeIconButton onClick={() => handleNewWorktree(project.id)} />
) : null}
<NewSessionIconButton
className="mr-2"
label={t('mobile.sessions.newSessionInProjectAria', { label: project.label })}
onClick={() => handleNewSessionInProject(project)}
/>
</div>
))}
</div>
@@ -1773,17 +1798,15 @@ export const MobileSessionsSheet: React.FC<MobileSessionsSheetProps> = ({ open,
<span className="block min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground">
{node.project.label}
</span>
{node.isActive ? <ActiveDot ariaLabel={t('mobile.sessions.activeProjectAria')} /> : null}
<span className="shrink-0 typography-micro text-muted-foreground tabular-nums">
{node.totalSessions}
</span>
</button>
{node.project.isGitRepo ? (
<NewWorktreeIconButton
className="mr-2"
onClick={() => handleNewWorktree(node.project.id)}
/>
<NewWorktreeIconButton onClick={() => handleNewWorktree(node.project.id)} />
) : null}
<NewSessionIconButton
className="mr-2"
label={t('mobile.sessions.newSessionInProjectAria', { label: node.project.label })}
onClick={() => handleNewSessionInProject(node.project)}
/>
</div>
</MobileSwipeActionsRow>
+1 -1
View File
@@ -127,13 +127,13 @@ export const dict = {
'mobile.sessions.showArchived': 'Archivierte anzeigen ({count})',
'mobile.sessions.hideArchived': 'Archivierte ausblenden',
'mobile.sessions.activeWorktreeAria': 'Aktives Worktree',
'mobile.sessions.activeProjectAria': 'Aktives Projekt',
'mobile.sessions.startNewChat': 'Neuen Chat starten',
'mobile.sessions.newChat': 'Neuer Chat',
'mobile.sessions.editOrder': 'Projekte neu anordnen',
'mobile.sessions.doneEditing': 'Fertig',
'mobile.sessions.editOrderHint': 'Ziehe den Griff, um die Projekte neu anzuordnen. Tippe auf das Häkchen, um zu beenden.',
'mobile.sessions.editProjectAria': '{label} bearbeiten',
'mobile.sessions.newSessionInProjectAria': 'Neue Sitzung in {label}',
'mobile.sessions.dragHandleAria': '{label} ziehen, um neu anzuordnen',
'mobile.sessions.moveUpAria': '{label} nach oben verschieben',
'mobile.sessions.moveDownAria': '{label} nach unten verschieben',
+1 -1
View File
@@ -157,13 +157,13 @@ export const dict = {
'mobile.sessions.showArchived': 'Show archived ({count})',
'mobile.sessions.hideArchived': 'Hide archived',
'mobile.sessions.activeWorktreeAria': 'Active worktree',
'mobile.sessions.activeProjectAria': 'Active project',
'mobile.sessions.startNewChat': 'Start new chat',
'mobile.sessions.newChat': 'New chat',
'mobile.sessions.editOrder': 'Reorder projects',
'mobile.sessions.doneEditing': 'Done',
'mobile.sessions.editOrderHint': 'Drag the handle to reorder projects. Tap a project to show its worktrees and drag those too. Tap the check to finish.',
'mobile.sessions.editProjectAria': 'Edit {label}',
'mobile.sessions.newSessionInProjectAria': 'New session in {label}',
'mobile.sessions.dragHandleAria': 'Drag {label} to reorder',
'mobile.sessions.moveUpAria': 'Move {label} up',
'mobile.sessions.moveDownAria': 'Move {label} down',
+1 -1
View File
@@ -158,7 +158,6 @@ export const dict: Record<I18nKey, string> = {
"mobile.sessions.showArchived": "Mostrar archivadas ({count})",
"mobile.sessions.hideArchived": "Ocultar archivadas",
"mobile.sessions.activeWorktreeAria": "Worktree activo",
"mobile.sessions.activeProjectAria": "Proyecto activo",
"mobile.sessions.startNewChat": "Iniciar nuevo chat",
"mobile.sessions.newChat": "Nuevo chat",
"mobile.sessions.editOrder": "Reordenar proyectos",
@@ -177,6 +176,7 @@ export const dict: Record<I18nKey, string> = {
"mobile.sessions.deleteSessionAria": "Eliminar {title}",
"mobile.sessions.confirmDeleteSessionAria": "Confirmar eliminación de {title}",
"mobile.sessions.editProjectAria": "Editar {label}",
"mobile.sessions.newSessionInProjectAria": "Nueva sesión en {label}",
"mobile.projectEdit.worktreesTitle": "Worktrees",
"mobile.projectEdit.worktreesEmpty": "Este proyecto aún no tiene worktrees.",
"mobile.projectEdit.reorderHint": "Arrastra para reordenar los worktrees.",
+1 -1
View File
@@ -3009,13 +3009,13 @@ export const dict = {
'mobile.sessions.showArchived': 'Afficher les archivées ({count})',
'mobile.sessions.hideArchived': 'Masquer les archivées',
'mobile.sessions.activeWorktreeAria': 'Worktree actif',
'mobile.sessions.activeProjectAria': 'Projet actif',
'mobile.sessions.startNewChat': 'Démarrer un nouveau chat',
'mobile.sessions.newChat': 'Nouveau chat',
'mobile.sessions.editOrder': 'Réordonner les projets',
'mobile.sessions.doneEditing': 'Terminé',
'mobile.sessions.editOrderHint': 'Faites glisser la poignée pour réorganiser les projets. Touchez un projet pour afficher ses worktrees et les faire glisser aussi. Touchez la coche pour terminer.',
'mobile.sessions.editProjectAria': 'Modifier {label}',
'mobile.sessions.newSessionInProjectAria': 'Nouvelle session dans {label}',
'mobile.sessions.dragHandleAria': 'Faire glisser {label} pour réordonner',
'mobile.sessions.moveUpAria': 'Déplacer {label} vers le haut',
'mobile.sessions.moveDownAria': 'Déplacer {label} vers le bas',
+1 -1
View File
@@ -158,13 +158,13 @@ export const dict: Record<I18nKey, string> = {
'mobile.sessions.showArchived': 'アーカイブを表示({count}',
'mobile.sessions.hideArchived': 'アーカイブを非表示',
'mobile.sessions.activeWorktreeAria': 'アクティブなワークツリー',
'mobile.sessions.activeProjectAria': 'アクティブなプロジェクト',
'mobile.sessions.startNewChat': '新しいチャットを開始',
'mobile.sessions.newChat': '新しいチャット',
'mobile.sessions.editOrder': 'プロジェクトの並び替え',
'mobile.sessions.doneEditing': '完了',
'mobile.sessions.editOrderHint': 'ハンドルをドラッグしてプロジェクトを並べ替えます。プロジェクトをタップするとワークツリーが表示され、同様にドラッグできます。チェックをタップして完了します。',
'mobile.sessions.editProjectAria': '{label}を編集',
'mobile.sessions.newSessionInProjectAria': '{label}で新しいセッション',
'mobile.sessions.dragHandleAria': '{label}をドラッグして並び替え',
'mobile.sessions.moveUpAria': '{label}を上に移動',
'mobile.sessions.moveDownAria': '{label}を下に移動',
+1 -1
View File
@@ -158,7 +158,6 @@ export const dict: Record<I18nKey, string> = {
'mobile.sessions.showArchived': '보관된 항목 표시 ({count})',
'mobile.sessions.hideArchived': '보관된 항목 숨기기',
'mobile.sessions.activeWorktreeAria': '활성 워크트리',
'mobile.sessions.activeProjectAria': '활성 프로젝트',
'mobile.sessions.startNewChat': '새 채팅 시작',
'mobile.sessions.newChat': '새 채팅',
'mobile.sessions.editOrder': '프로젝트 순서 변경',
@@ -177,6 +176,7 @@ export const dict: Record<I18nKey, string> = {
'mobile.sessions.deleteSessionAria': '{title} 삭제',
'mobile.sessions.confirmDeleteSessionAria': '{title} 삭제 확인',
'mobile.sessions.editProjectAria': '{label} 편집',
'mobile.sessions.newSessionInProjectAria': '{label}에서 새 세션',
'mobile.projectEdit.worktreesTitle': '워크트리',
'mobile.projectEdit.worktreesEmpty': '이 프로젝트에는 아직 워크트리가 없습니다.',
'mobile.projectEdit.reorderHint': '드래그하여 워크트리 순서를 변경합니다.',
+1 -1
View File
@@ -159,7 +159,6 @@ export const dict: Record<I18nKey, string> = {
'mobile.sessions.showArchived': 'Pokaż zarchiwizowane ({count})',
'mobile.sessions.hideArchived': 'Ukryj zarchiwizowane',
'mobile.sessions.activeWorktreeAria': 'Aktywny worktree',
'mobile.sessions.activeProjectAria': 'Aktywny projekt',
'mobile.sessions.startNewChat': 'Rozpocznij nowy czat',
'mobile.sessions.newChat': 'Nowy czat',
'mobile.sessions.editOrder': 'Zmień kolejność projektów',
@@ -178,6 +177,7 @@ export const dict: Record<I18nKey, string> = {
'mobile.sessions.deleteSessionAria': 'Usuń {title}',
'mobile.sessions.confirmDeleteSessionAria': 'Potwierdź usunięcie {title}',
'mobile.sessions.editProjectAria': 'Edytuj {label}',
'mobile.sessions.newSessionInProjectAria': 'Nowa sesja w {label}',
'mobile.projectEdit.worktreesTitle': 'Worktree',
'mobile.projectEdit.worktreesEmpty': 'Ten projekt nie ma jeszcze worktree.',
'mobile.projectEdit.reorderHint': 'Przeciągnij, aby zmienić kolejność worktree.',
+1 -1
View File
@@ -158,7 +158,6 @@ export const dict: Record<I18nKey, string> = {
"mobile.sessions.showArchived": "Mostrar arquivadas ({count})",
"mobile.sessions.hideArchived": "Ocultar arquivadas",
"mobile.sessions.activeWorktreeAria": "Worktree ativa",
"mobile.sessions.activeProjectAria": "Projeto ativo",
"mobile.sessions.startNewChat": "Iniciar novo chat",
"mobile.sessions.newChat": "Novo chat",
"mobile.sessions.editOrder": "Reordenar projetos",
@@ -177,6 +176,7 @@ export const dict: Record<I18nKey, string> = {
"mobile.sessions.deleteSessionAria": "Excluir {title}",
"mobile.sessions.confirmDeleteSessionAria": "Confirmar exclusão de {title}",
"mobile.sessions.editProjectAria": "Editar {label}",
"mobile.sessions.newSessionInProjectAria": "Nova sessão em {label}",
"mobile.projectEdit.worktreesTitle": "Worktrees",
"mobile.projectEdit.worktreesEmpty": "Este projeto ainda não tem worktrees.",
"mobile.projectEdit.reorderHint": "Arraste para reordenar os worktrees.",
+1 -1
View File
@@ -144,13 +144,13 @@ export const dict = {
'mobile.sessions.showArchived': 'Arşivlenenleri göster ({count})',
'mobile.sessions.hideArchived': 'Arşivlenenleri gizle',
'mobile.sessions.activeWorktreeAria': 'Etkin worktree',
'mobile.sessions.activeProjectAria': 'Etkin proje',
'mobile.sessions.startNewChat': 'Yeni sohbet başlat',
'mobile.sessions.newChat': 'Yeni sohbet',
'mobile.sessions.editOrder': 'Projeleri yeniden sırala',
'mobile.sessions.doneEditing': 'Tamam',
'mobile.sessions.editOrderHint': 'Projeleri yeniden sıralamak için tutamacı sürükleyin. Worktree\'lerini görmek için bir projeye dokunun ve onları da sürükleyin. Bitirmek için onay işaretine dokunun.',
'mobile.sessions.editProjectAria': '{label} öğesini düzenle',
'mobile.sessions.newSessionInProjectAria': '{label} içinde yeni session',
'mobile.sessions.dragHandleAria': '{label} öğesini yeniden sıralamak için sürükleyin',
'mobile.sessions.moveUpAria': '{label} öğesini yukarı taşı',
'mobile.sessions.moveDownAria': '{label} öğesini aşağı taşı',
+1 -1
View File
@@ -158,7 +158,6 @@ export const dict: Record<I18nKey, string> = {
"mobile.sessions.showArchived": "Показати архівовані ({count})",
"mobile.sessions.hideArchived": "Сховати архівовані",
"mobile.sessions.activeWorktreeAria": "Активний worktree",
"mobile.sessions.activeProjectAria": "Активний проєкт",
"mobile.sessions.startNewChat": "Почати новий чат",
"mobile.sessions.newChat": "Новий чат",
"mobile.sessions.editOrder": "Змінити порядок проєктів",
@@ -177,6 +176,7 @@ export const dict: Record<I18nKey, string> = {
"mobile.sessions.deleteSessionAria": "Видалити {title}",
"mobile.sessions.confirmDeleteSessionAria": "Підтвердити видалення {title}",
"mobile.sessions.editProjectAria": "Редагувати {label}",
"mobile.sessions.newSessionInProjectAria": "Нова сесія в {label}",
"mobile.projectEdit.worktreesTitle": "Ворктрі",
"mobile.projectEdit.worktreesEmpty": "У цьому проєкті ще немає ворктрі.",
"mobile.projectEdit.reorderHint": "Перетягніть, щоб змінити порядок ворктрі.",
+1 -1
View File
@@ -158,7 +158,6 @@ export const dict: Record<I18nKey, string> = {
'mobile.sessions.showArchived': '显示已归档 ({count})',
'mobile.sessions.hideArchived': '隐藏已归档',
'mobile.sessions.activeWorktreeAria': '活动工作树',
'mobile.sessions.activeProjectAria': '活动项目',
'mobile.sessions.startNewChat': '开始新会话',
'mobile.sessions.newChat': '新会话',
'mobile.sessions.editOrder': '重新排序项目',
@@ -177,6 +176,7 @@ export const dict: Record<I18nKey, string> = {
'mobile.sessions.deleteSessionAria': '删除 {title}',
'mobile.sessions.confirmDeleteSessionAria': '确认删除 {title}',
'mobile.sessions.editProjectAria': '编辑 {label}',
'mobile.sessions.newSessionInProjectAria': '在 {label} 中新建会话',
'mobile.projectEdit.worktreesTitle': '工作树',
'mobile.projectEdit.worktreesEmpty': '此项目还没有工作树。',
'mobile.projectEdit.reorderHint': '拖动以重新排序工作树。',
+1 -1
View File
@@ -158,7 +158,6 @@ export const dict: Record<I18nKey, string> = {
'mobile.sessions.showArchived': '顯示已封存 ({count})',
'mobile.sessions.hideArchived': '隱藏已封存',
'mobile.sessions.activeWorktreeAria': '作用中的工作樹',
'mobile.sessions.activeProjectAria': '作用中的專案',
'mobile.sessions.startNewChat': '開始新聊天',
'mobile.sessions.newChat': '新聊天',
'mobile.sessions.editOrder': '重新排序專案',
@@ -177,6 +176,7 @@ export const dict: Record<I18nKey, string> = {
'mobile.sessions.deleteSessionAria': '刪除 {title}',
'mobile.sessions.confirmDeleteSessionAria': '確認刪除 {title}',
'mobile.sessions.editProjectAria': '編輯 {label}',
'mobile.sessions.newSessionInProjectAria': '在 {label} 中新增會話',
'mobile.projectEdit.worktreesTitle': '工作樹',
'mobile.projectEdit.worktreesEmpty': '此專案還沒有工作樹。',
'mobile.projectEdit.reorderHint': '拖曳以重新排序工作樹。',