Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(threads): restore missing permission grant component

Steven Enamakel4ce921c55f2f
diff --git a/app/src/components/assistant-ui/elements/permission-grant.tsx b/app/src/components/assistant-ui/elements/permission-grant.tsx
new file mode 100644
index 0000000000..d6b82a65fb
--- /dev/null
+++ b/app/src/components/assistant-ui/elements/permission-grant.tsx
@@ -0,0 +1,169 @@
+'use client';
+
+/**
+ * assistant-ui's permission-grant element: a capability request (e.g. an
+ * OAuth connect) with a "this grants" list and Deny / This session / Always
+ * decisions.
+ *
+ * Vendored from the assistant-ui `elements-permission-grant` registry item
+ * (https://r.assistant-ui.com/styles/base-nova/elements-permission-grant.json).
+ * Changes from upstream:
+ * - `cn` import path (`@/components/assistant-ui/lib/utils`).
+ * - Every user-facing label is now a prop with an English default, so the
+ * calling adapter supplies the translated string via `useT()`.
+ * - `denyProps` / `sessionProps` / `alwaysProps` slots, same rationale as
+ * `approval-card.tsx`: OpenHuman's e2e specs click a decision by its
+ * `data-analytics-id`, which the upstream buttons carry no way to attach.
+ * - `pendingLabel` / `deniedLabel` / `grantedLabel` are now format functions
+ * (`(scope) => string`) rather than a bare string, so the OpenHuman connect
+ * card can render "granted · always" from one translated template
+ * (`chat.approval.*` keys use `{scope}` placeholders) instead of
+ * concatenating English words.
+ * - Added a `busy` state distinct from `pending`: the OpenHuman OAuth handoff
+ * (poll for connection) has an in-flight phase with no decision buttons yet
+ * resolved, which upstream's `pending`/`GrantScope` union does not model.
+ */
+import type { ComponentProps } from 'react';
+import { KeyRoundIcon } from 'lucide-react';
+
+import { cn } from '@/components/assistant-ui/lib/utils';
+
+import { field, inkButton, mono, paper } from './surfaces';
+
+export type GrantScope = 'session' | 'always' | 'denied';
+
+export function PermissionGrant({
+ capability,
+ requester,
+ requesterLabel = 'requested by',
+ reach,
+ reachLabel = 'this grants',
+ scope,
+ onGrant,
+ denyLabel = 'Deny',
+ sessionLabel = 'This session',
+ alwaysLabel = 'Always',
+ pendingLabel = 'pending',
+ deniedLabel = 'denied',
+ grantedLabel = (grantedScope: GrantScope) => `granted · ${grantedScope}`,
+ denyProps,
+ sessionProps,
+ alwaysProps,
+ className,
+ ...props
+}: Omit<
+ ComponentProps<'div'>,
+ 'children' | 'capability' | 'requester' | 'reach' | 'scope' | 'onGrant'
+> & {
+ capability: string;
+ requester: string;
+ requesterLabel?: string;
+ reach: readonly string[];
+ reachLabel?: string;
+ scope: GrantScope | 'pending' | 'busy';
+ onGrant?: (scope: GrantScope) => void;
+ denyLabel?: string;
+ sessionLabel?: string;
+ alwaysLabel?: string;
+ pendingLabel?: string;
+ deniedLabel?: string;
+ grantedLabel?: (scope: GrantScope) => string;
+ denyProps?: ComponentProps<'button'>;
+ sessionProps?: ComponentProps<'button'>;
+ alwaysProps?: ComponentProps<'button'>;
+}) {
+ return (
+ <div
+ data-slot="permission-grant"
+ className={cn(paper, 'flex w-full max-w-sm flex-col gap-3.5 rounded-[20px] p-4', className)}
+ {...props}
+ >
+ <div className="flex items-center gap-2.5">
+ <span className="bg-foreground/[0.05] text-foreground/45 flex size-7 shrink-0 items-center justify-center rounded-lg">
+ <KeyRoundIcon className="size-3.5" />
+ </span>
+ <div className="flex min-w-0 flex-1 flex-col">
+ <span className="truncate text-[13.5px] font-medium">{capability}</span>
+ <span className="text-foreground/45 truncate text-xs">
+ {requesterLabel} {requester}
+ </span>
+ </div>
+ </div>
+
+ <div className="flex flex-col gap-1">
+ <span className={cn(mono, 'text-foreground/30')}>{reachLabel}</span>
+ {reach.map(item => (
+ <span key={item} className="text-foreground/60 flex items-baseline gap-2 text-xs">
+ <span aria-hidden className="bg-foreground/20 size-1 rounded-full" />
+ {item}
+ </span>
+ ))}
+ </div>
+
+ <div className="flex h-8 items-center justify-end gap-2">
+ {scope === 'pending' || scope === 'busy' ? (
+ onGrant && scope === 'pending' ? (
+ <>
+ <button
+ type="button"
+ onClick={() => onGrant('denied')}
+ {...denyProps}
+ className={cn(
+ 'text-foreground/55 hover:bg-foreground/[0.06] hover:text-foreground/90 h-8 rounded-full px-3 text-xs font-medium transition-[background-color,color,scale] duration-150 active:scale-[0.96]',
+ denyProps?.className
+ )}
+ >
+ {denyLabel}
+ </button>
+ <button
+ type="button"
+ onClick={() => onGrant('session')}
+ {...sessionProps}
+ className={cn(
+ 'text-foreground/55 hover:bg-foreground/[0.06] hover:text-foreground/90 h-8 rounded-full px-3 text-xs font-medium transition-[background-color,color,scale] duration-150 active:scale-[0.96]',
+ sessionProps?.className
+ )}
+ >
+ {sessionLabel}
+ </button>
+ <button
+ type="button"
+ onClick={() => onGrant('always')}
+ {...alwaysProps}
+ className={cn(
+ inkButton,
+ 'flex h-8 items-center rounded-full px-3 text-xs font-medium',
+ alwaysProps?.className
+ )}
+ >
+ {alwaysLabel}
+ </button>
+ </>
+ ) : (
+ <span
+ key={scope}
+ className={cn(
+ field,
+ mono,
+ 'fade-in animate-in text-foreground/55 rounded-full px-2.5 py-1.5 duration-300'
+ )}
+ >
+ {pendingLabel}
+ </span>
+ )
+ ) : (
+ <span
+ key={scope}
+ className={cn(
+ field,
+ mono,
+ 'fade-in animate-in text-foreground/55 rounded-full px-2.5 py-1.5 duration-300'
+ )}
+ >
+ {scope === 'denied' ? deniedLabel : grantedLabel(scope)}
+ </span>
+ )}
+ </div>
+ </div>
+ );
+}
diff --git a/crates/openhuman-core/src/threads/transcript_view/project.rs b/crates/openhuman-core/src/threads/transcript_view/project.rs
index 7c7ec6a838..99d9b9442f 100644
--- a/crates/openhuman-core/src/threads/transcript_view/project.rs
+++ b/crates/openhuman-core/src/threads/transcript_view/project.rs
@@ -246,6 +246,7 @@ impl Projector {
request_id: msg.request_id.clone(),
model: msg.turn_usage.as_ref().map(|tu| tu.model.clone()),
iteration: msg.iteration,
+ ts: msg.ts.clone(),
});
}
}
@@ -315,6 +316,7 @@ impl Projector {
request_id: msg.request_id.clone(),
model: msg.turn_usage.as_ref().map(|tu| tu.model.clone()),
iteration: Some(iteration),
+ ts: msg.ts.clone(),
});
}