Skip to content

fix(swift-ios): open workspace file links - #5803

Closed
saphid wants to merge 7 commits into
pingdotgg:t3code/rebuild-mobile-app-swiftfrom
saphid:t3code/fix-swiftui-file-links-upstream
Closed

fix(swift-ios): open workspace file links#5803
saphid wants to merge 7 commits into
pingdotgg:t3code/rebuild-mobile-app-swiftfrom
saphid:t3code/fix-swiftui-file-links-upstream

Conversation

@saphid

@saphid saphid commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

What changed

  • Makes workspace-file links in native SwiftUI transcripts tappable inside recycled UICollectionView cells while preserving text selection across linked text.
  • Resolves repository-relative and contained absolute paths, strips :line[:column], and opens the existing Files preview.
  • Keeps ordinary web URLs on the system path and rejects authorities, traversal, and paths outside the workspace.

This is deliberately limited to transcript → existing Files preview. It does not add recursive navigation between Markdown file previews or change server, wire, web, React Native, signing, or release behavior.

Base: pingdotgg/t3code:t3code/rebuild-mobile-app-swift at e55c7ffd1 (owner PR #5178).
Reviewed head: 2ce29335a0a9e8a820a5c0d89da4434a8d0e9242 (tree-identical metadata refresh after an unrelated WebKit simulator flake).

Why

SwiftUI Text(AttributedString) links hosted through UIHostingConfiguration were rendered as links but did not reliably receive taps. The overlay is limited to linked glyphs and disables its own hit testing while text-selection mode is active, so transcript scrolling and selection remain unchanged.

Ambiguous dotted bare destinations such as README.md:42 can also be custom URL schemes, so they remain on the system path; use the explicit relative form ./README.md:42. Slash-containing relative paths and conventional extensionless names such as Makefile:12 remain supported.

UI evidence

Before:

Workspace link before tap

After — exact rebased head opening the existing workspace preview:

Workspace file preview

Tap workspace link and open Files preview

Full-resolution MP4

Verification

  • T3CodeTests/FeatureToolStateTests: passed again on the final reviewed head (21 test cases, 0 failed).
  • Full native gate: 223 tests in 27 suites passed on the exact rebased head.
  • Exact-head integrated iOS run: a seeded CONTRIBUTING.md:1 transcript link was exposed as a semantic link target and opened workspace-file-preview with the expected file.
  • git diff --check: passed; rebase preserved the feature patch exactly.
  • GPT-5.6 Sol high reviewed the frozen head, the MacroScope follow-up fix, and the text-selection hit-testing fix: no actionable findings; judged minimally scoped for the bug.
  • Direct Claude Opus 5 high review attempt: Claude Code 2.1.224, exit 1, HTTP 429 weekly-limit response before review; no Claude findings are claimed.
  • MacroScope's custom-scheme finding is fixed and covered by org.example:123, ambiguous bare-file, explicit-relative-file, and conventional extensionless-file cases. Cursor's text-selection finding is fixed by disabling only the invisible link overlay's hit testing while selection mode is active. MacroScope correctness passed on the identical reviewed tree, Cursor passed on the final metadata-only head, and MacroScope approvability defers this user-facing change to human review.
  • The first final-head native CI attempt hit the repository's existing ProjectFaviconStoreTests.svgFaviconsAreRasterizedBeforeCaching() iOS 27 WebKit GPU-process timeout. The commit metadata was refreshed to rerun CI; tree SHA 69cd4cae8fe3e8606ea34f00cd3efd65548271e8 and stable patch ID dcaf0513e45ce447433da2c650bc93c573d788e8 are unchanged.

Checklist

  • Small, focused bug fix
  • Explained what changed and why
  • Before/after UI evidence and interaction video
  • Focused tests, full native gate, and exact-head simulator proof
  • Independent Sol-high minimum-change review
  • Current fixed-head CI/MacroScope complete

Built with GPT-5.6 Sol in the Codex harness.


Note

Medium Risk
New path parsing and workspace boundary checks must reject traversal and out-of-root paths; link overlay touch handling interacts with text selection in recycled cells, though both areas have broad tests.

Overview
Makes workspace file links in native chat markdown tappable and routes them into the existing Files preview sheet, while https links still use the system browser.

Markdown gains an optional onOpenURL callback, a MarkdownOpenURLDisposition helper (unhandled file: URLs are discarded instead of opening externally), and a UIKit link hit-test overlay on linked text so taps work inside recycled transcript cells; the overlay turns off during Select text mode.

Thread detail resolves taps via new FeatureWorkspaceFileLink / FeatureWorkspaceFileLinkRoute logic (POSIX, Windows, UNC, relative paths, :line[:column], workspace containment) and shows an alert when a link looks like a workspace path but is rejected.

A small provider label fix stops using global snapshot.providers when providersByEnvironment exists but has no entry for the thread’s environment.

Reviewed by Cursor Bugbot for commit 5b37739. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Open workspace file links from markdown messages in the iOS chat transcript

  • Tapping a file or directory link in a chat message opens a preview sheet scoped to the active workspace; unsupported workspace destinations show an alert and external links fall back to system handling.
  • Adds MarkdownLinkInteractionView (UIKit) with precise glyph-level hit-testing for inline links, bridged into SwiftUI via MarkdownLinkInteractionOverlay; link taps are disabled while text selection is active.
  • Adds FeatureWorkspaceFileLink to validate and normalize POSIX, Windows drive, and UNC paths, preventing workspace escapes and stripping line/column positions.
  • Fixes provider label resolution in FeatureThread.homeProviderLabel and HomeThreadRowContext to fall back to the global providers list when the environment-scoped catalog is missing.

Macroscope summarized 5b37739.

Delivery: direct
Validated against Theo commit: f98cab5
Depends on: none
Merge order: this PR only
Validation status: Mergeable with runnable checks green; requested review changes remain. The unrelated Vercel authorization failure is a maintainer-side gate.

@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3f4dae10-f95e-45a9-a3a4-63c6543446c9

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Aug 9, 2026
@saphid
saphid force-pushed the t3code/fix-swiftui-file-links-upstream branch from 6cf32bb to fa75b83 Compare August 9, 2026 10:28
@saphid saphid changed the title feat(swift-ios): open workspace file links fix(swift-ios): open workspace file links Aug 9, 2026
Comment thread apps/swift-ios/Features/Files/FeatureFilesView.swift
Comment thread apps/swift-ios/Features/Shared/FeatureToolModels.swift Outdated
@saphid
saphid force-pushed the t3code/fix-swiftui-file-links-upstream branch 3 times, most recently from ce45355 to faccbb2 Compare August 9, 2026 10:48
@saphid

saphid commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

@t3dotgg Macroscope has completed on the final head faccbb279 with no new findings, and both prior review threads have been addressed and resolved. Would you review the scope and implementation when you have a chance? The native suite passes all 223 tests; the only failing status is the unrelated Vercel marketing authorization gate.

@saphid
saphid force-pushed the t3code/fix-swiftui-file-links-upstream branch 3 times, most recently from faccbb2 to 025cfc5 Compare August 10, 2026 01:20
Comment thread apps/swift-ios/Features/Shared/FeatureToolModels.swift Outdated
@saphid
saphid marked this pull request as ready for review August 10, 2026 01:26
@macroscopeapp

macroscopeapp Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Needs human review

1 blocking correctness issue found. This PR introduces new workspace file link navigation functionality (~960 lines), including path resolution logic, a UIKit link overlay, and sheet-based file previews. New user-facing features of this scope warrant human review. Additionally, there are unresolved comments about path handling edge cases.

You can customize Macroscope's approvability policy. Learn more.

@saphid
saphid force-pushed the t3code/fix-swiftui-file-links-upstream branch from 025cfc5 to e85cc0d Compare August 10, 2026 01:43
Comment thread apps/swift-ios/Features/Chat/MarkdownMessageView.swift
@saphid
saphid force-pushed the t3code/fix-swiftui-file-links-upstream branch 2 times, most recently from 5ddc475 to 2ce2933 Compare August 10, 2026 02:03
@saphid

saphid commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

@t3dotgg Ready for your review against the current SwiftUI branch. Final head 2ce2933; all executable current-head CI is green, focused/full native and integrated evidence are in the PR body, and all review threads are resolved. MacroScope correctness passed on the identical reviewed tree and approvability defers this user-facing change to human review.

@t3dotgg
t3dotgg force-pushed the t3code/rebuild-mobile-app-swift branch from 4cb3307 to 497f54f Compare August 10, 2026 03:58
@saphid

saphid commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

Rebuilt as one focused commit on the exact current Theo SwiftUI head (5b7ee58f6). The old red status was a stale branch-history conflict, not a feature conflict; Theo still lacked transcript → contained workspace preview behavior.

Final behavior uses one reusable workspace containment resolver, keeps remote links unchanged, rejects traversal/authority/custom-scheme/outside-root paths with feedback, handles line/column suffixes, preserves selectable transcript text, and routes taps correctly after cell reuse.

Verification:

  • native CI: 331 total / 330 passed / 1 pre-existing skip / 0 failed
  • git diff --check: clean
  • real iPhone 17 simulator interaction: transcript README link opened the contained workspace preview
  • private proof video: https://alexs-macbook-pro-1.tail4e5636.ts.net:8766/swiftui-transcript-file-link-proof-20260810.mp4
  • first direct Claude Opus 5 high review: exit 0; three medium findings (Bold Text geometry, unused location exposure, silent rejection) were fixed
  • final post-fix review was attempted twice. One stream aborted; the parent retry exited 1 with HTTP 429 session-limit before any tokens/findings. No final-review verdict is claimed. The post-fix full native suite and self-audit are green.

Conflict classification: branch-history only; no upstream feature duplicate.

@saphid
saphid force-pushed the t3code/fix-swiftui-file-links-upstream branch from 2ce2933 to 6640d9c Compare August 10, 2026 12:12
@github-actions github-actions Bot added size:XL 500-999 changed lines (additions + deletions). and removed size:L 100-499 changed lines (additions + deletions). labels Aug 10, 2026
Comment thread apps/swift-ios/Features/Chat/ThreadDetailView.swift
@saphid

saphid commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

Dependent follow-up is now preserved separately at saphid/swiftui-file-preview-navigation (cc21b952a), stacked one commit on this PR head. It intentionally does not expand #5803. After #5803 lands, that branch can be rebased into its own focused PR for file info, Files → containing directory, and nested Markdown preview navigation while reusing this PR's one containment resolver.

Verification: 21 focused tests; full native 331 pass / one pre-existing skip; integrated iPhone 17 proof; git diff --check clean. Tailnet-only video: https://alexs-macbook-pro-1.tail4e5636.ts.net:10013/file-preview-navigation-info-proof.mp4

Direct Opus review was unavailable due confirmed HTTP 429 before inference; no independent verdict is claimed.

@t3-code t3-code Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one blocking workspace-root fallback issue remains.

}

