Skip to content

#929 Search sessions on Home - #978

Merged
ivanfenenko merged 26 commits into
mainfrom
feature/929-search-sessions
Nov 4, 2026
Merged

ivanfenenko merged 26 commits into
mainfrom
feature/929-search-sessions

Conversation

@ivanfenenko

@ivanfenenko ivanfenenko commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Search sessions on Home (#929), on iOS and Android, for v1 and v2 servers. Stacked on #977 (Archived sessions, itself on #976 Home ⋯ menu); merge order #976 → #977 → #978. The design is in the #929 design comment.

  • Screen: search covers Home's pane. Back button, a search field focused with the keyboard up, placeholder "Search in ". A scope chip starts at Home's project scope (a worktree scope searches its project) and opens a selection menu of All projects plus each project.
  • Results: Home's own session row (either row style) with the title match highlighted, under an "N results" header. Before typing, only a short hint. With no match, "No sessions match “q”" in , plus Search all projects when another project has a match. Tapping a result opens the session; Back returns to search with query and scope kept, and the keyboard stays down. On split layouts the session opens beside search.
  • Entry: Search sessions is the first entry of Home's ⋯ menu (then Archived sessions, divider, Settings), shown once Home has loaded.
  • Include archived (servers with supportsArchivedSessions, #833 Restore archived sessions #977): on open, search lists every Home project's archived sessions once through #833 Restore archived sessions #977's archived listing and matches their titles locally. An "Include archived · N" toggle chip (N in scope, off on every open) adds archived matches in their own Archived section with an Archived tag; opening one shows #833 Restore archived sessions #977's archived banner. With no match, the empty state offers Include archived and/or Search all projects, each only when it would find something. Hidden on servers without archive support.
  • Keyboard: ⌘F (iPad) / Ctrl+F (Android) opens and focuses search, listed and gated like the other Keyboard and mouse support #869 app shortcuts. Esc clears the query, then closes search.
  • Data: SessionRepository.searchSessions(query, directory) behind the domain adapter.
    • v1 sends GET /session?directory=&search=&roots=true (confirmed in the 1.19.5 /doc).
    • v2 sends GET /api/session with project/directory, search, parentID=null, archived=false.
    • Both filter the reply again locally (roots, not archived, case-insensitive title match), so a server that ignores search still gives correct results.
  • Screen Model (SessionSearchViewModel / SessionSearchModel):
    • Home's rows match on every keystroke. The server is asked 250 ms after the last keystroke, or at once on a scope change, with one request per listed path in scope.
    • Server-only sessions join through Home's row builder; Home's copy wins because it has live status. Stale replies are dropped, and a failed request keeps the local results.
    • busy covers the debounce and the request, so the field shows a spinner and "Searching…" shows instead of a premature "No match".
  • Design system (both apps, gallery entries):
    • Search text-input kind: search mark, a clear button, and a spinner while busy.
    • List item titleHighlight.
    • New OpenCodeMenuChip, with Menu and Toggle variants.
    • iOS anchored overflow menu gets placement: .below.
    • The scope menu reuses the existing overflow-menu "selection rows" convention.

Checks

  • Rebuilt and re-run after merging feature/929-home-overflow-menu and feature/833-restore-archived-sessions.
  • Android: :app:testDebugUnitTest passes in full. New: SessionSearchViewModelTest (including Include archived), SessionTitleSearchTest, and v1/v2 search request tests in SessionProtocolRepositoryTest. ktlint is clean on the changed lines.
  • iOS: build-for-testing (generic simulator) succeeds. New and changed suites passed in the iOS worktree run (104 tests): SessionSearchModelTests, SessionTitleSearchTests, SessionProtocolRepositoryTests, OpenCodeListItemTitleHighlightTests, OpenCodeKeyboardShortcutTests, OpenCodeKeyboardNavigationTests, OpenCodeEscapeResolverTests. Not re-run on this branch, because slices no longer run xcodebuild test.
  • scripts/check-string-keys.mjs passes. scripts/check-hardcoded-text.mjs finds nothing in changed files.
  • Device verification is pending: the shared simulator/emulator pass will run it.

Evidence

Pending: the shared device verification pass will add it.

Issue

Fixes #929

Risks / Follow-ups

  • Stack: this PR needs #929 #833 Home top-bar overflow menu #976 and #833 Restore archived sessions #977 first.
  • Archived results have no long-press actions (Home's sheet would offer Archive on an archived session). If one project's archived listing fails, search shows no archived rows or count, like #833 Restore archived sessions #977's screen.
  • iOS Include archived tests (in SessionSearchModelTests) compile but were not run; slices no longer run xcodebuild test.
  • Server-only rows (sessions Home has not loaded) show no live status.
  • iPad Esc order: while search is open in the leading pane, Esc goes to search before it can interrupt a running chat in the detail pane.

🤖 Generated with Claude Code

ivanfenenko and others added 5 commits November 3, 2026 21:49
Search covers Home's pane: a search field (focused, keyboard up), a scope
chip that starts at Home's project scope, and Home's rows for sessions
whose title matches, with the match highlighted. Ctrl+F opens it; Esc
clears the query, then closes.

- Domain: SessionRepository.searchSessions sends `search` on v1
  (`/session`, `roots=true`) and v2 (`/api/session`, `parentID=null`,
  `archived=false`), then filters the reply locally so servers that
  ignore `search` still give correct results.
- SessionSearchViewModel: Home rows match on every keystroke; the server
  search runs after a 250 ms debounce, merges server-only sessions, and
  keeps local results when it fails.
- Design system: Search text input kind (spinner while busy, clear
  button), list item title highlight, new OpenCodeMenuChip.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Home's Settings button becomes a ⋯ menu that holds Settings for now.
HomeMenu (iOS and Android) puts feature entries first, in order, and
adds Settings last behind a divider, so Search sessions, Archived
sessions and Worktrees each add one entry. The shared overflow menu
gains a dividerAbove slot, and on iOS a whole menu row now takes the
tap, not just its icon and text. ⌘, / Ctrl+, still open Settings.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Add an Archived sessions screen on Android and iOS: Home's scope, grouped
This week / Earlier by archive time, with one-tap Unarchive (snackbar with
Undo), an actions sheet (Unarchive, Open, Delete…) and a live refresh on
session.archived / unarchived / deleted. Session Chat shows an "Archived
<time>" banner with Unarchive.

v2 lists with ?archived=true and restores with PATCH {archived: false}.
v1 can archive but cannot clear time.archived, so a new
supportsArchivedSessions capability hides the feature there.
ArchivedSessionList is shared so search can reuse it for archived results.

The Home ⋯ menu entry lands after the #929 menu foundation.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Search covers Home's pane: field with scope chip, Home's own rows with the
title match highlighted, server search per added path (v1 search/roots,
v2 search/parentID=null/archived=false, both re-filtered locally), Cmd-F
in the Go menu, and Esc clearing the query before closing.

Design system: search text input kind with busy spinner and clear button,
list item title highlight, below placement for the anchored overflow menu,
and OpenCodeMenuChip, each with gallery entries.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ivanfenenko
ivanfenenko marked this pull request as ready for review November 3, 2026 21:38
@ivanfenenko

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 4 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit ae8a455. Configure here.

ivanfenenko and others added 4 commits November 3, 2026 22:46
…into claude/929-search-sessions-17ace1

# Conflicts:
#	ios/OpenCode Mobile/OpenCode Mobile/UI/Main/ProjectListHomeView.swift
Both apps add Search sessions above Settings in the Home ⋯ menu once
Home has loaded; it opens search on Home's scope, like ⌘F / Ctrl+F.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The ⋯ menu lists "Archived sessions" with "N in <scope>", counted when the
menu opens and left out on servers that cannot restore archived sessions.
It opens the Archived sessions screen for Home's current scope.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Automated review: no finding that 2+ of 1 passes agreed on.

opencode pr-review · passes: muse-spark-1.3-contributor, glm-5.3-flash, deepseek-v4.1-flash · $0.194 · 1 pass(es) stopped early · 2 pass(es) failed

@ivanfenenko
ivanfenenko changed the base branch from main to feature/929-home-overflow-menu November 3, 2026 21:51
@ivanfenenko
ivanfenenko marked this pull request as draft November 3, 2026 21:51
@ivanfenenko
ivanfenenko marked this pull request as ready for review November 3, 2026 21:58

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Automated review: 2 finding(s) that 2+ of 3 passes agreed on.

Outside the diff lines:

  • ios/OpenCode Mobile/OpenCode Mobile/UI/Main/SessionSearchModel.swift:179 medium: Scope falling back to All projects does not restart or cancel the running search
4 finding(s) from a single pass, not posted
  • ios/OpenCode Mobile/OpenCode Mobile/UI/Main/SessionSearchModel.swift:259 high: Server rows for worktree-extra paths are dropped (muse-spark-1.3-contributor)
  • ios/OpenCode Mobile/OpenCode Mobile/UI/Main/SessionSearchModel.swift:210 medium: Project-scope search omits separately-listed worktrees (muse-spark-1.3-contributor)
  • android/app/src/main/java/dev/opencode/mobile/ui/main/SessionSearchViewModel.kt:231 medium: One failed per-path request drops every sibling's server results (glm-5.3-flash)
  • ios/OpenCode Mobile/OpenCode Mobile/UI/Main/SessionSearchModel.swift:111 low: "Search all projects" is never offered for a match that exists only on the server in another project (deepseek-v4.1-flash)

opencode pr-review · passes: muse-spark-1.3-contributor, glm-5.3-flash, deepseek-v4.1-flash · $0.137 · 1 pass(es) stopped early

…sions' into claude/929-search-sessions-17ace1

# Conflicts:
#	android/app/src/main/java/dev/opencode/mobile/domain/session/V2SessionRemote.kt
#	android/app/src/main/java/dev/opencode/mobile/ui/components/list/SessionList.kt
#	android/app/src/main/java/dev/opencode/mobile/ui/main/MainScreen.kt
#	ios/OpenCode Mobile/OpenCode Mobile/Components/List/SessionList.swift
#	ios/OpenCode Mobile/OpenCode Mobile/UI/Main/ProjectListHomeView.swift
ivanfenenko and others added 2 commits November 3, 2026 23:22
On servers that list archived sessions (#833), search lists every Home
project's archived sessions once on open and matches their titles
locally. An "Include archived · N" toggle chip (N in scope) adds them
in their own Archived section with an Archived tag; with no match, the
empty state offers Include archived when it would find something.

The search chip gains a Toggle variant (no chevron, switch semantics).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ivanfenenko
ivanfenenko changed the base branch from feature/929-home-overflow-menu to feature/833-restore-archived-sessions November 3, 2026 22:34
@ivanfenenko
ivanfenenko marked this pull request as draft November 3, 2026 22:34
ivanfenenko and others added 5 commits November 3, 2026 23:39
- Home menu: recount the Archived sessions entry once Home's server probe
  finishes, so it shows on the first open after launch (both apps).
- Android overflow menu: size the panel to its widest entry; a divider no
  longer stretches it to the window. Gallery gains the Home menu shape.
- iOS: archived rows drop the long-press overlay that covered the trailing
  Unarchive button; a tap still opens the actions.
- Delete confirmation names the session and says it is deleted from the
  server for good, from a target the closing sheet cannot clear.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…anges

- Android: one failed path no longer drops the other paths' server
  matches; when every path fails the last answer stays (as on iOS).
- Android: a new keystroke keeps the previous server matches until the
  next answer replaces them, instead of hiding them for the debounce.
- Both: when Home's lists in scope change (a project added or removed,
  or the scope falls back to All projects), search drops the removed
  projects' server rows and searches again at once. Live updates that
  keep the same lists do not search again.
- Android: switching server closes search, as on iOS.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Undo the overflow menu width change; #976 fixes the divider there.
- Session Chat: session.unarchived clears the banner directly, and an
  archive change since a session read began wins over that read, so a
  lagging GET no longer brings the banner back (both apps). iOS also
  clears the banner on rebind.
- Archived list: unarchived or deleted rows stay gone while a list still
  carries their old archive time; Undo rows keep their project, so an
  unknown directory no longer drops them; one failing project keeps the
  others listed (both apps).
- iOS: subscribe to events before the first load, and report
  cancellation from ArchivedSessionList.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
HorizontalDivider fills the width it is offered, and the panel offered
the popup window's width, so a divider stretched the menu across the
screen. The panel column now takes its widest row's intrinsic width,
and every row fills it, so the whole row takes the tap as on iOS.
Adds a grouped preview (subtitles plus divider) on both platforms and
an instrumented layout test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ivanfenenko

Copy link
Copy Markdown
Collaborator Author

Review triage for be7529a.

Fixed (threads answered and resolved): one failed path dropping all server matches (Android), keystrokes hiding server-only matches (Android), stale server rows after Home or server changes (both), and the scope falling back to All projects without a new search (both; this was github-actions' finding outside the diff at SessionSearchModel.swift:179). Each fix has unit tests on both platforms.

Single-pass findings, not changed:

  • SessionSearchModel.swift:259 Server rows for worktree-extra paths are dropped and :210 Project-scope search omits separately-listed worktrees: iOS Home lists only added paths and has no separate worktree lists (Android lists them on v1 only). iOS search asks the same lists iOS Home shows, so nothing Home could show is missed. The v1 worktree gap is Home's, not search's.
  • SessionSearchViewModel.kt:231 One failed per-path request drops every sibling's server results: same as the resolved thread, fixed.
  • SessionSearchModel.swift:111 "Search all projects" is never offered for a match that exists only on the server in another project: true on both platforms, and kept on purpose. The offer is decided from Home's rows plus the current scope's server answer. Deciding it from server-only matches elsewhere would need an extra all-projects request on every keystroke just to show a button. Pressing "Search all projects" runs that server search anyway.

…sions' into claude/929-search-sessions-17ace1

# Conflicts:
#	ios/OpenCode Mobile/OpenCode Mobile/UI/Archived/ArchivedSessionsViewModel.swift
ivanfenenko and others added 2 commits November 4, 2026 09:00
Home's Done pill is server unread state. Unarchive from the Archived
screen must not acknowledge it; only opening the session does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Search's chips sit in a row that scrolls sideways. There the title's
`weight(1f, fill = false)` had no width to share and collapsed, so the
scope and Include archived chips showed only their icons. The title now
has a width cap instead of a weight.

Adds an instrumented Compose test that puts both chips in a sideways
scrolling row and checks their titles show.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ivanfenenko

Copy link
Copy Markdown
Collaborator Author

Device evidence: Search sessions (real app, scenario harness, fixture project)

Shared Pixel 9a emulator and iPhone 17 simulator; v2 (dev) and v1.19.5 through the scenario harness.

Android iOS
Results for “reply” with highlights Results for “reply” with labelled chips
Include archived adds an Archived section
v1.19.5: scope chip label, no archived chip

Checked: menu entry, scope placeholder and hint, title matching with highlight, Include archived section with pill (v2), opening an archived result shows the archived banner, v1 search with the archived chip hidden. Row 2 was captured before 19ba2ef4a, which made the Android chip labels visible (row 3 shows the fixed chip).

main's only new commit is the #976 squash, whose tree matches fa295aa,
already merged here in a9d2fac, so this branch's tree is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ivanfenenko
ivanfenenko marked this pull request as ready for review November 4, 2026 08:30
- Dedupe archived sessions after sorting, so a duplicate keeps its newest copy.
- A row Undo put back settles against any archive time when unarchived
  again, since the app never saw the server's time for it.
- Android: capture the archive generation before launching the read;
  the v2 project lookup rethrows cancellation.
- iOS: recheck the menu entry with Home's current projects.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Automated review: no finding that 2+ of 3 passes agreed on.

2 finding(s) from a single pass, not posted
  • ios/OpenCode Mobile/OpenCode Mobile/UI/Main/SessionSearchModel.swift:294 high: iOS search never queries v1 worktree lists (muse-spark-1.3-contributor)
  • ios/OpenCode Mobile/OpenCode Mobile/UI/Main/SessionSearchModel.swift:344 medium: iOS drops server rows without a matching section (muse-spark-1.3-contributor)

opencode pr-review · passes: muse-spark-1.3-contributor, glm-5.3-flash, deepseek-v4.1-flash · $0.167

Base automatically changed from feature/833-restore-archived-sessions to main November 4, 2026 09:27
ivanfenenko and others added 2 commits November 4, 2026 10:27
Co-Authored-By: Claude Opus 5.5 <[email protected]>

# Conflicts:
#	android/app/src/main/java/dev/opencode/mobile/domain/session/V2SessionRemote.kt
main's tree equals #977's final commit f30175e, merged in the parent.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ivanfenenko added a commit that referenced this pull request Nov 4, 2026
Menu entries kept in order: Search sessions, Archived sessions, Worktrees; Localizable.xcstrings merged by key.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
On v1, iOS Home folds the sessions of a project's non-added worktrees
into the added path's section, but search only asked the added paths,
so a server match in such a worktree was missed (Android already asks
these lists). Home now passes those directories to search, which asks
them too and files their matches under the added path's section, the
way Home shows them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ivanfenenko

Copy link
Copy Markdown
Collaborator Author

Triage of the latest review summary (the automated review on 19ba2ef).

  • high SessionSearchModel.swift:294 iOS search never queries v1 worktree lists: a real bug, fixed in 032ee67. My earlier triage was wrong. On v1, iOS Home does fold the sessions of a project's non-added worktrees into the added path's section (HomeWorktreeSessionFold), but search only asked the added paths. Home now passes those worktree directories to search, which asks them too, the same lists Android asks. Tests: v1WorktreeLists_areSearchedAndFiledUnderTheirAddedPath, v1WorktreeLists_ofAnotherProjectAreLeftOutOfAProjectScope.
  • medium SessionSearchModel.swift:344 iOS drops server rows without a matching section: the worktree case was the real one, and the same fix covers it. A match from one of those worktrees is now filed under the added path whose Home section shows it, so it is no longer dropped. Search only asks lists Home shows, so every reply has a section. The only reply still left out is one for a list whose section left Home while the request ran. That change already starts a new search for the current lists, so nothing current is lost.

@ivanfenenko
ivanfenenko merged commit 7157d1b into main Nov 4, 2026
@ivanfenenko
ivanfenenko deleted the feature/929-search-sessions branch November 4, 2026 09:57
ivanfenenko added a commit that referenced this pull request Nov 4, 2026
main's tree equals #978's final commit 032ee67, already merged here
in a6e1364, so this branch's tree is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.

Search sessions on Home

1 participant