Going through this myself for the first time as well. My understanding is that the IRS will treat your taxable capital gains in a US brokerage as foreign sourced as you are resident in the UK. I'm less sure about dividends - they may be able to be treaty sourced, but I'm having a difficult time understanding the provision in the treaty.
The other part that may or may not apply to you is that the FTC works by dividing your income into baskets, and each credit can only be applied to the taxes paid within each basket. The relevant baskets would be general, passive, and treaty-sourced.
General sourcing rules:
newcomer link: https://www.irs.gov/pub/int_practice_units/ftc_c_10_02_05.pdf [nonactive] (pg 15 for capital gains)