#23594: test(tui): fix mock typing in command handler tests
size: XS
## Summary
Describe the problem and fix in 2–5 bullets:
- Problem:
- Why it matters:
- What changed:
- What did NOT change (scope boundary):
## Change Type (select all)
- [ ] Bug fix
- [ ] Feature
- [ ] Refactor
- [ ] Docs
- [ ] Security hardening
- [ ] Chore/infra
## Scope (select all touched areas)
- [ ] Gateway / orchestration
- [ ] Skills / tool execution
- [ ] Auth / tokens
- [ ] Memory / storage
- [ ] Integrations
- [ ] API / contracts
- [ ] UI / DX
- [ ] CI/CD / infra
## Linked Issue/PR
- Closes #
- Related #
## User-visible / Behavior Changes
List user-visible changes (including defaults/config).
If none, write `None`.
## Security Impact (required)
- New permissions/capabilities? (`Yes/No`)
- Secrets/tokens handling changed? (`Yes/No`)
- New/changed network calls? (`Yes/No`)
- Command/tool execution surface changed? (`Yes/No`)
- Data access scope changed? (`Yes/No`)
- If any `Yes`, explain risk + mitigation:
## Repro + Verification
### Environment
- OS:
- Runtime/container:
- Model/provider:
- Integration/channel (if any):
- Relevant config (redacted):
### Steps
1.
2.
3.
### Expected
-
### Actual
-
## Evidence
Attach at least one:
- [ ] Failing test/log before + passing after
- [ ] Trace/log snippets
- [ ] Screenshot/recording
- [ ] Perf numbers (if relevant)
## Human Verification (required)
What you personally verified (not just CI), and how:
- Verified scenarios:
- Edge cases checked:
- What you did **not** verify:
## Compatibility / Migration
- Backward compatible? (`Yes/No`)
- Config/env changes? (`Yes/No`)
- Migration needed? (`Yes/No`)
- If yes, exact upgrade steps:
## Failure Recovery (if this breaks)
- How to disable/revert this change quickly:
- Files/config to restore:
- Known bad symptoms reviewers should watch for:
## Risks and Mitigations
List only real risks for this PR. Add/remove entries as needed. If none, write `None`.
- Risk:
- Mitigation:
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Improved mock type safety in TUI command handler tests by replacing unsafe type assertions with proper TypeScript narrowing patterns.
- Changed `as never` to `as unknown as never` for type assertions in test mocks, following best practice to avoid directly casting to `never`
- Introduced `resolveSendFn` helper function to safely invoke the `resolveSend` callback with optional chaining instead of unsafe type assertion
- These changes improve type safety without affecting test behavior or coverage
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk
- The changes are purely test-focused type safety improvements with no runtime behavior changes. The modifications follow TypeScript best practices by using `as unknown as never` instead of direct `as never` casts, and introduce a helper function to eliminate unsafe type assertions. This is part of a series of commits improving type safety in the TUI tests.
- No files require special attention
<sub>Last reviewed commit: f448669</sub>
<!-- greptile_other_comments_section -->
<sub>(4/5) You can add custom instructions or style guidelines for the agent [here](https://app.greptile.com/review/github)!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#21027: fix(tests): resolve TypeScript type errors in CLI test files
by kittipond2365 · 2026-02-19
79.3%
#23772: fix(ci): unblock repo-wide check gate type regressions
by SmithLabsLLC · 2026-02-22
79.1%
#17393: fix(ci): resolve TS2742 type error blocking all PRs
by miloudbelarebia · 2026-02-15
77.7%
#16479: fix(test): annotate vitest mock return types to resolve TS2742 port...
by colddonkey · 2026-02-14
77.5%
#20496: test(utils): add comprehensive unit tests for utility functions
by masifislamm · 2026-02-19
75.5%
#9220: Fix: TUI drops API responses silently when runID already finalized
by vishaltandale00 · 2026-02-05
75.3%
#6116: refactor: add explicit type assertion in resolveOptionFromCommand
by T1mn · 2026-02-01
74.9%
#19674: test: allow optional session key in subagent announce mock
by DmitryIschanko · 2026-02-18
74.9%
#4109: fix(cli): bypass config guard for tui --url
by hopenjin · 2026-01-29
74.4%
#22990: test: fix readonly typing regressions in CI check baseline
by bmendonca3 · 2026-02-21
74.2%