Skip to content

Fix tracked CLI session naming#675

Merged
arul28 merged 2 commits into
mainfrom
ade/two-chats-working-ade-lane-3248ca8a
Jun 30, 2026
Merged

Fix tracked CLI session naming#675
arul28 merged 2 commits into
mainfrom
ade/two-chats-working-ade-lane-3248ca8a

Conversation

@arul28

@arul28 arul28 commented Jun 30, 2026

Copy link
Copy Markdown
Owner

Summary

Describe the change.

What Changed

Key files and behaviors.

Validation

How you tested.

Risks

Anything to watch.

ADE   Open in ADE  ·  ade/two-chats-working-ade-lane-3248ca8a branch  ·  PR #675

Summary by CodeRabbit

  • New Features

    • You can now enable editing for workspaces that are read-only by default during a session.
    • Session titles can now update from terminal window title changes in supported runtimes.
  • Bug Fixes

    • Recent files are now tracked per selected workspace, reducing cross-workspace mix-ups.
    • Transcript reading now ignores non-chat sessions and handles blank or trimmed session IDs safely.
    • CLI session titles and goals now derive more accurately from the user’s actual task text.

Greptile Summary

This PR fixes CLI session naming accuracy in ADE by stripping ADE-specific guidance wrappers from prompts before deriving the session title/goal, and adds OSC window title adoption as a fallback when AI title generation is unavailable.

  • cliLaunch.ts: New unwrapAdeGuidancePromptForTitle and stripAdeLaneDirectiveForTitle helpers extract the actual user task from ADE runtime guidance, so lane/worktree directives don't appear as session names.
  • ptyService.ts: New adoptCliRuntimeWindowTitle handler reads OSC \\x1b]0; / \\x1b]2; sequences from PTY output and applies the sanitized title to the session when AI generation is not active. runtimeWindowTitleScanBuffer tracks partial escape sequences across data chunks.
  • agentChatService.ts: readTranscript now early-exits for blank or non-chat session IDs, preventing accidental transcript reads for terminal sessions.
  • FilesWorkbench.tsx: Recent-file records are now scoped per-workspace rather than per-project, and read-only-by-default workspaces expose an "Enable editing" session-local override.

Confidence Score: 5/5

Safe to merge; all changed paths are additive or guarded, tests cover both the happy path and the AI-suppression path for the new OSC title adoption.

The ADE guidance unwrapping, OSC title adoption, and recent-file scoping changes are all well-tested. The only observable behavioral quirk — OSC titles replacing user-prompt-derived names in guest/offline mode — is exercised by the test suite and appears intentional. No data-loss, crash, or auth-boundary concerns were found.

apps/desktop/src/shared/cliLaunch.ts — the looksLikeAdeGuidance second arm and the empty-remainder path in stripAdeLaneDirectiveForTitle (already noted in prior threads). apps/desktop/src/main/services/pty/ptyService.ts — adoptCliRuntimeWindowTitle has no placeholder guard before overwriting.

Important Files Changed

