Skip to content

chore(xgw): prefer String#slice() over String#substring()#87

Merged
ryan-dyer-sp merged 1 commit into
brightfire/xgwfrom
claw/vash/xgw-lint
Jun 4, 2026
Merged

chore(xgw): prefer String#slice() over String#substring()#87
ryan-dyer-sp merged 1 commit into
brightfire/xgwfrom
claw/vash/xgw-lint

Conversation

@ryan-dyer-sp

Copy link
Copy Markdown
Member

Summary

Clears three pre-existing unicorn/prefer-string-slice lint annotations on brightfire/xgw that PR #85's build-stable run surfaced.

Changes

  • src/gateway/xgw/outbound.ts:68bodyText.substring(0, 200)bodyText.slice(0, 200)
  • src/gateway/server-methods/sessions-xgw.ts:47rawKey.substring(1, slashIdx)rawKey.slice(1, slashIdx)
  • src/gateway/server-methods/sessions-xgw.ts:48rawKey.substring(slashIdx + 1)rawKey.slice(slashIdx + 1)

Why

String#slice() is the modern preferred form. All three call sites pass non-negative integer arguments, so the behaviour of slice() and substring() is byte-identical — substring() only differs from slice() when given negative or out-of-order arguments. Pure hygiene change.

Test plan

pnpm exec oxlint src/gateway/xgw/outbound.ts src/gateway/server-methods/sessions-xgw.ts   # clean
pnpm test src/gateway/xgw/ src/gateway/server-methods/sessions-xgw.test.ts                # all green
git grep -n "substring(" -- src/gateway/xgw/ src/gateway/server-methods/sessions-xgw.ts   # no remaining hits

Refs

Three pre-existing lint annotations on brightfire/xgw surfaced by
pre-push checks during PR #85's build-stable run:

- src/gateway/xgw/outbound.ts:68
- src/gateway/server-methods/sessions-xgw.ts:47
- src/gateway/server-methods/sessions-xgw.ts:48

All three are non-negative integer arguments, so slice() and
substring() behave identically. Pure hygiene change to clear lint
debt that pre-dates the xgw canonical's latest PR (#72).
@ryan-dyer-sp ryan-dyer-sp merged commit c8c6d9c into brightfire/xgw Jun 4, 2026
74 of 86 checks passed
@github-actions github-actions Bot deleted the claw/vash/xgw-lint branch June 4, 2026 16:50
ryan-dyer-sp added a commit that referenced this pull request Jun 4, 2026
)

The previous step ran prepush:ci with stderr silenced and a tsgo fallback:
  run: pnpm prepush:ci 2>/dev/null || pnpm tsgo

This hid real failures and produced misleading 100s timing on every build.
prepush:ci's first inner step (pnpm check) was failing on pre-existing
lint debt; bash exited non-zero; the fallback pnpm tsgo ran in ~20s and
the workflow continued. We never ran the strict-smoke bundle, the UI
guard, or any of the lint surface that step purported to check.

Once PRs #86 and #87 cleared the lint debt, prepush:ci ran to completion
and exposed massive redundancy: it triples up on pnpm test (extensions
config + unit config + full suite), all at maxWorkers=1, on top of the
workflow's existing 'Run tests' step which already runs the full suite
at PARALLEL=4 × MAX_WORKERS=2. The extension and unit configs are
included in fullSuiteVitestShards, so 'Run tests' already covers them.

Replaces the single silenced step with three explicit non-redundant
checks before Build:

  - pnpm check                          (lint + arch + typecheck)
  - pnpm build:strict-smoke             (bundle smoke + plugin-sdk dts)
  - pnpm lint:ui:no-raw-window-open     (UI guard)

prepush:ci's protocol regeneration is already handled by 'Regenerate
build artifacts' with drift-absorb-via-commit semantics, which is the
correct behavior for the squash-merge build-stable context (drift is
expected, not a failure).

prepush:ci's test invocations are dropped — they duplicate 'Run tests'
slower and serial. No coverage lost.

Steps remain sequential rather than backgrounded-parallel because tsgo
and tsdown are memory-hungry (tsgo:prod alone wants 12GB heap); running
concurrently risks OOM on the 32GB runner. GHA step-level overhead is
~0, so sequential gives clean logs and per-step timing.

Expected wall-clock: prior ~22min (with silenced failure) -> new
~25-30min (actually doing the work). Saves ~15min of redundant test
runs by dropping the inner prepush:ci test phase.

Refs: #86, #87

Co-authored-by: Vash <vash@brightfire.net>
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.

1 participant