Skip to content

feat(sessions): show sub-task indicator for agent-delegated sessions#685

Open
helloworld89 wants to merge 1 commit into
fathah:mainfrom
helloworld89:feat/session-subtask-badge
Open

feat(sessions): show sub-task indicator for agent-delegated sessions#685
helloworld89 wants to merge 1 commit into
fathah:mainfrom
helloworld89:feat/session-subtask-badge

Conversation

@helloworld89

Copy link
Copy Markdown

Summary

Adds a visual indicator on the Sessions page to distinguish sessions created by agent delegation (sub-tasks) from manually created sessions.

Changes

  • session-cache.ts: Added parent_session_id to the SQL query and parentId to the CachedSession interface
  • sessions.ts: Added parentId to SearchResult and all session search queries
  • Sessions.tsx: Display an orange sub-task tag next to session cards when session.parentId is set
  • remote-sessions.ts / ssh-remote.ts / preload: Updated all session list/search return types with parentId for compatibility

Screenshots

(Add screenshots after visual verification)

Testing

  • TypeScript typecheck passes (npm run typecheck)
  • Visual verification: run npm run dev and check Sessions page shows orange sub-task badge for delegated sessions

- Add parent_session_id to session-cache SQL query and CachedSession type
- Add parentId to SearchResult interface and all search queries
- Display orange 'sub-task' tag in Sessions list when session.parentId exists
- Update remote-sessions.ts, ssh-remote.ts, and preload types for compatibility
@greptile-apps

greptile-apps Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR propagates a parentId field (mapped from parent_session_id) through every layer of the session data pipeline — SQLite queries, cache sync, search, SSH/remote stubs, preload types, and the renderer — to surface an "Agent sub-task" badge on session cards.

  • Data layer (session-cache.ts, sessions.ts): parent_session_id is added to all relevant SQL queries and correctly mapped to parentId through the incremental sync, title/FTS/message-content search paths, and deduplication logic.
  • Remote stubs (remote-sessions.ts, ssh-remote.ts): Hardcode parentId: null since remote session sources don't expose parent relationships — correct placeholder.
  • UI (Sessions.tsx): Renders a sessions-tag--child badge when session.parentId is truthy, but the CSS modifier for that class is never defined, so the badge appears with no visual differentiation from other tags.

Confidence Score: 3/5

The data-pipeline changes are solid, but the UI feature this PR introduces — an orange visual badge for agent sub-tasks — will render as an invisible/unstyled tag because the CSS rule for the new modifier class was never added.

The entire user-visible goal of this PR is the styled sub-task badge, and that badge will appear with no distinguishing colour or weight because .sessions-tag--child has no CSS definition. The feature ships broken visually even though all the plumbing behind it is correct.

src/renderer/src/screens/Sessions/Sessions.tsx and src/renderer/src/assets/main.css — the badge class is used in JSX but the companion CSS rule is absent entirely.

Important Files Changed

Filename Overview
src/renderer/src/screens/Sessions/Sessions.tsx Adds parentId to both local interfaces and renders a sessions-tag--child badge, but the corresponding CSS modifier is never defined, so the badge appears unstyled.
src/main/session-cache.ts Adds parent_session_id to the incremental sync query and maps it to parentId; stale-count refresh path does not propagate parentId changes to already-cached sessions.
src/main/sessions.ts Correctly adds parent_session_id to all three search query branches (title/FTS/message-content) and maps it to parentId in the final SearchResult; deduplication preserves the field via generics.
src/main/remote-sessions.ts Adds parentId: null to all three return sites; remote sessions do not surface parent relationships, so the constant null is intentional.
src/main/ssh-remote.ts Adds parentId: null to the SSH session list mapper — correct placeholder for remote sessions.
src/preload/index.d.ts Adds `parentId: string
src/preload/index.ts Runtime preload type annotations updated to include parentId; no logic changes, just type alignment.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    DB[(SQLite\nparent_session_id)]

    subgraph main["Main Process"]
        SC["session-cache.ts\nsyncSessionCache()\nlistCachedSessions()"]
        SS["sessions.ts\nsearchSessions()"]
        RS["remote-sessions.ts\nnormalizeCachedSession()\nremoteSearchSessions()"]
        SSH["ssh-remote.ts\nsshListCachedSessions()"]
    end

    subgraph preload["Preload"]
        PI["index.ts / index.d.ts\nIPC bridge types"]
    end

    subgraph renderer["Renderer"]
        SX["Sessions.tsx\nSessionCard"]
        BADGE["span.sessions-tag--child\n'sub-task' badge"]
        CSS["main.css\n⚠️ .sessions-tag--child\nnot defined"]
    end

    DB -->|"SELECT parent_session_id"| SC
    DB -->|"SELECT parent_session_id"| SS
    RS -->|"parentId: null"| PI
    SSH -->|"parentId: null"| PI
    SC -->|"parentId: string|null"| PI
    SS -->|"parentId: string|null"| PI
    PI -->|IPC| SX
    SX -->|"session.parentId truthy"| BADGE
    BADGE -.->|"no rule"| CSS

    style CSS fill:#ffcccc,stroke:#cc0000
    style BADGE fill:#fff3cd,stroke:#ffc107
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
    DB[(SQLite\nparent_session_id)]

    subgraph main["Main Process"]
        SC["session-cache.ts\nsyncSessionCache()\nlistCachedSessions()"]
        SS["sessions.ts\nsearchSessions()"]
        RS["remote-sessions.ts\nnormalizeCachedSession()\nremoteSearchSessions()"]
        SSH["ssh-remote.ts\nsshListCachedSessions()"]
    end

    subgraph preload["Preload"]
        PI["index.ts / index.d.ts\nIPC bridge types"]
    end

    subgraph renderer["Renderer"]
        SX["Sessions.tsx\nSessionCard"]
        BADGE["span.sessions-tag--child\n'sub-task' badge"]
        CSS["main.css\n⚠️ .sessions-tag--child\nnot defined"]
    end

    DB -->|"SELECT parent_session_id"| SC
    DB -->|"SELECT parent_session_id"| SS
    RS -->|"parentId: null"| PI
    SSH -->|"parentId: null"| PI
    SC -->|"parentId: string|null"| PI
    SS -->|"parentId: string|null"| PI
    PI -->|IPC| SX
    SX -->|"session.parentId truthy"| BADGE
    BADGE -.->|"no rule"| CSS

    style CSS fill:#ffcccc,stroke:#cc0000
    style BADGE fill:#fff3cd,stroke:#ffc107
Loading

Comments Outside Diff (1)

  1. src/main/session-cache.ts, line 190-208 (link)

    P2 Stale-count refresh path skips parentId update

    The periodic stale-count refresh query (SELECT id, message_count FROM sessions WHERE id IN (...)) only updates messageCount on existing cache entries. If a session's parent_session_id column were ever set or changed after it was first cached (e.g., a retroactive assignment), its parentId in the cache would remain stale indefinitely. The parentId field is also never backfilled for sessions already present in the on-disk cache from before this update. Adding parent_session_id to the stale-refresh SELECT and applying it alongside messageCount would keep the data consistent.

Reviews (1): Last reviewed commit: "feat(sessions): show sub-task badge for ..." | Re-trigger Greptile

Comment on lines +239 to +241
<span className="sessions-tag sessions-tag--child" title="Agent sub-task">
sub-task
</span>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Missing CSS modifier — badge will be unstyled

The class sessions-tag--child is applied to the sub-task badge, but no corresponding CSS rule exists in src/renderer/src/assets/main.css (only sessions-tag--source and sessions-tag--model are defined there). The PR description promises an "orange" badge, but at runtime the span will fall back entirely to the base .sessions-tag styles, rendering identically to any other tag with no visual differentiation. A rule like .sessions-tag--child { color: orange; font-weight: 500; } (or a CSS variable equivalent) needs to be added to main.css.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

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