Handling "infinite" values of a publisher in a MainActor

Yes. TextViewModel.init() runs on the main actor, and the Task { … } you launch from there inherits this actor context. This ensures that your @Published property is updated on the main thread.

No and no. The Task is a totally independent task. It will run to completion unless explicitly cancelled, and its lifetime is managed by the concurrency runtime.

You should store the task in a property inside the view model and then cancel it manually in deinit. (You might encounter a complication here due to Deinit and MainActor, I'm not sure. It's a good idea to activate the concurrency checks with -Xfrontend -warn-concurrency.)