With regards to lens compatibility, the determining factor here is the lens mount design rather than the sensor. The short answer is that your 400D body will probably remain compatible with Canon's lenses for decades to come, although it's possible that the kit lens that came with your 400D (assuming you bought it as a kit) will become obsolete.
Canon currently sells two slightly different lens families - EF and EF-S. All of Canon's EOS SLRs, including your 400D, will mount EF lenses. Only the 400D, 350D, and 300D will mount EF-S lenses. EF-S lenses will not mount on Canon's other SLR models. Your 400D therefore has the best of both worlds. If you have a full-frame digital SLR that only takes EF lenses, you might be worried that Canon will eventually drop the EF system in favour of EF-S, but that seems unlikely.
The EF mount dates back to the Canon EOS 650 of 1987, which was the very first Canon EOS camera. All of Canon's EOS film SLRs use EF lenses, without a crop factor. EF lenses also work with all of Canon's digital SLRs, including your 400D. The cropping factor is slightly different depending on the model (the 400D is x1.6, the 1D range is mostly x1.3, the full-frame models don't have a crop factor), but the lens works just as well. I believe that some modern image-stabilised EF lenses don't stabilise well on old Canon film SLRs, but don't quote me on that.
Canon launched the EF-S mount with the 300D back in 2003, and continued it with with the 350D and 400D, with which it is still current. The EF-S lenses are smaller and cheaper to make than EF lenses. They use the same basic bayonet mount, but they will only fit on the 300D, the 350D, and the 400D. If you try mounting one on another Canon digital or film SLR you would have to modify the lens, and you would run the risk of damaging your return mirror, because the EF-S lenses protrude further back into the camera body. There is only a limited range of EF-S lenses. At the moment therefore the EF-S lens system that fits onto your 400D is in the minority.
Once upon a time Canon did drop an entire lens mount. When Canon launched the EOS system in 1987 the company ditched its previous lens mount, the FD. This left a lot of photographers angry. You'll notice that eBay has a lot of surprisingly cheap Canon lenses for the FD-mount - they are cheap because they cannot be used on modern EOS bodies. It seems extremely unlikely that Canon will do that again. EF has been around for a while and it works well.
It's not clear what Canon will do in the future. The company might introduce full-frame sensors into all of its digital SLRs, if it becomes economical to do so - in which case EF-S might become a dead end - or the company might abandon full-frame sensors, if they find a way to make a smaller sensor with the same or greater image quality than a full-frame sensor. Nonetheless the EF lenses will still work, they'll just have a greater or lesser crop factor.