Bring a large pot of lightly salted water to a boil. Stir 1/4 cup olive oil and basil into water. Cook spaghetti in the boiling water, stirring occasionally, until cooked through but firm to the bite, about 12 minutes. Drain and return to pot.
Heat remaining olive oil in a small pot over medium heat. Cook and stir onion, garlic, thyme, and sea salt in hot oil until fragrant and softened, 8 to 10 minutes. Pour olive mixture over spaghetti and stir.