Skip to content

Keep a new plan's title in sync with its prompt and LLM-generated name instead of freezing the first word #2476

Closed

Description

@propr-dev

Context

A new plan is saved automatically while the user types in Planner Studio (/studio/new). useAutoDraftCreation waits for a 1-second pause, then calls createDraft(repo, prompt). The backend stores the plan name from the prompt as it was at that moment. Users often pause after the first word, so the saved name is something like Add or Fix.

The name is already partly corrected on the server. usePromptPersistence (in setupWizardHooks.ts) later calls updateDraft(draftId, { initial_prompt, name: truncateToSentences(prompt) }). The UI still shows the stale title for three reasons:

  1. The in-place draft object is never refreshed. PlanStudioPage stores the created draft in inPlaceDraft through handleDraftCreatedInPlace and computes activeDraft = inPlaceDraft || draft. The document/tab title comes from getDocumentTitle(activeDraft). inPlaceDraft is only set once, at creation, so the title stays at the first word even after the server has a better name.
  2. Prompt saves give no feedback. usePromptPersistence writes the new name to the server but tells nobody, so no component can update its local copy.
  3. Display code uses draft.name directly. Other places (PlanEditor.getPlanName, ApprovedPlanView, PlansListItem in PlansPageComponents.tsx, PlanStudioPage.getTaskTitle) render draft.name || draft.initial_prompt. If a stale prompt-derived name reaches them before the next prompt save lands (for example, the user reloads within the debounce window), they show the one-word title even though initial_prompt holds the full text.

The LLM-generated title is set server-side (for example, the epic/plan title generated with the summarization model during finalization). It must always win over anything derived from the prompt. Today it does win once the draft is refetched. The inPlaceDraft || draft ordering, however, can keep showing the stale in-place copy.

Requirements

  1. Create a single display-name helper, getDraftDisplayName(draft, fallback), and use it everywhere a plan title is shown.
    • If name looks like it was derived from an earlier, shorter version of the current prompt, show a title derived from the current prompt using the existing truncateToSentences.
    • A name counts as stale-derived when the current prompt starts with it (ignoring a trailing ...) and the name is shorter than the title the current prompt would produce.
    • Any other name (LLM-generated or user-provided) is shown unchanged.
    • With no name, fall back to the prompt-derived title, then to the fallback text.
  2. Add an optional onPersisted callback to usePromptPersistence. After each successful save, including flushes before generation, call it with { draftId, initial_prompt, name }.
  3. Add an optional onDraftMetadataPersisted prop to SetupWizard and pass it to usePromptPersistence through useSetupWizardLoaders.
  4. In PlanStudioPage:
    • Store the latest persisted metadata in a metadataOverride state and use it only for the page title, and only while the draft is still in setup (draft / failed status).
    • Do not merge the override into the draft prop passed to SetupWizard. Changing draft.initial_prompt there resets useDebouncedDraftPersistence, which cancels a pending debounced save and could lose the user's latest keystrokes.
    • Prefer the refetched draft from useDraft over the one-time inPlaceDraft snapshot when computing the title, so an LLM-generated name shows up as soon as it is fetched.
    • Reset the override on navigation (location.key), as is already done for inPlaceDraft.
  5. Replace direct draft.name || draft.initial_prompt usage with getDraftDisplayName in PlanEditor.tsx, ApprovedPlanView.tsx, PlansPageComponents.tsx and PlanStudioPage.tsx (getTaskTitle, getDocumentTitle).
  6. Make no backend or API changes. The server already stores the corrected name on every prompt save and the LLM title on finalization; only the UI is stale.

Implementation Specification

  1. New file propr-ui/src/components/TaskPlanner/planDisplayName.ts: export isStalePromptDerivedName and getDraftDisplayName. It imports truncateToSentences from ./setupWizardPrompt so the displayed title matches exactly what the server will store.
  2. New test propr-ui/src/components/TaskPlanner/planDisplayName.test.ts.
  3. setupWizardHooks.ts:
    • Export a PromptPersistedUpdate interface.
    • Add a fifth optional parameter onPersisted to usePromptPersistence, stored in a ref so changing callbacks do not recreate enqueuePromptSave.
    • Call it after updateDraft resolves inside the save queue.
  4. SetupWizard.tsx:
    • Add the onDraftMetadataPersisted prop.
    • Add a third parameter to useSetupWizardLoaders and forward it to usePromptPersistence.
  5. PlanStudioPage.tsx:
    • Add the override state, the handler and the applyMetadataOverride helper.
    • Pass onDraftMetadataPersisted to NewDraftView and DraftView (both render SetupWizard).
    • Update the title helpers.
  6. PlanEditor.tsx, ApprovedPlanView.tsx, PlansPageComponents.tsx: switch to getDraftDisplayName.
  7. setupWizardHooks.persistence.test.tsx: add a test proving onPersisted receives the derived name.

