mirror of
https://github.com/block/buzz.git
synced 2026-10-30 22:11:36 +00:00
Keep default activity ingress in app
Co-authored-by: Rizz <302abe414ca6e3134763d2539bfcf145aea2a63fe5f8455204ed602fd40cf381@buzz.block.builderlab.xyz> Signed-off-by: Taylor Ho <taylorkmho@gmail.com>
This commit is contained in:
@@ -5,7 +5,6 @@ import { useAppNavigation } from "@/app/navigation/useAppNavigation";
|
||||
import { useChannelReferences } from "@/features/channels/openChannelDirectory";
|
||||
import { useAgentSession } from "@/shared/context/AgentSessionContext";
|
||||
import type { Channel } from "@/shared/api/types";
|
||||
import { openAgentActivityWindow } from "@/shared/api/agentActivityWindow";
|
||||
import { normalizePubkey } from "@/shared/lib/pubkey";
|
||||
import { getAgentWorkingState } from "./agentWorkingSignal";
|
||||
import { useRelayAgentsQuery } from "./hooks";
|
||||
@@ -55,11 +54,23 @@ export function resolveOpenableActivityChannelId({
|
||||
}
|
||||
|
||||
/**
|
||||
* Universal ingress for opening an agent's activity feed.
|
||||
* Universal ingress for opening an agent's activity pane.
|
||||
*
|
||||
* The selected channel is still resolved and authorized in the current
|
||||
* webview, but Tauri presents the existing channel-scoped feed in a dedicated
|
||||
* companion window. Browser builds keep the previous in-app route fallback.
|
||||
* Inside a channel screen the AgentSessionContext handler opens the pane in
|
||||
* place. Everywhere else (agents page, home profile panel, popovers reached
|
||||
* from non-channel routes) there is no provider, so we navigate to a channel
|
||||
* with the `agentSession` search param instead — preferring a channel the
|
||||
* agent is currently working in (unified working signal), then falling back
|
||||
* to the first channel the agent is a member of.
|
||||
*
|
||||
* Navigation only ever targets channels the viewer can actually open
|
||||
* (joined, or open visibility). Owner-global ingestion means the working
|
||||
* signal can report activity in rooms the viewer can't access; deep-linking
|
||||
* there would land on a screen they can't read. In that case we surface a
|
||||
* safe warning instead of navigating — no channel content, no trap-door.
|
||||
*
|
||||
* The separate pop-out actions invoke the native companion window explicitly;
|
||||
* ordinary activity entry points preserve the existing in-app behavior.
|
||||
*/
|
||||
export function useOpenAgentActivity() {
|
||||
const { onOpenAgentSession } = useAgentSession();
|
||||
@@ -138,22 +149,6 @@ export function useOpenAgentActivity() {
|
||||
[areChannelsReady, onOpenAgentSession, resolveChannelId],
|
||||
);
|
||||
|
||||
const openActivityDestination = React.useCallback(
|
||||
(pubkey: string, channelId: string): void => {
|
||||
void openAgentActivityWindow(channelId, pubkey)
|
||||
.then((openedNativeWindow) => {
|
||||
if (!openedNativeWindow) {
|
||||
void goChannel(channelId, { agentSession: pubkey });
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Failed to open agent activity window:", error);
|
||||
toast.error("Couldn't open the agent activity window.");
|
||||
});
|
||||
},
|
||||
[goChannel],
|
||||
);
|
||||
|
||||
const openAgentActivity = React.useCallback(
|
||||
(pubkey: string, options?: { channelId?: string | null }): boolean => {
|
||||
// An explicit channel target (e.g. clicking a "Working in #channel"
|
||||
@@ -167,18 +162,22 @@ export function useOpenAgentActivity() {
|
||||
toast.warning(INACCESSIBLE_ACTIVITY_MESSAGE);
|
||||
return false;
|
||||
}
|
||||
openActivityDestination(pubkey, options.channelId);
|
||||
void goChannel(options.channelId, { agentSession: pubkey });
|
||||
return true;
|
||||
}
|
||||
// A channel-scoped AgentSessionProvider belongs to the channel view
|
||||
// already authorized by its route. Do not reject its own current
|
||||
// channel while the member/reference query is still settling.
|
||||
openActivityDestination(pubkey, options.channelId);
|
||||
onOpenAgentSession(pubkey, options.channelId);
|
||||
return true;
|
||||
}
|
||||
if (onOpenAgentSession) {
|
||||
onOpenAgentSession(pubkey);
|
||||
return true;
|
||||
}
|
||||
const channelId = resolveChannelId(pubkey);
|
||||
if (channelId) {
|
||||
openActivityDestination(pubkey, channelId);
|
||||
void goChannel(channelId, { agentSession: pubkey });
|
||||
return true;
|
||||
}
|
||||
// The agent may be working somewhere, just nowhere the viewer can open.
|
||||
@@ -189,12 +188,7 @@ export function useOpenAgentActivity() {
|
||||
}
|
||||
return false;
|
||||
},
|
||||
[
|
||||
findOpenableChannel,
|
||||
onOpenAgentSession,
|
||||
openActivityDestination,
|
||||
resolveChannelId,
|
||||
],
|
||||
[findOpenableChannel, goChannel, onOpenAgentSession, resolveChannelId],
|
||||
);
|
||||
|
||||
return { canOpenAgentActivity, openAgentActivity };
|
||||
|
||||
Reference in New Issue
Block a user