Skip to content

Introduce hierarchical command/query context with status tracking#1792

Draft
Copilot wants to merge 8 commits intomainfrom
copilot/introduce-command-scope-context
Draft

Introduce hierarchical command/query context with status tracking#1792
Copilot wants to merge 8 commits intomainfrom
copilot/introduce-command-scope-context

Conversation

Copy link
Contributor

Copilot AI commented Feb 17, 2026

Summary

Implements a hierarchical context system for tracking commands, queries, and execution state across component trees. Command scopes can now be nested and injected into ViewModels, providing unified state management for save/cancel workflows and loading indicators.

Added

  • Hierarchical scope support - ICommandScope instances can be nested with parent property tracking the scope chain
  • Query tracking - Queries created via useQuery hook are automatically registered with nearest scope
  • isPerforming flag - Tracks real-time execution state for commands and queries
  • ViewModel DI integration - ICommandScope can be injected via tsyringe, receiving closest scope in component hierarchy
  • Status callbacks - CommandScope component accepts setIsPerforming and setHasChanges callbacks for state propagation
// ViewModel injection
@injectable()
export class MyViewModel {
    constructor(private readonly _commandScope: ICommandScope) {}
    
    get isLoading(): boolean {
        return this._commandScope.isPerforming;
    }
}

// Hierarchical scopes
<CommandScope setHasChanges={setHasChanges} setIsPerforming={setIsPerforming}>
    <PageToolbar />
    <Section>
        <CommandScope>
            <SectionToolbar />
            <SectionContent />
        </CommandScope>
    </Section>
</CommandScope>

Changed

  • ICommandScope from interface to abstract class - Enables DI injection while maintaining extensibility
  • useQuery dependency tracking - Added commandScope to useMemo dependencies for proper re-registration on scope changes
  • CommandScope component - Uses refs to avoid stale closures in callbacks

Removed

  • isInvalid flag - Removed due to async validation complexity; validation checked during execution instead
Original prompt

This section details on the original issue you should resolve

<issue_title>Introduce a context that holds information about commands, queries and general status flags such as loading, performing, invalid and more</issue_title>
<issue_description>We want to expose information quite easily about what is happening inside your application.
Much like we had in Bifrost region.

The goal is to be able to get to the current context and quite easily get status of whether or not commands are being performed, queries being performed and also whether or not there are items holding validators such as commands and queries that are invalid and easily get to the validation results for these.

We call this CommandScope in React today.

It should be established explicitly. But there should be a root scope that is configured in the Arc context.

Its meant to be hierarchical, everything bubbling up to the parent scope.
We're interested in knowing:

  • Are things valid
  • Are there commands with changes

Change the ICommandScope from an interface to abstract class and make it possible to inject it into view models.

ViewModels should get the closest command scope injected.

</issue_description>

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

@einari This should be possible to be injected into a ViewModel and at the same time be accessible through a React Hook

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 7 commits February 17, 2026 13:47
… add query tracking

Co-authored-by: einari <134365+einari@users.noreply.github.com>
Co-authored-by: einari <134365+einari@users.noreply.github.com>
Co-authored-by: einari <134365+einari@users.noreply.github.com>
Co-authored-by: einari <134365+einari@users.noreply.github.com>
…eview

Co-authored-by: einari <134365+einari@users.noreply.github.com>
Co-authored-by: einari <134365+einari@users.noreply.github.com>
…lify implementation

Co-authored-by: einari <134365+einari@users.noreply.github.com>
Copilot AI changed the title [WIP] Introduce context for commands and queries status Introduce hierarchical command/query context with status tracking Feb 17, 2026
Copilot AI requested a review from einari February 17, 2026 14:01
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.

Introduce a context that holds information about commands, queries and general status flags such as loading, performing, invalid and more

2 participants

Comments