refactor(mobile): inline the alias-only bindings the deleted casts left behind

Each of the eight was `const result = x as { ok?: boolean; error?: string }`.
With the cast gone the line is a rename of a binding that already has a name,
and every one of them is followed immediately by the same `ok === false` check.
Reading `created.ok` / `updated.ok` / `written.ok` / `replyResult.ok` directly
leaves one name per value.

The parity constants move with it and with the reaction change before it. The
comment there names both: ten string literals leave `semantics` with the phantom
reaction vocabulary and one arrives with the `?? ''` fallback, and the alias
deletions move the hook and statement hashes. No `rpc:` or `jsx:` signature
moves, the render-token hash does not move, and the hook, statement and
declaration counts are unchanged at 350, 417 and 194.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
This commit is contained in:
Jinwoo-H
2026-09-17 00:42:34 -04:00
parent 9421a88e9f
commit c3ebb298f3
8 changed files with 47 additions and 46 deletions
@@ -34,15 +34,24 @@ const hash = (parts: string[] | string): string =>
// counts are unchanged, and the render-token hash does not move at all — nothing this family sees
// changed inside a JSX tree. `semantics` is a pure deletion of ten lines.
//
// Round-1 review moves four, and names what each one is. The reaction reader stops matching
// `content` against an arm set mobile invented and forwards it, so `DetailComment` loses the eight
// phantom arms and `COMMENT_REACTION_EMOJI` stops being keyed by them: that is ten string literals
// gone and the `?? ''` fallback's one added, the whole of `semantics`' 3,290 -> 3,281. The eight
// alias-only bindings the deleted casts left behind (`const result = created` and its seven
// siblings) are inlined, which moves the hook and statement hashes without moving their counts.
// No `rpc:` signature and no `jsx:` signature moves, the render-token hash does not move, and
// counts stay at 350 hooks, 417 statements and 194 declarations.
//
// The `gitlab.todos` fixture correction moves the same three hashes once more and no others: the
// to-do row is checked now, so the reader's cast is gone from the list-loading hook and the row
// type it forwarded is declared by what the reader proves. Counts are unchanged again, and
// `semantics` does not move, because no RPC call, runtime string or JSX host signature does.
const SCREEN_RPC_SCREEN_HOOKS = '3d5371bc2db5a6959016293b8f071f55f37ffc914b5bc96fbaf1e7bd40ef47cd'
const SCREEN_RPC_SCREEN_HOOKS = 'ea596e60d596b595b007af6ab7f11fc232098b4a6c0331e092021b429836c17c'
const PRE_REFACTOR_DIFF_HOOKS = '93c7189b32bed8456cc51814fffa8ce80cf62011ef968a9d53ddec2b9686f58f'
const SCREEN_RPC_STATEMENTS = '206ba86923dea685ae7b22030c62ad1bd94466dc0dd1308ac78567ee358a86e2'
const MAIN_REBASED_DECLARATIONS = 'e3617c37a4a28664ff4749dcdec4e31f1d657872b50dba5e27ae504e02cf9122'
const SCREEN_RPC_SEMANTICS = '3e729bc760428e4701cdfa87c5e51c4301524d96a4e79bff7af9eb403153d76c'
const SCREEN_RPC_STATEMENTS = 'b35d41712ae65958d6ae7cc7a967f4d2ccc99d65873f340f804e3ad92cbd0260'
const MAIN_REBASED_DECLARATIONS = '0f57ae1285c698344976adf7f888e840ddd48f1e12afb12990878525e1fe1380'
const SCREEN_RPC_SEMANTICS = '71e1e39421e917897335d2a987a756ef85414518558853633f21fa356752b871'
const PRE_REFACTOR_STYLES = '1db6af69c791d9963928541ad5310942fcbda6d984b422c90b6eb92b6816579a'
const SCREEN_RPC_RENDER_TREE = '46d5a3ce9d71a8281a1e7b17411fb1dd963a4f392a5d095bc126b6a7cff4b92d'
@@ -71,7 +80,7 @@ describe('Mobile Tasks refactor parity', () => {
it('preserves RPC calls, runtime strings, and JSX host signatures', () => {
const semantics = readMobileTasksSemanticSource()
expect(semantics.split('\n')).toHaveLength(3_290)
expect(semantics.split('\n')).toHaveLength(3_281)
expect(hash(semantics)).toBe(SCREEN_RPC_SEMANTICS)
})
@@ -88,11 +88,10 @@ export function useMobileTasksGithubReplyMergeActions(model: GithubCheckFileActi
{ timeoutMs: 30_000 }
)
)
const envelope = replyResult
if (envelope.ok === false) {
throw new Error(envelope.error ?? 'Failed to reply')
if (replyResult.ok === false) {
throw new Error(replyResult.error ?? 'Failed to reply')
}
const reply: DetailComment = envelope.comment ?? {
const reply: DetailComment = replyResult.comment ?? {
id: `local-${Date.now()}`,
body,
createdAt: new Date().toISOString(),
@@ -166,9 +165,8 @@ export function useMobileTasksGithubReplyMergeActions(model: GithubCheckFileActi
{ timeoutMs: 60_000 }
)
)
const result = merged
if (result.ok === false) {
throw new Error(result.error ?? 'Failed to merge')
if (merged.ok === false) {
throw new Error(merged.error ?? 'Failed to merge')
}
setActionItem(null)
await loadTasks({ silent: true })
@@ -52,9 +52,8 @@ export function useMobileTasksGitlabGithubStatusActions(model: ProjectFileMergeA
projectRef: item.source.projectRef
})
)
const result = updated
if (result.ok === false) {
throw new Error(result.error ?? 'Failed to update GitLab item')
if (updated.ok === false) {
throw new Error(updated.error ?? 'Failed to update GitLab item')
}
setActionItem(null)
await loadTasks({ silent: true })
@@ -93,11 +93,10 @@ export function useMobileTasksHostedCommentReviewActions(model: HostedMetadataAc
{ timeoutMs: 30_000 }
)
)
const result = written
if (result.ok === false) {
throw new Error(result.error ?? 'Failed to add comment')
if (written.ok === false) {
throw new Error(written.error ?? 'Failed to add comment')
}
const comment: DetailComment = result.comment ?? {
const comment: DetailComment = written.comment ?? {
id: `local-${Date.now()}`,
body,
createdAt: new Date().toISOString(),
@@ -142,9 +142,8 @@ export function useMobileTasksHostedMetadataActions(model: GitlabGithubStatusAct
{ timeoutMs: 30_000 }
)
)
const result = updated
if (result.ok === false) {
throw new Error(result.error ?? 'Failed to update GitLab item')
if (updated.ok === false) {
throw new Error(updated.error ?? 'Failed to update GitLab item')
}
const nextLabels = [
...new Set([
@@ -265,9 +265,8 @@ export function useMobileTasksProjectFileMergeActions(model: ProjectReviewCheckA
updates: { state: nextState }
})
)
const result = updated
if (result.ok === false) {
throw new Error(result.error ?? 'Failed to update GitHub status')
if (updated.ok === false) {
throw new Error(updated.error ?? 'Failed to update GitHub status')
}
setActionItem(null)
await loadTasks({ silent: true })
@@ -196,11 +196,10 @@ export function useMobileTasksProjectThreadReplyActions(
{ timeoutMs: 30_000 }
)
)
const result = written
if (result.ok === false) {
throw new Error(result.error ?? 'Failed to reply')
if (written.ok === false) {
throw new Error(written.error ?? 'Failed to reply')
}
const reply: DetailComment = result.comment ?? {
const reply: DetailComment = written.comment ?? {
id: `local-${Date.now()}`,
body,
createdAt: new Date().toISOString(),
@@ -73,23 +73,22 @@ export function useMobileTasksTaskCreateActions(model: LinearItemActionsModel) {
body: createBody
})
)
const result = created
if (result.ok === false) {
if (created.ok === false) {
throw new Error(
result.error ?? `Failed to create ${provider === 'github' ? 'GitHub' : 'GitLab'} issue`
created.error ?? `Failed to create ${provider === 'github' ? 'GitHub' : 'GitLab'} issue`
)
}
if (typeof result.number === 'number') {
if (typeof created.number === 'number') {
const createdAt = new Date().toISOString()
if (provider === 'github') {
setActionItem(
createGitHubTask(repo, {
id: `issue:${result.number}`,
id: `issue:${created.number}`,
type: 'issue',
number: result.number,
number: created.number,
title,
state: 'open',
url: result.url ?? '',
url: created.url ?? '',
labels: [],
updatedAt: createdAt,
author: null
@@ -98,12 +97,12 @@ export function useMobileTasksTaskCreateActions(model: LinearItemActionsModel) {
} else {
setActionItem(
createGitLabTask(repo, {
id: `issue:${result.number}`,
id: `issue:${created.number}`,
type: 'issue',
number: result.number,
number: created.number,
title,
state: 'opened',
url: result.url ?? '',
url: created.url ?? '',
labels: [],
updatedAt: createdAt,
author: null
@@ -122,19 +121,19 @@ export function useMobileTasksTaskCreateActions(model: LinearItemActionsModel) {
description: createBody.trim() || undefined,
workspaceId: team.workspaceId
})
const result = linearIssueCreate.interpret(reply)
if (result.ok === false || !result.id || !result.identifier) {
throw new Error(result.error ?? 'Failed to create Linear issue')
const created = linearIssueCreate.interpret(reply)
if (created.ok === false || !created.id || !created.identifier) {
throw new Error(created.error ?? 'Failed to create Linear issue')
}
setActionItem(
createLinearTask({
id: result.id,
id: created.id,
workspaceId: team.workspaceId,
workspaceName: team.workspaceName,
identifier: result.identifier,
title: result.title ?? title,
identifier: created.identifier,
title: created.title ?? title,
description: createBody.trim(),
url: result.url ?? '',
url: created.url ?? '',
state: { name: 'Open', type: 'unstarted', color: colors.accentBlue },
team,
labels: [],