Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(agent-session): rename the split title by double-click, drop the pencil (#5989)

Wolf Mermelsteind7259f0df738
diff --git a/apps/web/src/components/app/split-layout/components/SplitLabel.tsx b/apps/web/src/components/app/split-layout/components/SplitLabel.tsx
index d73c452837..1cb248b383 100644
--- a/apps/web/src/components/app/split-layout/components/SplitLabel.tsx
+++ b/apps/web/src/components/app/split-layout/components/SplitLabel.tsx
@@ -29,6 +29,7 @@ import {
type Component,
createEffect,
createMemo,
+ createSignal,
For,
type JSX,
type ParentProps,
@@ -49,14 +50,21 @@ export function StaticSplitLabel(props: {
badges?: JSX.Element;
class?: string;
colorIcon?: boolean;
- /** Enables in-place editing while retaining the split title/menu chrome. */
+ /** Enables double-click renaming while retaining the split title/menu
+ * chrome. */
onRename?: (name: string) => void;
renameAriaLabel?: string;
}) {
const panel = useSplitPanelOrThrow();
+ const [renaming, setRenaming] = createSignal(false);
createEffect(() => {
panel.handle.setDisplayName(props.label);
});
+ const startRename = (event: MouseEvent) => {
+ event.preventDefault();
+ event.stopPropagation();
+ setRenaming(true);
+ };
const openTitleFileMenu = (e: MouseEvent) => {
if (!isTouchDevice()) return;
const trigger = panel.titleFileMenuTrigger();
@@ -96,15 +104,35 @@ export function StaticSplitLabel(props: {
}
>
{(onRename) => (
- <span onClick={(event) => event.stopPropagation()}>
- <InlineTitleEditor
- value={props.label}
- placeholder="Untitled"
- ariaLabel={props.renameAriaLabel ?? 'Rename'}
- onRename={onRename()}
- class="text-sm"
- />
- </span>
+ <Show
+ when={renaming()}
+ fallback={
+ <span
+ class="inline-block truncate text-sm font-semibold"
+ onDblClick={startRename}
+ onClick={(event) => {
+ if (isTouchDevice()) startRename(event);
+ }}
+ >
+ {props.label}
+ </span>
+ }
+ >
+ <span
+ onClick={(event) => event.stopPropagation()}
+ onDblClick={(event) => event.stopPropagation()}
+ >
+ <InlineTitleEditor
+ value={props.label}
+ placeholder="Untitled"
+ ariaLabel={props.renameAriaLabel ?? 'Rename'}
+ onRename={onRename()}
+ class="text-sm"
+ autofocus
+ onExit={() => setRenaming(false)}
+ />
+ </span>
+ </Show>
)}
</Show>
<Show when={panel.titleFileMenuTrigger()}>
diff --git a/apps/web/src/lib/core/component/InlineTitleEditor.tsx b/apps/web/src/lib/core/component/InlineTitleEditor.tsx
index 0574978905..7a613a64f6 100644
--- a/apps/web/src/lib/core/component/InlineTitleEditor.tsx
+++ b/apps/web/src/lib/core/component/InlineTitleEditor.tsx
@@ -1,11 +1,10 @@
-import PencilIcon from '@phosphor/pencil-simple.svg';
import { cn } from '@ui/utils/classname';
-import { createSignal } from 'solid-js';
+import { createSignal, onMount } from 'solid-js';
/**
* Inline-editable entity title, mirroring the markdown-document title UX:
- * the title is always editable in place — click to put the caret in it,
- * type, and the rename commits on blur/Enter (Escape discards). Blank or
+ * the title is edited in place with no pencil affordance — put the caret in
+ * it, type, and the rename commits on blur/Enter (Escape discards). Blank or
* unchanged edits are dropped rather than committed.
*/
export function InlineTitleEditor(props: {
@@ -16,11 +15,23 @@ export function InlineTitleEditor(props: {
onRename: (name: string) => void;
/** Optional typography and sizing override for compact title contexts. */
class?: string;
+ /** Focus and select the name once mounted, for callers that mount the
+ * editor in response to an explicit edit gesture. */
+ autofocus?: boolean;
+ /** Runs after the editor loses focus, whether the edit committed or was
+ * discarded, so those callers can drop back to their static title. */
+ onExit?: () => void;
}) {
// Local draft while the user is typing; null = show the current value.
const [draft, setDraft] = createSignal<string | null>(null);
let inputRef: HTMLInputElement | undefined;
+ onMount(() => {
+ if (!props.autofocus) return;
+ inputRef?.focus();
+ inputRef?.select();
+ });
+
const commit = () => {
const raw = draft();
setDraft(null);
@@ -31,45 +42,32 @@ export function InlineTitleEditor(props: {
};
return (
- <div class="group flex min-w-0 items-center gap-1.5">
- <input
- ref={inputRef}
- type="text"
- aria-label={props.ariaLabel}
- autocomplete="off"
- data-1p-ignore
- class={cn(
- 'field-sizing-content min-w-0 max-w-full truncate bg-transparent text-xl font-semibold outline-none',
- props.class
- )}
- placeholder={props.placeholder}
- value={draft() ?? props.value}
- onInput={(e) => setDraft(e.currentTarget.value)}
- onBlur={commit}
- onKeyDown={(e) => {
- if (e.key === 'Enter') {
- e.preventDefault();
- e.currentTarget.blur();
- } else if (e.key === 'Escape') {
- setDraft(null);
- e.currentTarget.blur();
- }
- }}
- />
- {/* Hover-only affordance; the input itself is the tab stop, and the
- pencil hides while editing (group-focus-within). */}
- <button
- type="button"
- aria-hidden="true"
- tabIndex={-1}
- class="shrink-0 text-ink-muted opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-0"
- onClick={() => {
- inputRef?.focus();
- inputRef?.select();
- }}
- >
- <PencilIcon class="size-4" />
- </button>
- </div>
+ <input
+ ref={inputRef}
+ type="text"
+ aria-label={props.ariaLabel}
+ autocomplete="off"
+ data-1p-ignore
+ class={cn(
+ 'field-sizing-content min-w-0 max-w-full truncate bg-transparent text-xl font-semibold outline-none',
+ props.class
+ )}
+ placeholder={props.placeholder}
+ value={draft() ?? props.value}
+ onInput={(e) => setDraft(e.currentTarget.value)}
+ onBlur={() => {
+ commit();
+ props.onExit?.();
+ }}
+ onKeyDown={(e) => {
+ if (e.key === 'Enter') {
+ e.preventDefault();
+ e.currentTarget.blur();
+ } else if (e.key === 'Escape') {
+ setDraft(null);
+ e.currentTarget.blur();
+ }
+ }}
+ />
);
}