Skip to content

Console: open a separate tab per operation - #110

Merged
graeme merged 3 commits into
mainfrom
fix-console-tab-bug
Aug 4, 2026
Merged

Console: open a separate tab per operation#110
graeme merged 3 commits into
mainfrom
fix-console-tab-bug

Conversation

@graeme

@graeme graeme commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

PR: Console: open a separate tab when an operation id is re-run

Summary

Fixes a console tab uniqueness bug: installing a package and then uninstalling it reused a single tab, still titled after the first operation, with the second operation's output appended to the first. Install and uninstall (or any two operations on the same package) now open two separate tabs.

Changes

  • Introduce CommandJobID, a UUID-backed per-run identity, as the console tab identity. This is distinct from BrewOperationID, which the command center deliberately reuses across successive operations on the same package.
  • CommandJob now carries both its id (the tab) and its operationID (the routing key). Retyped CommandJobsObserving, BrewCommandJobsRepository (jobs, orderedIDs, remove), the console view model (selectedID, select, dismiss), and the unimplemented environment stub to the new id.
  • The repository routes live phase and output updates through a liveJobByOperationID map. When a job reaches a terminal phase its entry is cleared, so the next .running for that operation id materializes a fresh tab rather than reviving the finished one.

Why this split

Two atomic commits. The first is a pure refactor that introduces the identity separation with behaviour preserved. The second makes the single behaviour change (clear the routing entry on terminal) plus its regression test, so the fix is easy to review and revert in isolation.

Testing

  • scripts/test full suite green (622 tests across 74 suites).
  • Added a regression test asserting install then uninstall of the same package yields two tabs, each with its own command string and output buffer.
  • swiftformat, swiftlint --strict, and BrewUILint all clean.

PR checklist

  • Have you followed this repository's contribution and workflow guidance?
  • Have you explained what changed and why this should land now?
  • Have you run relevant local checks for the changed scope?
  • Are changes scoped and free of unrelated modifications?

  • AI was used to generate or assist with generating this PR.
  • If yes, describe exactly how AI was used and what manual verification was performed. Claude Code diagnosed the root cause, implemented both commits, and wrote the tests. The full test suite and lint tooling were run locally and pass.

Console tabs were keyed by BrewOperationID, which the command center
deliberately reuses across successive operations on the same package
(install, upgrade, uninstall of `gh` all share one id). Introduce a
per-run CommandJobID as the tab identity, with the BrewOperationID kept
on CommandJob as its routing key, and route live phase/output updates
through a liveJobByOperationID map in the repository.

Pure refactor: behaviour is unchanged — a re-run for an id that already
has a job still reuses that tab. The next commit fixes that.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Copilot AI left a comment

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.

Pull request overview

This PR fixes a console-tab identity bug by splitting “operation routing identity” (BrewOperationID) from “per-run tab identity” (CommandJobID), so re-running an operation on the same package creates a new tab rather than reusing the old one.

Changes:

  • Introduces CommandJobID (UUID-backed) and updates CommandJob to carry both id (tab identity) and operationID (routing key).
  • Retypes the console jobs repository, observing protocol, console view model selection/dismiss APIs, and the unimplemented environment stub to use CommandJobID.
  • Adds/updates tests, including a regression test asserting “install then uninstall same package” yields two distinct tabs with separate command/output buffers.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
Tests/BrewFeatureConsoleTests/ConsoleViewModelTests.swift Updates selection/active job assertions to use operationID vs per-tab id and adapts to CommandJobID selection.
Tests/BrewFeatureConsoleTests/ConsoleJobsHarness.swift Adds helpers to bridge operation IDs to the most recent routed CommandJob and to expose ordered operation IDs for assertions.
Tests/BrewFeatureConsoleTests/CommandJobTests.swift Updates CommandJob construction to use operationID: initializer label.
Tests/BrewFeatureConsoleTests/CommandJobExportTests.swift Updates CommandJob construction to use operationID: initializer label.
Tests/BrewFeatureConsoleTests/BrewCommandJobsRepositoryTests.swift Updates repository assertions for CommandJobID and adds regression test for separate tabs on rerun.
Sources/BrewRepositoryInterfaces/Protocols/CommandJobsObserving.swift Retypes observing interface to jobs/orderedIDs/remove keyed by CommandJobID.
Sources/BrewRepositoryInterfaces/CommandJob.swift Adds CommandJobID and splits CommandJob identity (id) from routing key (operationID).
Sources/BrewRepositories/BrewCommandJobsRepository.swift Implements liveJobByOperationID routing map to associate operation updates with a specific tab identity.
Sources/BrewFeatureConsole/ViewModels/ConsoleViewModel.swift Retypes selection and dismissal to CommandJobID, keeping selectedJob derived from repository state.
Sources/BrewAppEnvironment/UnimplementedRepositories.swift Updates unimplemented observing stub to the new CommandJobID-keyed API.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Sources/BrewRepositories/BrewCommandJobsRepository.swift Outdated
@graeme graeme changed the title Fix console tab bug Console: open a separate tab per operation Aug 4, 2026
graeme and others added 2 commits August 4, 2026 19:40
When a job reaches terminal, clear its liveJobByOperationID entry so the
next `.running` for that BrewOperationID materializes a fresh tab instead
of reviving the finished one. Fixes install-then-uninstall of the same
package showing on a single tab titled after the first operation.

Adds a regression test asserting two distinct tabs with their own command
strings and output buffers.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@graeme
graeme force-pushed the fix-console-tab-bug branch from 591dc59 to a5bedbd Compare August 4, 2026 09:44
@graeme
graeme marked this pull request as ready for review August 4, 2026 09:48
@graeme
graeme merged commit 80d8fc7 into main Aug 4, 2026
10 checks passed
@graeme
graeme deleted the fix-console-tab-bug branch August 4, 2026 12:03
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.

3 participants