We present a first exploratory investigation of the dynamical evolution of a dusty stellar wind envelope along the upper AGB and its transformation into a planetary nebula. We find the existence of AGB stars with detached shells to be a natural consequence of the mass-loss variations during a thermal pulse. It is also demonstrated that due to the large dynamical effects caused by the ionizing radiation field and the fast wind of the central star, it is impossible to deduce the AGB mass loss history from the planetary's density and velocity distribution. The structure of the halo, however, is still determined by the AGB mass loss history. The rapid decline of mass loss expected in the aftermath of thermal pulses leads to extended shells of low densities and explains halos with sharp boundaries.