feat: reach cross-workspace session search from Telegram - #311
Merged
Conversation
#309 gave the TUI a Tab toggle between this-workspace and all-workspaces search. Telegram was left on the old path, so the same capability was still unreachable there. Two problems, not one. The scope was wrong even when it worked. `/search` sent scope:"workspace" with no workdir, so the daemon fell through to `#guessCallerWorkdir`, which returns the workdir of the most recently CREATED session by that user. That is unrelated to what the Telegram user is attached to — you could be attached to alpha, ask about alpha, and silently search beta because beta was started later. The handler now anchors on the attached session's workdir. With nothing attached there is no workspace worth scoping to, so the search runs cross-workspace instead of scoping to an arbitrary repo. Same rule the TUI modal uses for its initial scope. Telegram has no Tab, so the widen control is an inline-keyboard button on the results: "🌐 Search all workspaces". It is offered on zero hits too, which is exactly when widening is most useful. callback_data caps at 64 bytes and queries are free text, so the query is parked in `#pendingSearches` keyed `${userId}:${short}` — the same shape as approvals and provider dialogs — with oldest-first eviction at 200 entries and single-use tokens. Cross-workspace hits show the repo name, as in the TUI: two repos can each have a "fix auth" session, so a bare session name is ambiguous once results span workspaces. `basename` is total in both frontends. A hit whose session is no longer live can carry an empty workdir — the daemon already renders those as "(unknown)" — and a missing repo label must not break the result list. The TUI copy had the same latent hazard and is fixed alongside. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
rsharath
approved these changes
Aug 29, 2026
saucam
added a commit
that referenced
this pull request
Sep 1, 2026
Third and last surface. #309 gave the TUI a Tab toggle and #311 gave Telegram a button; the web UI still had no way to ask for a cross-workspace search while a session was focused. Its anchoring was already right -- it passed the focused session's workdir, which is what Telegram had to be fixed to do -- but the scope was derived and never overridable: ...(focusedSession()?.workdir ? { workdir: focusedSession()!.workdir, scope: "workspace" } : { scope: "all" }) So global search was reachable only by accident, when nothing happened to be focused. With a session open you searched one directory, and the 73% precision@1 path the feature exists for was unreachable. A segmented control in the modal header now switches This workspace / All workspaces. It is an override on top of the derived default rather than a replacement for it, so focusing a session later does not silently undo a choice the user made. The control is hidden entirely when nothing is focused, because there is no workspace to scope to and a toggle with one meaningful position is noise. The debounce effect now depends on scope as well as query, so flipping re-runs the current query instead of leaving stale hits from the other regime on screen. Zero hits under workspace scope also offers a widen button inline -- the same reasoning as the Telegram keyboard, since an empty scoped result is exactly when widening helps. Ctrl+K is taken for open/close, so this is a click target rather than a key. Results already render hit.workdir, so global hits were legible without further work. Worth recording, since it is easy to misread: a workspace is a DIRECTORY, not a session family. workspaceIdFromPath hashes workdir + account_id + project_id, so every session that ever ran in that directory under the same tenant shares the workspace, related or not -- and a fork isolated into a git worktree gets a different path, so it lands OUTSIDE its parent's scope. That is precisely the history cross-workspace search recovers. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #309, which gave the TUI a Tab toggle between this-workspace and all-workspaces search. Telegram was left on the old path, so the capability was still unreachable there.
Two problems, not one.
The scope was wrong even when it worked
/searchsentscope:"workspace"with no workdir, so the daemon fell through to#guessCallerWorkdir— which returns the workdir of the most recently created session by that user.That's unrelated to what the Telegram user is attached to. You could be attached to
alpha, ask aboutalpha, and silently searchbetabecausebetawas started later. The handler now anchors on the attached session's workdir.With nothing attached there's no workspace worth scoping to, so the search runs cross-workspace rather than scoping to an arbitrary repo — the same rule the TUI modal uses for its initial scope.
No global path
Telegram has no Tab, so the widen control is an inline-keyboard button on the results: 🌐 Search all workspaces. Offered on zero hits too, which is exactly when widening is most useful.
callback_datacaps at 64 bytes and queries are free text, so the query is parked in#pendingSearcheskeyed${userId}:${short}— the same shape as approvals and provider dialogs — with oldest-first eviction at 200 entries and single-use tokens.Cross-workspace hits show the repo name, as in the TUI: two repos can each have a "fix auth" session, so a bare session name is ambiguous once results span workspaces.
Behaviour
basenameis now totalA hit whose session is no longer live can carry an empty workdir — the daemon already renders those as
(unknown)— and a missing repo label must not break the result list. The TUI copy from #309 had the same latent hazard and is fixed alongside; the existing chunked-output test caught it.Verification
bun run typecheckcleanbun run lintclean (360 files)bun test— 2401 pass, 19 skip, 0 failCo-authored-by: Claude Opus 5 (1M context) noreply@anthropic.com
🤖 Generated with Claude Code