Acceptance Criteria

  • Open /studio/new, type Add, wait about 1.5 s so the draft is created, then keep typing Add dark mode toggle to settings.. Within about 1 s of stopping, the browser tab title changes from Add | ProPR to Add dark mode toggle to settings. | ProPR without a page reload.
  • Stored name Add and initial_prompt Add dark mode toggle to settings.: the Plans list, Plan Editor header and Approved view show the full derived title.
  • A name that is not a prefix of the prompt (LLM-generated such as Dark Mode Settings Toggle, or user-renamed) is always shown unchanged.
  • After finalization, when the server sets an LLM title, the studio header and tab title show that title once the draft is refetched. The one-time in-place snapshot does not override it.
  • Typing continuously never loses characters. The override is not passed into SetupWizard's draft prop, and existing persistence tests still pass.
  • npm test -w propr-ui passes, including the new planDisplayName.test.ts and the new persistence test.
  • npm run typecheck -w propr-ui and npm run lint -w propr-ui -- --max-warnings 0 pass.

Created by ProPR AI Planner

Activity

  1. propr-dev commented on Sep 23, 2026

    @propr-dev
    ContributorAuthor

    Suggested Implementation:

    Implementation Approach

    The server already holds the right data. Every debounced prompt save writes name: truncateToSentences(prompt), and finalization writes an LLM-generated title. The bug is purely client-side: the UI keeps a one-time snapshot of the draft (inPlaceDraft) and renders draft.name directly. The fix has two parts:

    1. Push: usePromptPersistence reports each successful save through an optional callback. PlanStudioPage stores that metadata in a title-only override, so the tab title updates as soon as the save lands.
    2. Pull / defensive rendering: a single getDraftDisplayName helper recognises a name that was frozen from an earlier, shorter prompt and shows the current prompt's title instead. It never overrides a name that is not a prompt prefix, so LLM or user titles always win.

    Alternatives considered:

    • Refetching the draft after every prompt save. Rejected. It adds network traffic and can flip useDraft into a loading state, which unmounts the wizard (PlanStudioPage renders LoadingView while loading).
    • Raising the auto-create threshold (for example, waiting for 20 characters before creating the draft). Rejected. It delays auto-save and does not fix the stale title when a user pauses after 20 characters.
    • Merging the override into SetupWizard's draft prop. Rejected. useDebouncedDraftPersistence clears the pending debounce timer whenever draft.initial_prompt changes, which would drop the user's latest keystrokes.
    • A backend change (a draft-update socket event with the new name). Not needed, because no server data is wrong. It can be done later if the header dropdown also needs live renames.

    Trade-off: a user-chosen name that is exactly a prefix of the prompt would be displayed as the longer prompt-derived title. There is no rename UI today and LLM titles are never literal prompt prefixes, so this edge case is acceptable.

    File: propr-ui/src/components/TaskPlanner/planDisplayName.ts (new file)

    Why this file: One source of truth for how a plan title is displayed, so the studio, editor, approved view and Plans list cannot disagree. It reuses truncateToSentences so the displayed fallback is byte-identical to what the next prompt save will persist, which avoids a visible title change when the server catches up.

    import { truncateToSentences } from './setupWizardPrompt';
    
    interface DraftNameSource {
      name?: string | null;
      initial_prompt?: string | null;
    }
    
    // truncateToSentences appends '...' when it shortens long prompts. Strip it
    // before comparing so a truncated name can still be recognised as a prefix.
    const stripEllipsis = (value: string): string =>
      (value.endsWith('...') ? value.slice(0, -3) : value).trim();
    
    /**
     * True when `name` was derived from an EARLIER, shorter version of the prompt,
     * e.g. auto-save created the draft after the user typed only "Add".
     * We require both: the current prompt starts with the name, and the name is
     * shorter than what the current prompt would produce. An LLM-generated or
     * user-chosen title is (practically) never a literal prompt prefix, so it is
     * never treated as stale and always wins.
     */
    export function isStalePromptDerivedName(name: string, prompt: string, derivedName: string): boolean {
      const base = stripEllipsis(name);
      if (!base) return true;
      return base.length < stripEllipsis(derivedName).length && prompt.startsWith(base);
    }
    
    /**
     * Title to show for a plan everywhere in the UI.
     * Order of preference:
     *   1. A real (non-stale) stored name: LLM summary or user rename.
     *   2. A title derived from the CURRENT prompt, computed exactly like the
     *      server-side name persisted by usePromptPersistence.
     *   3. The caller-provided fallback.
     */
    export function getDraftDisplayName(
      draft: DraftNameSource | null | undefined,
      fallback = 'Untitled Plan',
    ): string {
      if (!draft) return fallback;
      const name = (draft.name ?? '').trim();
      const prompt = (draft.initial_prompt ?? '').trim();
      const derivedName = prompt ? truncateToSentences(prompt) : '';
    
      if (!name) return derivedName || fallback;
      // Only replace the stored name when it is a stale prefix of the prompt;
      // never downgrade a meaningful title to raw prompt text.
      if (derivedName && isStalePromptDerivedName(name, prompt, derivedName)) return derivedName;
      return name;
    }

    File: propr-ui/src/components/TaskPlanner/planDisplayName.test.ts (new file)

    Why this file: Locks down the two properties that matter: first-word names get replaced, and LLM/user titles are never replaced.

    import { describe, expect, it } from 'vitest';
    import { getDraftDisplayName, isStalePromptDerivedName } from './planDisplayName';
    
    describe('getDraftDisplayName', () => {
      it('replaces a name frozen from the first word of the prompt', () => {
        expect(getDraftDisplayName({
          name: 'Add',
          initial_prompt: 'Add dark mode toggle to settings. Persist it per user.',
        })).toBe('Add dark mode toggle to settings. Persist it per user.');
      });
    
      it('keeps an LLM-generated or user-provided title that is not a prompt prefix', () => {
        expect(getDraftDisplayName({
          name: 'Dark Mode Settings Toggle',
          initial_prompt: 'Add dark mode toggle to settings.',
        })).toBe('Dark Mode Settings Toggle');
      });
    
      it('keeps a name that already matches the full prompt summary', () => {
        expect(getDraftDisplayName({ name: 'Add dark mode', initial_prompt: 'Add dark mode' }))
          .toBe('Add dark mode');
      });
    
      it('treats a truncated name as stale when the prompt has grown', () => {
        const prompt = `Refactor the planner ${'x'.repeat(200)}`;
        const result = getDraftDisplayName({ name: 'Refactor the planner...', initial_prompt: prompt });
        expect(result).not.toBe('Refactor the planner...');
        expect(result.startsWith('Refactor the planner')).toBe(true);
      });
    
      it('falls back to the prompt and then to the fallback text', () => {
        expect(getDraftDisplayName({ name: '', initial_prompt: 'Fix login bug' })).toBe('Fix login bug');
        expect(getDraftDisplayName({ name: null, initial_prompt: null })).toBe('Untitled Plan');
        expect(getDraftDisplayName(null, 'Planner Studio')).toBe('Planner Studio');
      });
    });
    
    describe('isStalePromptDerivedName', () => {
      it('is false for names that are not prefixes of the prompt', () => {
        expect(isStalePromptDerivedName('Summary title', 'Add a thing', 'Add a thing')).toBe(false);
      });
    });

    File: propr-ui/src/components/TaskPlanner/setupWizardHooks.ts

    Why this file: usePromptPersistence is the only place that knows when the corrected name reached the server. Exposing a callback lets the page update its title without refetching. The callback is kept in a ref so passing a new inline function on each render does not change enqueuePromptSave's identity. That would re-run the debounce effect and cancel pending saves.

    --- a/propr-ui/src/components/TaskPlanner/setupWizardHooks.ts
    +++ b/propr-ui/src/components/TaskPlanner/setupWizardHooks.ts
    @@ -372,18 +372,34 @@
    +/**
    + * Emitted after a prompt save succeeds. `name` is exactly what was persisted,
    + * so the UI can show the corrected plan title without a refetch.
    + */
    +export interface PromptPersistedUpdate {
    +  draftId: string;
    +  initial_prompt: string;
    +  name: string;
    +}
    +
     export function usePromptPersistence(
       draftId: string | undefined,
       prompt: string,
       initialPrompt: string | undefined,
       persistOnInitialDraft = false,
    +  onPersisted?: (update: PromptPersistedUpdate) => void,
     ) {
       const trimmedPrompt = prompt.trim();
       const { debounceTimerRef, isMountedRef, lastSavedValueRef, previousDraftIdRef } = useDebouncedDraftPersistence((initialPrompt || '').trim(), draftId);
       const saveQueueRef = useRef<Promise<void>>(Promise.resolve());
    +  // Read the latest callback through a ref: callers usually pass an inline
    +  // function, and adding it to useCallback deps would recreate
    +  // enqueuePromptSave on every render, re-running the debounce effect below
    +  // and cancelling in-flight debounced saves.
    +  const onPersistedRef = useRef(onPersisted);
    +  onPersistedRef.current = onPersisted;
       const enqueuePromptSave = useCallback((targetDraftId: string, value: string) => {
         const save = saveQueueRef.current.then(async () => {
    -      await updateDraft(targetDraftId, { initial_prompt: value, name: truncateToSentences(value) });
    +      const name = truncateToSentences(value);
    +      await updateDraft(targetDraftId, { initial_prompt: value, name });
           lastSavedValueRef.current = value;
    +      // Notify only after the server accepted the name, so the UI never shows
    +      // a title that would be lost on reload.
    +      onPersistedRef.current?.({ draftId: targetDraftId, initial_prompt: value, name });
         });
         saveQueueRef.current = save.catch(() => undefined);
         return save;
       }, [lastSavedValueRef]);

    File: propr-ui/src/components/TaskPlanner/SetupWizard.tsx

    Why this file: SetupWizard owns the usePromptPersistence call (through useSetupWizardLoaders) and is rendered by PlanStudioPage for both new and existing drafts. It forwards the callback upward and has no title logic of its own.

    --- a/propr-ui/src/components/TaskPlanner/SetupWizard.tsx
    +++ b/propr-ui/src/components/TaskPlanner/SetupWizard.tsx
    @@ -40,7 +40,8 @@
       useDraftContextConfigSync,
       usePreviewTrace,
    -  useSetupWizardEffects
    +  useSetupWizardEffects,
    +  type PromptPersistedUpdate
     } from './setupWizardHooks';
    @@ -48,9 +49,12 @@
     interface SetupWizardProps {
       draft?: PlannerDraft;
       onGenerateComplete: () => void;
       onDraftCreated?: (draftId: string) => void;
       onDraftCreatedInPlace?: (draft: PlannerDraft) => void;
       onGenerationStarted?: (runId: string) => void;
    +  // Fired after each successful prompt save so the page can refresh the plan
    +  // title immediately (the draft object held by the page is otherwise stale).
    +  onDraftMetadataPersisted?: (update: PromptPersistedUpdate) => void;
     }
    @@ -280,7 +284,11 @@
    -function useSetupWizardLoaders({ isNewMode, draft, locationState, savedSettings, config, setConfig }: SetupWizardLoadersParams, persistPromptOnInitialDraft: boolean) {
    +function useSetupWizardLoaders(
    +  { isNewMode, draft, locationState, savedSettings, config, setConfig }: SetupWizardLoadersParams,
    +  persistPromptOnInitialDraft: boolean,
    +  onPromptPersisted?: (update: PromptPersistedUpdate) => void,
    +) {
    @@ -297,5 +305,5 @@
    -  const { flushPrompt } = usePromptPersistence(draft?.draft_id, config.prompt, draft?.initial_prompt, persistPromptOnInitialDraft);
    +  const { flushPrompt } = usePromptPersistence(draft?.draft_id, config.prompt, draft?.initial_prompt, persistPromptOnInitialDraft, onPromptPersisted);
       useDraftSettingsPersistence(draft?.draft_id, config, draft);
    @@ -331,5 +339,5 @@
    -export const SetupWizard: React.FC<SetupWizardProps> = ({ draft, onGenerateComplete, onDraftCreated, onDraftCreatedInPlace, onGenerationStarted }) => {
    +export const SetupWizard: React.FC<SetupWizardProps> = ({ draft, onGenerateComplete, onDraftCreated, onDraftCreatedInPlace, onGenerationStarted, onDraftMetadataPersisted }) => {
    @@ -349,5 +357,5 @@
         config,
         setConfig
    -  }, Boolean(onDraftCreatedInPlace));
    +  }, Boolean(onDraftCreatedInPlace), onDraftMetadataPersisted);

    File: propr-ui/src/pages/PlanStudioPage.tsx

    Why this file: This page produces the tab title and holds the stale inPlaceDraft snapshot. It receives the persisted metadata and applies it only to the title. It must never apply it to the draft prop passed to SetupWizard, because that would reset the prompt debounce. It also prefers the refetched draft, so a server-side LLM title wins over the creation snapshot.

    --- a/propr-ui/src/pages/PlanStudioPage.tsx
    +++ b/propr-ui/src/pages/PlanStudioPage.tsx
    @@ -10,6 +10,8 @@
     import StudioStepper, { StudioStage } from '../components/TaskPlanner/StudioStepper';
     import { PlannerDraft, DraftWithPlan } from '../api/plannerApi';
    +import { getDraftDisplayName } from '../components/TaskPlanner/planDisplayName';
    +import type { PromptPersistedUpdate } from '../components/TaskPlanner/setupWizardHooks';
     import {
    @@ -52,8 +54,9 @@
     const getTaskTitle = (draft: PlannerDraft): string => {
       // eslint-disable-next-line @typescript-eslint/no-explicit-any
       const draftAny = draft as any;
    -  return draftAny?.task_title || draftAny?.title || 'Untitled Task';
    +  // Shared helper so the generating view never shows a first-word title.
    +  return draftAny?.task_title || getDraftDisplayName(draft, draftAny?.title || 'Untitled Task');
     };
    @@ -187,11 +190,12 @@
    -const DraftView: React.FC<{ currentStage: StudioStage; draft: PlannerDraft; onRefetch: () => void; onGenerationStarted: (runId: string) => void }> = ({ currentStage, draft, onRefetch, onGenerationStarted }) => (
    +const DraftView: React.FC<{ currentStage: StudioStage; draft: PlannerDraft; onRefetch: () => void; onGenerationStarted: (runId: string) => void; onDraftMetadataPersisted?: (update: PromptPersistedUpdate) => void }> = ({ currentStage, draft, onRefetch, onGenerationStarted, onDraftMetadataPersisted }) => (
    @@ -200,6 +204,7 @@
           <SetupWizard
             draft={draft}
             onGenerateComplete={onRefetch}
             onGenerationStarted={onGenerationStarted}
    +        onDraftMetadataPersisted={onDraftMetadataPersisted}
           />
    @@ -210,8 +215,11 @@
     const getDocumentTitle = (draft: PlannerDraft | null): string => {
       // eslint-disable-next-line @typescript-eslint/no-explicit-any
       const draftAny = draft as any;
    -  return draftAny?.name || draftAny?.task_title || draft?.repository || 'Planner Studio';
    +  // getDraftDisplayName replaces a first-word name with the current prompt's
    +  // title but keeps LLM/user titles untouched.
    +  return getDraftDisplayName(draft, '') || draftAny?.task_title || draft?.repository || 'Planner Studio';
     };
    @@ -236,11 +244,12 @@
     const NewDraftView: React.FC<{
       singleTask?: boolean;
       draft?: PlannerDraft;
       onDraftCreated?: (draft: PlannerDraft) => void;
       onRefetch?: () => void;
       onGenerationStarted?: (runId: string) => void;
    -}> = ({ draft, onDraftCreated, onRefetch, onGenerationStarted, singleTask }) => (
    +  onDraftMetadataPersisted?: (update: PromptPersistedUpdate) => void;
    +}> = ({ draft, onDraftCreated, onRefetch, onGenerationStarted, singleTask, onDraftMetadataPersisted }) => (
    @@ -254,6 +263,7 @@
             onGenerateComplete={onRefetch || (() => {})}
             onDraftCreatedInPlace={onDraftCreated}
             onGenerationStarted={onGenerationStarted}
    +        onDraftMetadataPersisted={onDraftMetadataPersisted}
           />
    @@ -265,6 +275,7 @@
     interface DraftViewOptions extends IntentAwareViewProps {
       draft: PlannerDraft;
       currentStage: StudioStage;
       refetch: () => void;
       onGenerationStarted: (runId: string) => void;
    +  onDraftMetadataPersisted?: (update: PromptPersistedUpdate) => void;
     }
    @@ -272,6 +283,7 @@
       refetch,
       onGenerationStarted,
    +  onDraftMetadataPersisted,
       notificationIntent,
       onNotificationIntentConsumed,
     }: DraftViewOptions): React.ReactElement => {
    @@ -310,5 +322,5 @@
    -  return <DraftView currentStage={currentStage} draft={draft} onRefetch={refetch} onGenerationStarted={onGenerationStarted} />;
    +  return <DraftView currentStage={currentStage} draft={draft} onRefetch={refetch} onGenerationStarted={onGenerationStarted} onDraftMetadataPersisted={onDraftMetadataPersisted} />;
     };
    @@ -360,10 +372,40 @@
       // For /studio/new: track draft created in-place (without navigation)
       const [inPlaceDraft, setInPlaceDraft] = useState<PlannerDraft | null>(null);
    +  // Latest prompt/name the server accepted during setup. Used ONLY for the
    +  // title: feeding it back into SetupWizard's draft prop would change
    +  // draft.initial_prompt, which resets useDebouncedDraftPersistence and
    +  // cancels the user's pending debounced save.
    +  const [metadataOverride, setMetadataOverride] = useState<PromptPersistedUpdate | null>(null);
     
       useEffect(() => {
         setInPlaceDraft(null);
    +    setMetadataOverride(null);
       }, [location.key]);
    +
    +  const handleDraftMetadataPersisted = useCallback((update: PromptPersistedUpdate) => {
    +    setMetadataOverride(update);
    +  }, []);
    @@ -390,12 +432,24 @@
       // The actual draft to use - prefer the in-place draft when available
       const activeDraft = inPlaceDraft || draft;
     
    -  useDocumentTitle(isNew && !inPlaceDraft ? getNewDraftTitle(location.search) : getDocumentTitle(activeDraft));
    +  // For the title, prefer the refetched draft over the one-time creation
    +  // snapshot so a server-side (LLM) title shows as soon as it is fetched.
    +  // While still in setup, overlay the last persisted prompt/name so the title
    +  // tracks typing without a refetch. Outside setup the server is
    +  // authoritative (e.g. an LLM title written on finalize) and the local
    +  // override must not mask it.
    +  const titleSource = draft || inPlaceDraft;
    +  const titleDraft = titleSource
    +    && metadataOverride?.draftId === titleSource.draft_id
    +    && isDraftStatus(titleSource.status)
    +    ? { ...titleSource, name: metadataOverride.name, initial_prompt: metadataOverride.initial_prompt }
    +    : titleSource;
    +
    +  useDocumentTitle(isNew && !inPlaceDraft ? getNewDraftTitle(location.search) : getDocumentTitle(titleDraft));
    @@ -410,6 +464,7 @@
             onDraftCreated={handleDraftCreatedInPlace}
             onRefetch={refetch}
             onGenerationStarted={activateGenerationRun}
    +        onDraftMetadataPersisted={handleDraftMetadataPersisted}
           />
    @@ -429,6 +484,7 @@
         refetch,
         onGenerationStarted: activateGenerationRun,
    +    onDraftMetadataPersisted: handleDraftMetadataPersisted,
         notificationIntent: activeNotificationIntent,

    Note: activeDraft stays as it is because other code in the component may read it. Only the title now uses titleDraft. The draft prop given to SetupWizard (inPlaceDraft / draft) is left unchanged on purpose, for the reason explained in the comment.

    File: propr-ui/src/components/TaskPlanner/PlanEditor.tsx

    Why this file: The review-stage header shows planName. Using the shared helper keeps it consistent with the tab title.

    --- a/propr-ui/src/components/TaskPlanner/PlanEditor.tsx
    +++ b/propr-ui/src/components/TaskPlanner/PlanEditor.tsx
    @@ -12,6 +12,7 @@
     import PlanIntentConfirmationDialog from './PlanIntentConfirmationDialog';
    +import { getDraftDisplayName } from './planDisplayName';
    @@ -38,5 +39,6 @@
    -const getPlanName = (draft: DraftWithPlan) => draft.name || draft.initial_prompt || 'Untitled Plan';
    +// Single display rule: stale first-word names are replaced, LLM titles kept.
    +const getPlanName = (draft: DraftWithPlan) => getDraftDisplayName(draft);

    File: propr-ui/src/components/TaskPlanner/ApprovedPlanView.tsx

    Why this file: The execution-stage header. After finalization it should show the LLM title, or a correct prompt-derived fallback.

    --- a/propr-ui/src/components/TaskPlanner/ApprovedPlanView.tsx
    +++ b/propr-ui/src/components/TaskPlanner/ApprovedPlanView.tsx
    @@ -12,6 +12,7 @@
     import type { PlanNotificationIntent } from '../../utils/notificationIntents';
    +import { getDraftDisplayName } from './planDisplayName';
    @@ -283,5 +284,6 @@
    -  const planName = draft.name || draft.initial_prompt || 'Untitled Plan';
    +  // Same display rule as the studio/editor so titles never disagree.
    +  const planName = getDraftDisplayName(draft);

    File: propr-ui/src/pages/PlansPageComponents.tsx

    Why this file: The Plans list re-fetches on status changes. It should still never render a stale one-word name when initial_prompt already holds the full text.

    --- a/propr-ui/src/pages/PlansPageComponents.tsx
    +++ b/propr-ui/src/pages/PlansPageComponents.tsx
    @@ -8,6 +8,7 @@
       formatRelativeTime
     } from './PlansPageUtils';
    +import { getDraftDisplayName } from '../components/TaskPlanner/planDisplayName';
    @@ -117,7 +118,8 @@
               <div className="mb-1">
                 <span className="text-sm font-medium text-gray-900 break-words">
    -              {draft.name || draft.initial_prompt}
    +              {/* Replaces names frozen from a partial prompt at auto-save time. */}
    +              {getDraftDisplayName(draft)}
                 </span>
               </div>

    File: propr-ui/src/components/TaskPlanner/setupWizardHooks.persistence.test.tsx

    Why this file: Proves the new callback fires with the persisted name. This covers the exact in-place flow: the draft is created from Add, then the prompt grows.

    --- a/propr-ui/src/components/TaskPlanner/setupWizardHooks.persistence.test.tsx
    +++ b/propr-ui/src/components/TaskPlanner/setupWizardHooks.persistence.test.tsx
    @@ -86,6 +86,32 @@
    +  it('reports the persisted prompt and derived name so the UI can refresh the plan title', async () => {
    +    vi.useFakeTimers();
    +    try {
    +      type HookProps = { draftId: string | undefined; prompt: string };
    +      const onPersisted = vi.fn();
    +      const { rerender } = renderHook(
    +        ({ draftId, prompt }: HookProps) =>
    +          usePromptPersistence(draftId, prompt, 'Add', true, onPersisted),
    +        { initialProps: { draftId: undefined, prompt: 'Add' } as HookProps }
    +      );
    +
    +      // Draft was auto-created from the first word; the user kept typing.
    +      rerender({ draftId: 'draft-9', prompt: 'Add dark mode toggle to settings.' });
    +      await vi.advanceTimersByTimeAsync(1_100);
    +
    +      expect(onPersisted).toHaveBeenCalledWith({
    +        draftId: 'draft-9',
    +        initial_prompt: 'Add dark mode toggle to settings.',
    +        name: 'Add dark mode toggle to settings.',
    +      });
    +    } finally {
    +      vi.useRealTimers();
    +    }
    +  });
    +
       it('waits for an in-flight autosave and cancels the queued debounce before saving the final prompt', async () => {

    Verification Steps

    1. Run npm run typecheck -w propr-ui, npm run lint -w propr-ui -- --max-warnings 0 and npm test -w propr-ui.
    2. Manually:
      • Open /studio/new, type Add, and pause 2 s.
      • Type the rest of the sentence and pause 1 s.
      • The tab title updates to the full title and the Plans list shows the full title.
      • Generate the plan, then finalize it. If the server writes an LLM title, it replaces the prompt-derived title everywhere after the refetch.
  2. propr-dev commented on Sep 23, 2026

    @propr-dev
    ContributorAuthor

    🤖 AI processing has started for this issue using claude agent with claude-opus-5 model.

    I'll analyze the problem and work on a solution. This may take a few minutes.

    Processing Details:

    • Agent: claude
    • Model: claude-opus-5
    • Branch: 2476/claude-opus-5-keep-a-new-plan-s-title-i-20260923-1155-xku
    • Base Branch: main
    • Worktree: issue-2476-20260923-1155-claude-opus-5-xku

    🔍 Track Task Execution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions