Skip to content

refactor: eliminate duplicate log source resolution logic#2619

Merged
lpcox merged 2 commits intomainfrom
copilot/remove-duplicate-log-source-logic
May 6, 2026
Merged

refactor: eliminate duplicate log source resolution logic#2619
lpcox merged 2 commits intomainfrom
copilot/remove-duplicate-log-source-logic

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 6, 2026

logs.ts contained a ~38-line inline copy of the source discovery/validation/selection block that already existed as discoverAndSelectSource() in logs-command-helpers.ts. Any bug fix or behavioral change had to be applied twice.

Changes

  • logs-command-helpers.ts: Made loggingOptions optional in discoverAndSelectSource(). When omitted, info messages are always emitted — preserving the unconditional logging behavior expected by logsCommand.

  • logs.ts: Replaced the inline block with a single call to discoverAndSelectSource(options.source); removed now-unused imports (discoverLogSources, selectMostRecent, validateSource).

  • logs-audit.test.ts: Added toBeDefined() + non-null assertion on loggingOptions to satisfy TypeScript's stricter typing of the now-optional parameter.

// Before: ~38 lines of inline logic in logs.ts
const sources = await discoverLogSources();
let source;
if (options.source) { ... } else if (sources.length === 0) { ... } else { ... }

// After
const source = await discoverAndSelectSource(options.source);

Copilot AI changed the title [WIP] Refactor duplicated log source resolution logic refactor: eliminate duplicate log source resolution logic May 6, 2026
Copilot AI requested a review from lpcox May 6, 2026 14:08
Copilot finished work on behalf of lpcox May 6, 2026 14:08
@lpcox lpcox marked this pull request as ready for review May 6, 2026 21:17
Copilot AI review requested due to automatic review settings May 6, 2026 21:17
@lpcox lpcox requested a review from Mossaka as a code owner May 6, 2026 21:17
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

⚠️ Coverage Regression Detected

This PR decreases test coverage. Please add tests to maintain coverage levels.

Overall Coverage

Metric Base PR Delta
Lines 86.81% 86.88% 📈 +0.07%
Statements 86.75% 86.82% 📈 +0.07%
Functions 81.39% 80.71% 📉 -0.68%
Branches 79.55% 79.63% 📈 +0.08%
📁 Per-file Coverage Changes (2 files)
File Lines (Before → After) Statements (Before → After)
src/container-lifecycle.ts 87.1% → 88.2% (+1.14%) 87.5% → 88.6% (+1.11%)
src/commands/logs-command-helpers.ts 84.7% → 88.3% (+3.59%) 85.0% → 88.5% (+3.52%)

Coverage comparison generated by scripts/ci/compare-coverage.ts

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

Smoke Test Results

✅ GitHub MCP: Last 2 merged PRs retrieved
✅ Playwright: GitHub page title verified
✅ File Writing: Test file created
✅ Bash Verification: File content confirmed

Status: PASS

💥 [THE END] — Illustrated by Smoke Claude

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

🔥 Smoke Test: Copilot BYOK (Offline) Mode

Test Result
GitHub MCP connectivity ✅ Listed merged PR #2599
GitHub.com HTTP ⚠️ Pre-step data unavailable (template vars not expanded)
File write/read ⚠️ Pre-step data unavailable (template vars not expanded)
BYOK inference (agent → api-proxy → api.githubcopilot.com)

Running in BYOK offline mode (COPILOT_OFFLINE=true) via api-proxy → api.githubcopilot.com.

Overall: PARTIAL — BYOK inference path confirmed working; pre-computed step data was not substituted into prompt.

PR author: @Copilot · Assignees: @lpcox, @Copilot

🔑 BYOK report filed by Smoke Copilot BYOK

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

🔬 Smoke Test Results

Test Status
GitHub MCP — refactor: eliminate duplicate log source resolution logic
GitHub.com connectivity (HTTP 200/301)
File write/read (smoke-test-copilot-25440333670.txt)

Overall: PASS

Author: @Copilot · Assignees: @lpcox, @Copilot

📰 BREAKING: Report filed by Smoke Copilot

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

Smoke Test Codex: FAIL
✅ Merged PRs: feat(api-proxy): OIDC authentication for Azure OpenAI (Entra-only); Enable Copilot BYOK provider-env fallback, base-path routing, and hardened token isolation
❌ safeinputs-gh PR query unavailable; ❌ Tavily search unavailable; ❌ github-discussion-query unavailable
✅ Playwright title GitHub; ✅ file write/read; ✅ npm ci && npm run build
Overall status: FAIL

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • registry.npmjs.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "registry.npmjs.org"

See Network Configuration for more information.

🔮 The oracle has spoken through Smoke Codex

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 refactors the awf logs command to reuse the existing log source discovery/validation/selection helper instead of maintaining a duplicated inline implementation, reducing drift risk between log-related commands.

Changes:

  • Made discoverAndSelectSource() accept an optional loggingOptions parameter to preserve logsCommand’s unconditional info logging behavior when auto-selecting a source.
  • Replaced the inline source discovery/selection logic in logs.ts with a call to discoverAndSelectSource(options.source).
  • Updated logs-audit.test.ts typing assertions to account for the now-optional helper parameter.
Show a summary per file
File Description
src/commands/logs.ts Removes duplicated source-selection logic and delegates to discoverAndSelectSource().
src/commands/logs-command-helpers.ts Makes loggingOptions optional and adjusts conditional info logging behavior accordingly.
src/commands/logs-audit.test.ts Updates test assertions for the optional loggingOptions parameter typing.

Copilot's findings

Tip

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

  • Files reviewed: 3/3 changed files
  • Comments generated: 2

Comment on lines 33 to 40
* @param sourceOption - User-specified source path or "running", or undefined for auto-discovery
* @param loggingOptions - Options controlling when to emit log messages
* @param loggingOptions - Options controlling when to emit log messages; when omitted, info messages are always emitted
* @returns Selected log source
*/
export async function discoverAndSelectSource(
sourceOption: string | undefined,
loggingOptions: LoggingOptions
loggingOptions?: LoggingOptions
): Promise<LogSource> {
Comment thread src/commands/logs.ts
Comment on lines 8 to 13
listLogSources,
LogFormatter,
streamLogs,
} from '../logs';
import { discoverAndSelectSource } from './logs-command-helpers';

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

🏗️ Build Test Suite Results

Ecosystem Project Build/Install Tests Status
Bun elysia 1/1 passed ✅ PASS
Bun hono 1/1 passed ✅ PASS
C++ fmt N/A ✅ PASS
C++ json N/A ✅ PASS
Deno oak N/A 1/1 passed ✅ PASS
Deno std N/A 1/1 passed ✅ PASS
.NET hello-world N/A ✅ PASS
.NET json-parse N/A ✅ PASS
Go color 1/1 passed ✅ PASS
Go env 1/1 passed ✅ PASS
Go uuid 1/1 passed ✅ PASS
Java gson 1/1 passed ✅ PASS
Java caffeine 1/1 passed ✅ PASS
Node.js clsx All passed ✅ PASS
Node.js execa All passed ✅ PASS
Node.js p-limit All passed ✅ PASS
Rust fd 1/1 passed ✅ PASS
Rust zoxide 1/1 passed ✅ PASS

Overall: 8/8 ecosystems passed — ✅ PASS

Generated by Build Test Suite for issue #2619 · ● 492.1K ·

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

Chroot Version Comparison

Runtime Host Version Chroot Version Match?
Python Python 3.12.13 Python 3.12.3 ❌ NO
Node.js v24.14.1 v20.20.2 ❌ NO
Go go1.22.12 go1.22.12 ✅ YES

⚠️ Not all versions match. Label smoke-chroot was not applied.

Tested by Smoke Chroot

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

Smoke Test: GitHub Actions Services Connectivity

Check Result
Redis PING ❌ Timeout/no response
PostgreSQL pg_isready ❌ No response on port 5432
PostgreSQL SELECT 1 ❌ Timeout/no response

Overall: FAILhost.docker.internal is not reachable from this runner. Service containers may not be configured or the host alias is unavailable in this environment.

🔌 Service connectivity validated by Smoke Services

@lpcox
Copy link
Copy Markdown
Collaborator

lpcox commented May 6, 2026

@copilot address the review feedback

@lpcox lpcox merged commit f85511d into main May 6, 2026
67 of 75 checks passed
Copilot stopped work on behalf of lpcox due to an error May 6, 2026 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Duplicate Code] Duplicated log source resolution logic between logs.ts and logs-command-helpers.ts

3 participants