private var workspaceRoot: String? {
currentThread.worktreePath

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an empty or whitespace-only worktreePath wins this coalescing expression and prevents fallback to the valid project path. the resolver then rejects the empty root, so transcript file links fail for these threads. trim and require a non-empty worktree path before falling back to the project path.

@t3-code t3-code Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

additional independent review found a remote-windows compatibility blocker in workspace file-link resolution.

}

guard !destination.path.isEmpty,
!destination.path.contains(":"),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this unconditionally rejects drive-qualified windows paths such as C:/repo/Sources/App.swift:42. the surrounding absolute-path and containment logic also assumes POSIX / roots, but the iOS client supports remote windows environments and the shared composer serializer explicitly normalizes windows paths. normalize according to the remote workspace root, including drive letters and separators, then apply the same containment check. add a windows-root regression test.

@saphid

saphid commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

Updated frozen head: 0a42fd8df143adc3acb13c0d658f9515dc9cdce7. The repair resolves remote Windows, UNC, authority, and file-link routing and fails closed for unhandled Markdown file links. Focused native verification passed 27 tests with 0 failures and 0 skips. Durable result bundle: ~/Library/Developer/XcodeBuildMCP/workspaces/t3code-8f2a7900-7e7011b508e2/result-bundles/test_sim_2026-08-13T15-13-44-170Z_pid9862_ec3e6956.xcresult. Final independent review of this frozen head reported no actionable findings.

