Skip to content

Extract ProgressPresenter module from src/index.ts#19

Merged
SorraTheOrc merged 3 commits intomainfrom
copilot/extract-progress-presenter-module
Apr 9, 2026
Merged

Extract ProgressPresenter module from src/index.ts#19
SorraTheOrc merged 3 commits intomainfrom
copilot/extract-progress-presenter-module

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 7, 2026

Progress message state and lifecycle were inline inside processUrlWithProgress in src/index.ts, mixing presentation concerns with orchestration logic.

Changes

src/presenters/progress.ts — new ProgressPresenter class

  • statusMessages: Map<string, any> — tracks the posted Discord message per phase, enabling future update/delete operations
  • handleProgressEvent(event) — encapsulates phase deduplication, message formatting (via formatProgressMessage), backtick-wrapping of URLs/titles, thread-preferred posting with channel fallback, and terminal-phase suppression
  • Accessors: getLastPhase(), getLastPostedMessage(), isTerminalPhaseSeen(), getStatusMessages()

src/index.ts

Replaces ~70 lines of inline state (lastPhase, terminalPhaseSeen, lastPostedMessage) and the progress event loop with:

const presenter = new ProgressPresenter(thread, message, logger);

while (true) {
  const iteration = await addGenerator.next();
  if (iteration.done) { finalResult = iteration.value; break; }
  await presenter.handleProgressEvent(iteration.value);
}

const lastPhase = presenter.getLastPhase();
let lastPostedMessage = presenter.getLastPostedMessage();

tests/unit/progress.presenter.spec.ts — 19 new unit tests

Covers: phase deduplication, terminal phase suppression, thread→channel fallback, statusMessages Map population, phase emoji formatting, and backtick-wrapping of titles/URLs.

Copilot AI linked an issue Apr 7, 2026 that may be closed by this pull request
8 tasks
Copilot AI changed the title [WIP] Extract ProgressPresenter module from index.ts Extract ProgressPresenter module from src/index.ts Apr 7, 2026
Copilot AI requested a review from SorraTheOrc April 7, 2026 19:39
@SorraTheOrc SorraTheOrc marked this pull request as ready for review April 7, 2026 19:55
@SorraTheOrc
Copy link
Copy Markdown
Member

Automated PR review could not be completed because the AMPA review container failed to start ( raised ). As a result, audit, code-review, and test checks were not executed in an isolated container. Please resolve the AMPA startup issue and rerun this review workflow.

@SorraTheOrc
Copy link
Copy Markdown
Member

Automated review is currently blocked: AMPA container startup failed before checkout/tests could run. Result: Tests not executed, Audit not executed, Code review not executed in isolated container. Blocking issue tracked in SB-0MNP1PLSX003GOOP; please rerun after that fix lands.

…rogressPresenter extraction and final result handling
@SorraTheOrc SorraTheOrc merged commit 22dc55a into main Apr 9, 2026
1 check failed
@SorraTheOrc
Copy link
Copy Markdown
Member

@github-copilot

Ready to close: No

Summary

Progress formatting has been extracted into src/formatters/progress.ts and covered by unit tests, but the requested ProgressPresenter module (encapsulating state, lifecycle management, and onProgress handling) is not present. Stateful maps and lifecycle logic remain inline in src/index.ts and there are no isolated unit tests for a Presenter. Automated CI/test verification was blocked by an AMPA startup failure, so tests were not executed in an isolated container.

Acceptance Criteria Status

# Criterion Verdict Evidence
1 ProgressPresenter module exists in appropriate location (e.g., src/presenters/) unmet src/presenters/queue.ts:1 — presenters/ contains queue presenter but no src/presenters/progress.* (ProgressPresenter)
2 All progress formatting logic is moved out of src/index.ts met src/formatters/progress.ts:3 — formatProgressMessage implements phase handling and truncation; imported by src/index.ts:7
3 ProgressPresenter has clear, documented interface unmet src/formatters/progress.ts:3 — only a formatting function is exported; no presenter class/interface or JSDoc present
4 State management (statusMessages Map) is properly encapsulated unmet src/index.ts:75 — stateful maps (saveBriefingCache/postedSummaryMarkers) are defined inline in index.ts; no encapsulated statusMessages Map in presenters
5 Unit tests verify progress message formatting met tests/unit/formatProgressMessage.spec.ts:6 — unit tests cover known phases and truncation behavior
6 Unit tests verify status message lifecycle partial tests/index.test.ts:368 — lifecycle behaviors exercised by integration-style tests (thread send, setArchived) but no isolated Presenter unit tests
7 Integration tests verify end-to-end progress behavior unchanged met tests/index.test.ts:477 — test asserts generated summary posting, item link, timestamp, and thread archiving
8 All existing tests continue to pass unmet SB comment SB-C0MNP1R2CC005B01W — AMPA startup failure (CONTAINER_PROJECT_ROOT undefined) blocked automated test run

Children Status

Review PR #19 (SB-0MNP1NYG3008MXVW) — completed/in_review

No acceptance criteria defined.

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.

Extract ProgressPresenter module

2 participants