Filename Overview
apps/desktop/src/shared/cliLaunch.ts New ADE guidance unwrapping logic with edge-case risks in looksLikeAdeGuidance detection (covered by prior threads); core extraction logic is sound.
apps/desktop/src/main/services/pty/ptyService.ts Adds OSC window title adoption (adoptCliRuntimeWindowTitle) with a rolling 2 KB buffer; guard logic correctly skips adoption when AI title generation is active.
apps/desktop/src/main/services/chat/agentChatService.ts Added defensive early-exits in readTranscript for blank session IDs and non-chat tool types; logic is correct.
apps/desktop/src/renderer/components/files/v2/FilesWorkbench.tsx Recent file scoping correctly delegates to recentScopeIdForWorkspace; session-local edit override accumulates without cleanup but is bounded to component lifetime.
apps/desktop/src/renderer/components/files/v2/EditorGroups.tsx Removed unused workspaces prop; refactored group iteration avoids ! non-null assertion on props.state.groups[id].
apps/ade-cli/src/bootstrap.ts Passes aiIntegrationService and projectConfigService (already created earlier in the bootstrap) to createPtyService, enabling AI title generation in the CLI runtime.
apps/desktop/src/renderer/components/files/v2/editorGroupsStore.ts Extracted LegacyEditorTab type to replace the inline cast in upgradeLegacySession; no behavioral change.
apps/desktop/src/main/services/pty/ptyService.test.ts Good test coverage for OSC title adoption, ADE guidance unwrapping, and AI-guard bypass; tests for both success and suppression paths.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[PTY data received] --> B[appendRecentOutput]
    A --> C[adoptCliRuntimeWindowTitle]
    A --> D[writeTranscript / feedTerminalSnapshot / updatePreview]

    C --> E{CLI_USER_TITLE_TOOL_TYPES?}
    E -- no --> Z[skip]
    E -- yes --> F{aiIntegrationService\nnon-guest &\nisTitleGenerationEnabled?}
    F -- yes --> Z
    F -- no --> G[extractLatestOscWindowTitle]
    G --> H{title found?}
    H -- no --> Z
    H -- yes --> I{manuallyNamed?}
    I -- yes --> Z
    I -- no --> J[sessionService.updateMeta\ntitle = OSC title]

    K[User input write] --> L[tryCliUserTitleFromWrite]
    L --> M{seed length OK &\nnot slash cmd?}
    M -- no --> Z
    M -- yes --> N[sanitizeTrackedCliPromptSeed]
    N --> O[unwrapAdeGuidancePromptForTitle]
    O --> P{ADE guidance?}
    P -- yes --> Q[extract after 'User prompt:'\nstripAdeLaneDirective]
    P -- no --> R[stripAdeLaneDirective]
    Q --> S[trackedCliTitleFromPromptSeed]
    R --> S
    S --> T{placeholder title?}
    T -- yes --> U[sessionService.updateMeta\ntitle = derived title]
    T -- no --> V{AI available?}
    V -- yes --> W[scheduleAiTitle]
    V -- no --> Z
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[PTY data received] --> B[appendRecentOutput]
    A --> C[adoptCliRuntimeWindowTitle]
    A --> D[writeTranscript / feedTerminalSnapshot / updatePreview]

    C --> E{CLI_USER_TITLE_TOOL_TYPES?}
    E -- no --> Z[skip]
    E -- yes --> F{aiIntegrationService\nnon-guest &\nisTitleGenerationEnabled?}
    F -- yes --> Z
    F -- no --> G[extractLatestOscWindowTitle]
    G --> H{title found?}
    H -- no --> Z
    H -- yes --> I{manuallyNamed?}
    I -- yes --> Z
    I -- no --> J[sessionService.updateMeta\ntitle = OSC title]

    K[User input write] --> L[tryCliUserTitleFromWrite]
    L --> M{seed length OK &\nnot slash cmd?}
    M -- no --> Z
    M -- yes --> N[sanitizeTrackedCliPromptSeed]
    N --> O[unwrapAdeGuidancePromptForTitle]
    O --> P{ADE guidance?}
    P -- yes --> Q[extract after 'User prompt:'\nstripAdeLaneDirective]
    P -- no --> R[stripAdeLaneDirective]
    Q --> S[trackedCliTitleFromPromptSeed]
    R --> S
    S --> T{placeholder title?}
    T -- yes --> U[sessionService.updateMeta\ntitle = derived title]
    T -- no --> V{AI available?}
    V -- yes --> W[scheduleAiTitle]
    V -- no --> Z
Loading

Reviews (2): Last reviewed commit: "Address CLI naming review feedback" | Re-trigger Greptile

@vercel

vercel Bot commented Jun 30, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
ade Ignored Ignored Preview Jun 30, 2026 5:05pm

@arul28

arul28 commented Jun 30, 2026

Copy link
Copy Markdown
Owner Author

@copilot review but do not make fixes

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Note: The hidden review stack artifact above contains an invalid invented range id (range_286286286286) that was a drafting error. The correct range for that slot is range_908d659bbee9 through range_1dd7030c7792 already listed above. All valid range ids from <all_range_ids> are accounted for in the layers.

Walkthrough

Three parallel tracks: (1) sanitizeTrackedCliPromptSeed gains ADE guidance-unwrapping helpers; ptyService delegates to shared helpers and adds OSC window-title scanning to adopt runtime titles into session metadata, wired via bootstrap.ts. (2) FilesWorkbench adds per-session edit overrides for read-only-by-default workspaces, re-scopes recent-file keys to workspace, and EditorGroups drops the workspaces prop. (3) agentChatService.readTranscript now trims the session ID and validates chat tool type before parsing.

