4. The maximum value of the function $y=\frac{4-\sin x}{3-\cos x}$ is

保留了源文本的换行和格式。
4. $\frac{6+\sqrt{6}}{4}$.

Notice that, the function can be regarded as the slope of the line connecting the fixed point $(3,4)$ and the moving point $(\cos x, \sin x)$, and the trajectory of the moving point $(\cos x, \sin x)$ is a unit circle.
Let the equation of the line passing through the point $(3,4)$ be
$$
y-4=k(x-3) \Rightarrow y-k x+(3 k-4)=0 \text {. }
$$

When the slope takes its maximum value, the line should be a tangent to the unit circle. Thus, the distance from the origin to the line is 1.
Therefore, $|3 k-4|=\sqrt{k^{2}+1} \Rightarrow k=\frac{6 \pm \sqrt{6}}{4}$.
Hence, the maximum value of the function is $\frac{6+\sqrt{6}}{4}$.