-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat(web): add Ctrl/Cmd+F find-in-chat #3539
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
hendrillara
wants to merge
24
commits into
pingdotgg:main
Choose a base branch
from
hendrillara:feat/find-in-chat
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
0525e33
feat(settings): add agent-stop notification client settings
hendrillara a6170f0
fix(settings): restore ServerSettings tests clobbered while adding no…
hendrillara 84c59b8
feat(web): add pure agent-stop notification decision core
hendrillara 41aee0f
test(web): cover ready + pending-approvals transitions; drop redundan…
hendrillara 3ab92d0
feat(web): add Web Audio notification chime
hendrillara 2bcf3ec
feat(desktop): add IPC for native agent-stop notification + system beep
hendrillara e2fcc76
feat(web): observe agent-stop transitions and add notification settings
hendrillara ce16b78
docs(web): document the user-interrupt false-positive limitation
hendrillara 9d295c8
docs(web): correct the interrupt-limitation mechanism and JSDoc
hendrillara a5db683
refactor(notifications): apply PR-review fixes (batch sound, gate web…
hendrillara dd5c760
style(notifications): apply formatter (vp check --fix)
hendrillara 7cc6bf7
fix(notifications): use HostProcessPlatform; clear our lint warnings
hendrillara 63cecbc
feat(find): add markdown→text projection for chat search
hendrillara 6701155
feat(find): build ordered matches and reconcile active match
hendrillara cc3cc3d
perf(find): O(1) reverse offset mapping; fix straße comment and add c…
hendrillara b669934
feat(find): add pure row-location and turn-lookup helpers
hendrillara 2f12304
feat(find): add pure offset→node mapping for highlight ranges
hendrillara 95b9328
feat(find): register find.toggle command bound to mod+f
hendrillara 67ee7c4
feat(find): add find bar UI and state, opened by Cmd/Ctrl+F
hendrillara 8dc61c6
feat(find): reveal and scroll the active match across folds and work-…
hendrillara e114624
fix(find): reveal scroll fires on navigation only, not on every rows …
hendrillara 0744066
feat(find): precise CSS Custom Highlight rendering with reveal-flash …
hendrillara 9fa70c5
fix(find): clear highlights on unmount, cap current highlight to one …
hendrillara 7649e63
fix(find): reveal collapsed long user messages holding the active match
hendrillara File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| import * as Effect from "effect/Effect"; | ||
| import * as Option from "effect/Option"; | ||
| import * as Schema from "effect/Schema"; | ||
| import * as Electron from "electron"; | ||
|
|
||
| import { AgentNotificationRequestSchema } from "@t3tools/contracts"; | ||
| import { HostProcessPlatform } from "@t3tools/shared/hostProcess"; | ||
| import { ElectronWindow } from "../../electron/ElectronWindow.ts"; | ||
| import * as IpcChannels from "../channels.ts"; | ||
| import * as DesktopIpc from "../DesktopIpc.ts"; | ||
|
|
||
| // Retain references so notifications are not garbage-collected before the user | ||
| // clicks them (Electron does not keep them alive on its own). | ||
| const activeNotifications = new Set<Electron.Notification>(); | ||
|
|
||
| export const showAgentNotification = DesktopIpc.makeIpcMethod({ | ||
| channel: IpcChannels.SHOW_AGENT_NOTIFICATION_CHANNEL, | ||
| payload: AgentNotificationRequestSchema, | ||
| result: Schema.Void, | ||
| handler: Effect.fn("desktop.ipc.agentNotifications.show")(function* (request) { | ||
| const electronWindow = yield* ElectronWindow; | ||
| const targetWindow = Option.getOrNull(yield* electronWindow.currentMainOrFirst); | ||
| const isDarwin = (yield* HostProcessPlatform) === "darwin"; | ||
|
|
||
| yield* Effect.sync(() => { | ||
| const notification = new Electron.Notification({ | ||
| title: request.title, | ||
| body: request.body, | ||
| silent: true, | ||
| }); | ||
| activeNotifications.add(notification); | ||
| notification.on("close", () => activeNotifications.delete(notification)); | ||
| notification.on("click", () => { | ||
| try { | ||
| activeNotifications.delete(notification); | ||
| if (targetWindow === null || targetWindow.isDestroyed()) return; | ||
| if (targetWindow.isMinimized()) targetWindow.restore(); | ||
| if (!targetWindow.isVisible()) targetWindow.show(); | ||
| if (isDarwin) Electron.app.focus({ steal: true }); | ||
| targetWindow.focus(); | ||
| targetWindow.webContents.send(IpcChannels.AGENT_NOTIFICATION_CLICKED_CHANNEL, { | ||
| threadId: request.threadId, | ||
| environmentId: request.environmentId, | ||
| }); | ||
| } catch (error) { | ||
| // @effect-diagnostics-next-line globalConsole:off - Electron click callback runs outside the Effect runtime. | ||
| console.error("agentNotifications click handler failed", error); | ||
| } | ||
| }); | ||
| notification.show(); | ||
| }); | ||
| }), | ||
| }); | ||
|
|
||
| export const playSystemSound = DesktopIpc.makeIpcMethod({ | ||
| channel: IpcChannels.PLAY_SYSTEM_SOUND_CHANNEL, | ||
| payload: Schema.Void, | ||
| result: Schema.Void, | ||
| handler: Effect.fn("desktop.ipc.agentNotifications.beep")(function* () { | ||
| yield* Effect.sync(() => { | ||
| Electron.shell.beep(); | ||
| }); | ||
| }), | ||
| }); |
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| import { useEffect, useRef } from "react"; | ||
| import { useNavigate, useParams } from "@tanstack/react-router"; | ||
| import type { OrchestrationSessionStatus } from "@t3tools/contracts"; | ||
|
|
||
| import { useClientSettings } from "~/hooks/useSettings"; | ||
| import { decideAgentStopNotifications } from "~/lib/agentStopNotifications"; | ||
| import { playNotificationTone } from "~/lib/notificationSound"; | ||
| import { useProjects, useThreadShells } from "~/state/entities"; | ||
|
|
||
| /** | ||
| * App-global observer that watches every thread's session status and emits a | ||
| * native notification + sound when an agent stops working. Renders nothing. | ||
| */ | ||
| export function AgentStopNotifications(): null { | ||
| const threads = useThreadShells(); | ||
| const projects = useProjects(); | ||
| const popup = useClientSettings((s) => s.notifyOnAgentStopPopup); | ||
| const sound = useClientSettings((s) => s.notifyOnAgentStopSound); | ||
| const soundSource = useClientSettings((s) => s.notifyOnAgentStopSoundSource); | ||
| const activeThreadId = (useParams({ strict: false }) as { threadId?: string }).threadId ?? null; | ||
| const navigate = useNavigate(); | ||
|
|
||
| const prevStatusesRef = useRef<ReadonlyMap<string, OrchestrationSessionStatus>>(new Map()); | ||
|
|
||
| useEffect(() => { | ||
| const isAppFocused = typeof document !== "undefined" ? document.hasFocus() : false; | ||
| const { notifications, nextStatuses } = decideAgentStopNotifications({ | ||
| prevStatuses: prevStatusesRef.current, | ||
| threads, | ||
| projects, | ||
| settings: { popup, sound, soundSource }, | ||
| activeThreadId, | ||
| isAppFocused, | ||
| }); | ||
| prevStatusesRef.current = nextStatuses; | ||
|
|
||
| for (const notification of notifications) { | ||
| if (popup) { | ||
| void window.desktopBridge | ||
| ?.showAgentNotification({ | ||
| title: notification.title, | ||
| body: notification.body, | ||
| threadId: notification.threadId, | ||
| environmentId: notification.environmentId, | ||
| }) | ||
| ?.catch((error: unknown) => console.warn("showAgentNotification failed", error)); | ||
| } | ||
| } | ||
| if (sound && notifications.length > 0) { | ||
| if (soundSource === "system") { | ||
| void window.desktopBridge | ||
| ?.playSystemSound() | ||
| ?.catch((error: unknown) => console.warn("playSystemSound failed", error)); | ||
| } else { | ||
| playNotificationTone(); | ||
| } | ||
| } | ||
| }, [threads, projects, popup, sound, soundSource, activeThreadId]); | ||
|
|
||
| useEffect(() => { | ||
| const subscribe = window.desktopBridge?.onAgentNotificationClicked; | ||
| if (typeof subscribe !== "function") return; | ||
| const unsubscribe = subscribe(({ threadId, environmentId }) => { | ||
| void navigate({ | ||
| to: "/$environmentId/$threadId", | ||
| params: { environmentId, threadId }, | ||
| }); | ||
| }); | ||
| return () => unsubscribe?.(); | ||
| }, [navigate]); | ||
|
|
||
| return null; | ||
| } |
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Find highlights lag match counter
Medium Severity
The chat find feature uses a deferred query for its match list and match count, but an immediate query for applying highlights to the DOM. This can cause the displayed highlights, match counts, and active match selection to become out of sync, particularly when typing quickly.
Reviewed by Cursor Bugbot for commit 7649e63. Configure here.