From c3ebb298f3eb08e0a56ddd1eb5ce9283379bb9aa Mon Sep 17 00:00:00 2001 From: Jinwoo-H Date: Thu, 17 Sep 2026 00:42:34 -0400 Subject: [PATCH] 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 --- .../mobile-tasks-refactor-parity.test.ts | 19 ++++++++--- ...obile-tasks-github-reply-merge-actions.tsx | 12 +++---- ...ile-tasks-gitlab-github-status-actions.tsx | 5 ++- ...le-tasks-hosted-comment-review-actions.tsx | 7 ++-- ...e-mobile-tasks-hosted-metadata-actions.tsx | 5 ++- ...obile-tasks-project-file-merge-actions.tsx | 5 ++- ...ile-tasks-project-thread-reply-actions.tsx | 7 ++-- .../use-mobile-tasks-task-create-actions.tsx | 33 +++++++++---------- 8 files changed, 47 insertions(+), 46 deletions(-) diff --git a/mobile/src/tasks/mobile-tasks-refactor-parity.test.ts b/mobile/src/tasks/mobile-tasks-refactor-parity.test.ts index e8690cf64ba..7cee22fe1cf 100644 --- a/mobile/src/tasks/mobile-tasks-refactor-parity.test.ts +++ b/mobile/src/tasks/mobile-tasks-refactor-parity.test.ts @@ -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) }) diff --git a/mobile/src/tasks/use-mobile-tasks-github-reply-merge-actions.tsx b/mobile/src/tasks/use-mobile-tasks-github-reply-merge-actions.tsx index e0178bef784..91a8e248cf1 100644 --- a/mobile/src/tasks/use-mobile-tasks-github-reply-merge-actions.tsx +++ b/mobile/src/tasks/use-mobile-tasks-github-reply-merge-actions.tsx @@ -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 }) diff --git a/mobile/src/tasks/use-mobile-tasks-gitlab-github-status-actions.tsx b/mobile/src/tasks/use-mobile-tasks-gitlab-github-status-actions.tsx index 9b4864d294d..68ebd8fc855 100644 --- a/mobile/src/tasks/use-mobile-tasks-gitlab-github-status-actions.tsx +++ b/mobile/src/tasks/use-mobile-tasks-gitlab-github-status-actions.tsx @@ -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 }) diff --git a/mobile/src/tasks/use-mobile-tasks-hosted-comment-review-actions.tsx b/mobile/src/tasks/use-mobile-tasks-hosted-comment-review-actions.tsx index 0ad6fda90ea..90c28df540c 100644 --- a/mobile/src/tasks/use-mobile-tasks-hosted-comment-review-actions.tsx +++ b/mobile/src/tasks/use-mobile-tasks-hosted-comment-review-actions.tsx @@ -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(), diff --git a/mobile/src/tasks/use-mobile-tasks-hosted-metadata-actions.tsx b/mobile/src/tasks/use-mobile-tasks-hosted-metadata-actions.tsx index e2473c8fd11..377d6815cb8 100644 --- a/mobile/src/tasks/use-mobile-tasks-hosted-metadata-actions.tsx +++ b/mobile/src/tasks/use-mobile-tasks-hosted-metadata-actions.tsx @@ -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([ diff --git a/mobile/src/tasks/use-mobile-tasks-project-file-merge-actions.tsx b/mobile/src/tasks/use-mobile-tasks-project-file-merge-actions.tsx index c96ee719515..9ceb5e4f463 100644 --- a/mobile/src/tasks/use-mobile-tasks-project-file-merge-actions.tsx +++ b/mobile/src/tasks/use-mobile-tasks-project-file-merge-actions.tsx @@ -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 }) diff --git a/mobile/src/tasks/use-mobile-tasks-project-thread-reply-actions.tsx b/mobile/src/tasks/use-mobile-tasks-project-thread-reply-actions.tsx index 14180083b44..8d7928eaa71 100644 --- a/mobile/src/tasks/use-mobile-tasks-project-thread-reply-actions.tsx +++ b/mobile/src/tasks/use-mobile-tasks-project-thread-reply-actions.tsx @@ -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(), diff --git a/mobile/src/tasks/use-mobile-tasks-task-create-actions.tsx b/mobile/src/tasks/use-mobile-tasks-task-create-actions.tsx index 1d80ab31d31..f589a1a357f 100644 --- a/mobile/src/tasks/use-mobile-tasks-task-create-actions.tsx +++ b/mobile/src/tasks/use-mobile-tasks-task-create-actions.tsx @@ -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: [],