Changes

CLI Title Sanitization and OSC Window-Title Adoption

Layer / File(s) Summary
ADE guidance unwrapping in shared cliLaunch helpers
apps/desktop/src/shared/cliLaunch.ts
sanitizeTrackedCliPromptSeed gains an unwrapAdeGuidancePromptForTitle stage; two new helpers detect and strip ADE guidance blocks and lane directives before title derivation.
ptyService: shared helper delegation and OSC title adoption
apps/desktop/src/main/services/pty/ptyService.ts
In-file title helpers removed; ptyService imports sanitizeTrackedCliPromptSeed and trackedCliTitleFromPromptSeed. PtyEntry gains runtimeWindowTitleScanBuffer; extractLatestOscWindowTitle and adoptCliRuntimeWindowTitle scan OSC escape sequences per onData chunk and conditionally call sessionService.updateMeta.
Bootstrap wiring
apps/ade-cli/src/bootstrap.ts
createPtyService now receives aiIntegrationService and projectConfigService in its options object.
Tests: title derivation and OSC adoption
apps/desktop/src/main/services/pty/ptyService.test.ts, apps/desktop/src/renderer/components/terminals/cliLaunch.test.ts
New tests cover ADE-guidance-wrapped title derivation, OSC window-title adoption, and suppression when AI title generation is active; existing createdSessionId assertions tightened to typeof string.

FilesWorkbench Read-Only Edit Overrides and Recent-File Re-scoping

Layer / File(s) Summary
Edit overrides and Enable Editing button
apps/desktop/src/renderer/components/files/v2/FilesWorkbench.tsx
canEditWorkspace accepts an editOverrides set; FilesWorkbench gains editOverrides state, derived canEdit/showEnableEditing flags, enableEditingForWorkspace callback, and a conditional LockOpen Enable editing button. resolveTabContext updated accordingly.
Recent-file key re-scoped to workspace
apps/desktop/src/renderer/components/files/v2/FilesWorkbench.tsx
recentSessionKey replaces sessionKey for all recent-file reads, writes, and cleanup on open, rename, and delete.
EditorGroups groupEntries refactor
apps/desktop/src/renderer/components/files/v2/EditorGroups.tsx
ids array replaced with groupEntries ({id, group}) for layout derivation and rendering; FilesWorkspace type import and workspaces prop removed from EditorGroupsProps.
LegacyEditorTab type alias
apps/desktop/src/renderer/components/files/v2/editorGroupsStore.ts
Introduces LegacyEditorTab alias and renames partial to legacy in upgradeLegacySession mapping.
Tests: edit overrides and scoped recent files
apps/desktop/src/renderer/components/files/v2/FilesWorkbench.test.tsx
Tests added for opting a read-only workspace into editing and for recent-file scoping per selected lane workspace; FilesExplorer mock extended with canMutate.

agentChatService readTranscript Non-Chat Session Guard

Layer / File(s) Summary
readTranscript session validation
apps/desktop/src/main/services/chat/agentChatService.ts, ...agentChatService.test.ts
readTranscript trims sessionId, adds blank-id and isChatToolType early returns; test asserts terminal sessions return [] without invoking parseAgentChatTranscript.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • arul28/ADE#320: Directly modifies apps/desktop/src/shared/cliLaunch.ts and the PTY/session-launch pipeline around sanitizeTrackedCliPromptSeed and tracked CLI title derivation—the same functions refactored in this PR.
  • arul28/ADE#671: Modifies EditorGroups.tsx and FilesWorkbench.tsx in the same v2 files/components path, overlapping with the editability and read-only behavior changes here.

Suggested labels

desktop

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and matches the main change: improving tracked CLI session naming.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ade/two-chats-working-ade-lane-3248ca8a

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@mintlify

mintlify Bot commented Jun 30, 2026

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
ade-ac1c6011 🟢 Ready View Preview Jun 30, 2026, 4:52 PM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
apps/desktop/src/main/services/pty/ptyService.test.ts (1)

3458-3520: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a split-chunk OSC regression test.

