feat: highlight your name in orange

This commit is contained in:
Alejandro Gómez
2025-12-11 10:28:10 +01:00
parent 36a9b95695
commit f6d490cf26
7 changed files with 77 additions and 7 deletions

View File

@@ -0,0 +1,40 @@
import { useGrimoire } from "@/core/state";
import { Copy, Check } from "lucide-react";
import { useCopy } from "@/hooks/useCopy";
export function DebugViewer() {
const { state } = useGrimoire();
const { copy, copied } = useCopy();
const stateJson = JSON.stringify(state, null, 2);
return (
<div className="h-full w-full flex flex-col">
<div className="flex items-center justify-between p-4 border-b">
<h2 className="text-lg font-semibold">Application State</h2>
<button
onClick={() => copy(stateJson)}
className="inline-flex items-center gap-2 px-3 py-1.5 text-sm rounded-md hover:bg-muted transition-colors"
title="Copy state to clipboard"
>
{copied ? (
<>
<Check className="h-4 w-4 text-green-500" />
<span>Copied</span>
</>
) : (
<>
<Copy className="h-4 w-4" />
<span>Copy</span>
</>
)}
</button>
</div>
<div className="flex-1 overflow-auto p-4">
<pre className="text-xs font-mono bg-muted rounded-md p-4 overflow-x-auto">
{stateJson}
</pre>
</div>
</div>
);
}

View File

@@ -13,6 +13,7 @@ import { RelayViewer } from "./RelayViewer";
import KindRenderer from "./KindRenderer";
import Feed from "./nostr/Feed";
import { WinViewer } from "./WinViewer";
import { DebugViewer } from "./DebugViewer";
interface WindowRendererProps {
window: WindowInstance;
@@ -129,6 +130,9 @@ export function WindowRenderer({ window, onClose }: WindowRendererProps) {
case "relay":
content = <RelayViewer url={window.props.url} />;
break;
case "debug":
content = <DebugViewer />;
break;
default:
content = (
<div className="p-4 text-muted-foreground">

View File

@@ -13,12 +13,16 @@ interface UserNameProps {
* Component that displays a user's name from their Nostr profile
* Shows placeholder derived from pubkey while loading or if no profile exists
* Clicking opens the user's profile
* Uses orange-400 color for the logged-in user
*/
export function UserName({ pubkey, isMention, className }: UserNameProps) {
const { addWindow } = useGrimoire();
const { addWindow, state } = useGrimoire();
const profile = useProfile(pubkey);
const displayName = getDisplayName(pubkey, profile);
// Check if this is the logged-in user
const isActiveAccount = state.activeAccount?.pubkey === pubkey;
const handleClick = (e: React.MouseEvent) => {
e.stopPropagation();
addWindow("profile", { pubkey }, `Profile ${pubkey.slice(0, 8)}...`);
@@ -27,7 +31,11 @@ export function UserName({ pubkey, isMention, className }: UserNameProps) {
return (
<span
dir="auto"
className={cn("cursor-pointer hover:underline", className)}
className={cn(
"font-semibold cursor-crosshair hover:underline hover:decoration-dotted",
isActiveAccount ? "text-orange-400" : "text-accent",
className,
)}
onClick={handleClick}
>
{isMention ? "@" : null}

View File

@@ -30,10 +30,7 @@ export interface BaseEventProps {
export function EventAuthor({ pubkey }: { pubkey: string }) {
return (
<div className="flex flex-col gap-0">
<UserName
pubkey={pubkey}
className="text-md text-accent cursor-crosshair font-semibold hover:underline hover:decoration-dotted"
/>
<UserName pubkey={pubkey} className="text-md" />
</div>
);
}

View File

@@ -11,7 +11,8 @@ export type AppId =
| "profile"
| "encode"
| "decode"
| "relay";
| "relay"
| "debug";
export interface WindowInstance {
id: string;

View File

@@ -87,6 +87,18 @@ export const manPages: Record<string, ManPageEntry> = {
category: "System",
defaultProps: { cmd: "help" },
},
// debug: {
// name: "debug",
// section: "1",
// synopsis: "debug",
// description:
// "Display the current application state for debugging purposes. Shows windows, workspaces, active account, and other internal state in a formatted view.",
// examples: ["debug View current application state"],
// seeAlso: ["help"],
// appId: "debug",
// category: "System",
// defaultProps: {},
// },
man: {
name: "man",
section: "1",