Repository navigation
feat: @-mention a browser tab so the agent works in it #25469
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
Closed
bilalbayram
wants to merge
4
commits into
pingdotgg:main
from
bilalbayram:feat/composer-browser-tab-mentions
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
ae78fff
feat: @-mention a browser tab so the agent works in it
bilalbayram 3db23a8
fix: tab chips open their own thread; answers keep the tab id
bilalbayram 4c4e56f
fix: tab mentions stay distinct across threads; mobile won't open a s…
bilalbayram 35a574a
fix: encode tab mention ids unambiguously
bilalbayram 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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,57 @@ | ||
| import type { BrowserTabContextRecord } from "@t3tools/contracts"; | ||
| import { useNavigate } from "@tanstack/react-router"; | ||
| import { GlobeIcon } from "lucide-react"; | ||
|
|
||
| import { useFaviconForThreadUrl } from "~/browserFaviconStore"; | ||
| import { useThreadPreviewState } from "~/previewStateStore"; | ||
| import { useRightPanelStore } from "~/rightPanelStore"; | ||
| import { ContextChip, ContextChipLabel } from "./ContextChip"; | ||
| import { FaviconImage } from "./preview/PreviewFaviconIcon"; | ||
| import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip"; | ||
|
|
||
| export function BrowserTabContextChip(props: { | ||
| record: Pick<BrowserTabContextRecord, "environmentId" | "threadId" | "tabId" | "title" | "url">; | ||
| copyMarkdown?: string; | ||
| }) { | ||
| const { environmentId, threadId, tabId } = props.record; | ||
| const threadRef = { environmentId, threadId }; | ||
| const session = useThreadPreviewState(threadRef).sessions[tabId]; | ||
| const liveUrl = session && session.navStatus._tag !== "Idle" ? session.navStatus.url : null; | ||
| const liveTitle = | ||
| session && session.navStatus._tag !== "Idle" ? session.navStatus.title.trim() : ""; | ||
| const url = liveUrl ?? props.record.url; | ||
| const title = liveTitle || props.record.title; | ||
| const favicon = useFaviconForThreadUrl(threadRef, url ?? ""); | ||
| const navigate = useNavigate(); | ||
| return ( | ||
| <Tooltip> | ||
| <TooltipTrigger | ||
| render={ | ||
| <ContextChip | ||
| kind="browser-tab" | ||
| {...(session ? {} : { state: "unresolved" as const })} | ||
| render={<button type="button" disabled={!session} />} | ||
| onClick={() => { | ||
| // A chip pasted into another thread still points at the tab's own thread. | ||
| useRightPanelStore.getState().openBrowser(threadRef, tabId); | ||
| void navigate({ to: "/$environmentId/$threadId", params: threadRef }); | ||
| }} | ||
| aria-label={`Browser tab, ${title}`} | ||
| data-markdown-copy={props.copyMarkdown} | ||
| > | ||
| <FaviconImage | ||
| sources={[favicon]} | ||
| fallback={<GlobeIcon />} | ||
| className="size-[1.17em] self-center rounded-sm object-contain" | ||
| /> | ||
| <ContextChipLabel>{title}</ContextChipLabel> | ||
| </ContextChip> | ||
| } | ||
| /> | ||
| <TooltipPopup side="top"> | ||
| {session ? "Show in browser" : "Tab closed"} | ||
| {url ? <div className="max-w-80 truncate text-muted-foreground">{url}</div> : null} | ||
| </TooltipPopup> | ||
| </Tooltip> | ||
| ); | ||
| } |
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
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.
Recheck the requested tab while it remains selected.
If the requested tab closes after this check marks it
"open",initialTabStatusstays"open". Line 102 then selects another tab, and the closed-tab alert does not run. This can show a different tab when the user opened a browser-tab mention. Detect that closure whileselectedTabIdis still the requested tab, then close the preview instead of using the fallback.