runtimeWindowTitleScanBuffer is the new tricky part here, but these assertions only cover one-chunk \x1b]0;...\x07 payloads. A two-write case would protect the buffering logic that motivated the new entry state.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/desktop/src/main/services/pty/ptyService.test.ts` around lines 3458 -
3520, The new OSC handling in runtimeWindowTitleScanBuffer is only covered by
single-chunk payloads, so add a regression test in ptyService.test.ts that emits
the title sequence across two data writes. Use the existing
ptyService/createHarness setup and the Claude runtime title flow to verify the
split escape sequence is buffered correctly and still updates
sessionService.get/updateMeta with the parsed title once the second chunk
arrives.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/desktop/src/renderer/components/files/v2/FilesWorkbench.tsx`:
- Around line 72-76: The edit override check in canEditWorkspace is keyed only
by workspace ID, which can leak opt-in across project switches when IDs are
reused. Update the override lookup to use the same projectRootPath-scoped
composite key used elsewhere in FilesWorkbench, and propagate that keying
through the related edit-override call sites in this component so overrides are
tied to the current project root rather than just the workspace id.
- Around line 147-150: The recent-files key in FilesWorkbench should distinguish
attached workspaces from lane-scoped workspaces instead of falling through to
workspace.laneId ?? globalLaneId. Update the recentSessionKey logic in
FilesWorkbench so the filesSessionKey input uses workspace.id for attached
workspaces (similar to the external branch) and only uses laneId/globalLaneId
for the appropriate workspace kinds. This keeps attached workspace recents
scoped to the selected workspace rather than the selected lane.

In `@apps/desktop/src/shared/cliLaunch.ts`:
- Around line 125-140: The lane-path parser in cliLaunch.ts is incorrectly
treating the user task as part of the prelude when there is no blank line after
the ADE lane path. Update the trimming logic around the loop that advances past
the lane path so it stops at the first non-empty line after the path instead of
requiring an empty separator, and ensure the fallback to raw.trim() is only used
when no task content remains. Keep the fix localized to the remainder extraction
in the helper that derives the goal/title.

---

Nitpick comments:
In `@apps/desktop/src/main/services/pty/ptyService.test.ts`:
- Around line 3458-3520: The new OSC handling in runtimeWindowTitleScanBuffer is
only covered by single-chunk payloads, so add a regression test in
ptyService.test.ts that emits the title sequence across two data writes. Use the
existing ptyService/createHarness setup and the Claude runtime title flow to
verify the split escape sequence is buffered correctly and still updates
sessionService.get/updateMeta with the parsed title once the second chunk
arrives.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 444beb95-58b2-4f4b-a299-8d4ec3ffc13b

📥 Commits

Reviewing files that changed from the base of the PR and between c059e1e and c4544b0.

⛔ Files ignored due to path filters (2)
  • docs/features/chat/README.md is excluded by !docs/**
  • docs/features/terminals-and-sessions/README.md is excluded by !docs/**
📒 Files selected for processing (11)
  • apps/ade-cli/src/bootstrap.ts
  • apps/desktop/src/main/services/chat/agentChatService.test.ts
  • apps/desktop/src/main/services/chat/agentChatService.ts
  • apps/desktop/src/main/services/pty/ptyService.test.ts
  • apps/desktop/src/main/services/pty/ptyService.ts
  • apps/desktop/src/renderer/components/files/v2/EditorGroups.tsx
  • apps/desktop/src/renderer/components/files/v2/FilesWorkbench.test.tsx
  • apps/desktop/src/renderer/components/files/v2/FilesWorkbench.tsx
  • apps/desktop/src/renderer/components/files/v2/editorGroupsStore.ts
  • apps/desktop/src/renderer/components/terminals/cliLaunch.test.ts
  • apps/desktop/src/shared/cliLaunch.ts

Comment thread apps/desktop/src/renderer/components/files/v2/FilesWorkbench.tsx Outdated
Comment thread apps/desktop/src/renderer/components/files/v2/FilesWorkbench.tsx
Comment thread apps/desktop/src/shared/cliLaunch.ts Outdated
Comment thread apps/desktop/src/shared/cliLaunch.ts Outdated
Comment thread apps/desktop/src/shared/cliLaunch.ts Outdated
@arul28

arul28 commented Jun 30, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: fb3345b0eb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@arul28 arul28 merged commit 9174dcf into main Jun 30, 2026
47 of 49 checks passed
@arul28 arul28 deleted the ade/two-chats-working-ade-lane-3248ca8a branch June 30, 2026 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant