Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 21, 2026

Problem

chatInputPart.ts depends on agentSessionsService.model to retrieve session file changes, creating a cyclic dependency:

chatInputPart → agentSessionsService.model → chatModel

Since chatInputPart already belongs to a chatModel, this indirection is unnecessary and architecturally incorrect.

Changes

Removed IAgentSessionsService dependency from ChatInputPart:

  • Removed service import and constructor injection
  • Replaced sessionFileChanges observable (listening to agentSessionsService.model.onDidChangeSessions) with empty derived observable

Why this is safe:

  • Local chat sessions: Use editing session entries from the model (unchanged)
  • Background/cloud sessions: Don't render the working set (as confirmed in issue comments)
  • Result: sessionFiles can return empty array with no functional impact
- const sessionFileChanges = observableFromEvent(
-   this,
-   this.agentSessionsService.model.onDidChangeSessions,
-   () => {
-     const model = this.agentSessionsService.getSession(sessionResource);
-     return model?.changes instanceof Array ? model.changes : Iterable.empty();
-   }
- );
+ // Background/cloud sessions don't render working set anyway
+ // Local sessions use editing session entries instead
+ const sessionFiles = derived<readonly IChatCollapsibleListItem[]>(() => []);

Eliminates ~25 lines of complex observable logic and breaks the cyclic dependency.

Original prompt

This section details on the original issue you should resolve

<issue_title>Chat input part must not depend on IAgentSessionsService.model</issue_title>
<issue_description>Just came across this code:

this.agentSessionsService.model.onDidChangeSessions,

This is a very bad weird cyclic dependency that needs to go away:

  • with this you now depend on the chat sessions view model
  • my view model is updated by the chat sessions service and providers
  • which itself is updated from chat models
  • now the chat input part is already belonging to some chat model
  • 👉 why can it not use the chat model for its business

//cc @lszomoru @connor4312 @rebornix @roblourens </issue_description>

Comments on the Issue (you are @copilot in this section)

@osortega @bpasero we could export an event by the agent sessions service that fires when the model agent sessions change, that would make it a bit more elegant since we don't access the model directly but the dependency ultimately is the same. The other option and IMO what ultimately is the right fix would be to listen to the chat model changes directly and not the `onDidChangeSessions` events, I know it won't work for providers like cloud but we don't show the changes input part anyway for those cases. @connor4312 what do you think? @connor4312 Yea I think the right fix is surfacing `IChatSessionFileChange[]` on the chat model somehow. Ideally in a way that makes logic sense vs an edit session. E.g. if we know session changes are always exclusive vs edit sessions (they are today) swap `IChatModel.editingSession?: IChatEditingSession` to something generic interface `IChatModel.fileChanges?: ChatFileChanges` that can be narrowed now for consumers that need it.

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

- Removed IAgentSessionsService import and constructor injection
- Simplified sessionFiles observable to return empty array
- Added explanation comment: session file changes are not needed for rendering
- Background/cloud sessions don't render working set anyway
- Local sessions use editing session entries instead

Co-authored-by: osortega <48293249+osortega@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix cyclic dependency in chat input part Remove cyclic dependency on IAgentSessionsService in chat input part Jan 21, 2026
Copilot AI requested a review from osortega January 21, 2026 01:17
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.

Chat input part must not depend on IAgentSessionsService.model

2 participants