mirror of
https://github.com/multica-ai/multica.git
synced 2026-07-05 21:39:54 +02:00
fix(chat): disable focus button on pages without an anchor
The focus toggle was only disabled when focusMode was already ON *and* the current page had no anchor. Off-state on the same page stayed clickable — clicking turned it on, and the button instantly greyed out, making the missing fourth state visible. Decouple "clickable" from focusMode: the button is disabled whenever the current page has no anchor, regardless of the persisted on/off preference. Both the chip render (context-anchor.tsx:173) and send path (chat-window.tsx:176) already guard on candidate presence, so leaving focusMode=true on an unanchorable page has no side effects — the preference is preserved for the next anchorable page. Tooltip now reads "Nothing to share with Multica on this page" whenever the button is disabled, regardless of focusMode. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -109,13 +109,13 @@ export function useRouteAnchorCandidate(wsId: string): {
|
||||
}
|
||||
|
||||
/**
|
||||
* Focus-mode toggle. Three visual states driven by two dimensions:
|
||||
* - focusMode (persisted) on | off
|
||||
* - candidate present yes | no
|
||||
* Focus-mode toggle. Disabled whenever the current page has no anchor
|
||||
* (nothing to share) — focusMode persists across such pages, so returning
|
||||
* to an anchorable page restores the user's prior on/off choice.
|
||||
*
|
||||
* off → ghost + muted, clickable (→ turns on)
|
||||
* no candidate → disabled
|
||||
* off + candidate → ghost + muted, clickable (→ turns on)
|
||||
* on + candidate → secondary (bright), clickable (→ turns off)
|
||||
* on + no candidate → disabled (can't click until a focus target exists)
|
||||
*/
|
||||
export function ContextAnchorButton() {
|
||||
const wsId = useWorkspaceId();
|
||||
@@ -124,16 +124,16 @@ export function ContextAnchorButton() {
|
||||
const setFocusMode = useChatStore((s) => s.setFocusMode);
|
||||
|
||||
const hasAnchor = !!candidate;
|
||||
const isDisabled = focusMode && !hasAnchor && !isResolving;
|
||||
const isDisabled = !hasAnchor && !isResolving;
|
||||
const isBright = focusMode && hasAnchor;
|
||||
|
||||
const tooltipText = !focusMode
|
||||
? "Let Multica know what you're viewing"
|
||||
: hasAnchor
|
||||
const tooltipText = isDisabled
|
||||
? "Nothing to share with Multica on this page"
|
||||
: focusMode && candidate
|
||||
? candidate.type === "issue"
|
||||
? `Multica knows you're viewing ${candidate.label} · Click to turn off`
|
||||
: `Multica knows you're viewing project "${candidate.label}" · Click to turn off`
|
||||
: "Nothing to share with Multica on this page";
|
||||
: "Let Multica know what you're viewing";
|
||||
|
||||
return (
|
||||
<Tooltip>
|
||||
|
||||
Reference in New Issue
Block a user