@saphid
saphid force-pushed the t3code/fix-swiftui-file-links-upstream branch from 0a42fd8 to c6b03c9 Compare August 13, 2026 15:39
@saphid

saphid commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

Refreshed this branch onto current t3code/rebuild-mobile-app-swift (f98cab553) and repaired the provider-catalog compatibility failure from the merge build.

The environment-specific provider catalog remains authoritative when present. Legacy snapshots now fall back to snapshot.providers when no per-environment catalog exists.

Verification on exact head c6b03c9716ce384472bbdb6194f2cb65ea244e45:

  • Swift parse: passed
  • diff check: passed
  • focused native HomeThreadMetadataTests: 5 passed, 0 failed
  • result bundle: test_sim_2026-08-13T15-38-14-487Z_pid9862_a033a7c6.xcresult

A fresh direct Claude Opus 5 high review was attempted after the test pass. The process exited 1 because the session quota is exhausted until 04:50 AEST. No independent review is claimed for this refreshed head.

}
.sheet(item: $linkedFile) { link in
NavigationStack {
FeatureFilePreviewView(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium Chat/ThreadDetailView.swift:108

Directory links open a failing “File unavailable” preview instead of the existing directory browser. FeatureWorkspaceFileLink.entry loses the directory kind by marking every resolved path as .file, and this sheet always constructs FeatureFilePreviewView, whose load() calls readFile; preserve the resolved kind and route directory entries to FeatureFileDirectoryView (with the appropriate path/title).

🤖 Copy this AI Prompt to have your agent fix this:
In file @apps/swift-ios/Features/Chat/ThreadDetailView.swift around line 108:

Directory links open a failing “File unavailable” preview instead of the existing directory browser. `FeatureWorkspaceFileLink.entry` loses the directory kind by marking every resolved path as `.file`, and this sheet always constructs `FeatureFilePreviewView`, whose `load()` calls `readFile`; preserve the resolved kind and route directory entries to `FeatureFileDirectoryView` (with the appropriate path/title).

Comment thread apps/swift-ios/Features/Workspace/WorkspaceView.swift Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c6b03c9. Configure here.

Comment thread apps/swift-ios/Features/Workspace/DailyUXModels.swift Outdated
@saphid

saphid commented Aug 15, 2026

Copy link
Copy Markdown
Contributor Author

Closing this version while I rebuild the upstream contribution set from the latest base. Clean versions are coming soon.

@saphid saphid closed this Aug 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL 500-999 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant